0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

汎用分析環境の構築(Jupyter containerをAnsibleで構築)

Posted at

背景

前回途中でほったらかしとなっていた汎用分析環境の構築を進める。
今回やったことは以下。

  • jupyter containerを利用したdockerベースのjupyter notebook環境を作る
  • dockerのデータ永続領域をNFS経由とする
  • jupyter notebookのフロントエンドをnginxでリバースプロキシ化する
  • 構築をansible playbook化する

構築した環境

前回まで

本記事は以下の記事の続きです。

今回追加した構成

前回の構成図は以下の通りです。

![前回の構成図]
(https://camo.qiitausercontent.com/832b6361d848aa852fdf5565fc47bfdffcdeeb40/68747470733a2f2f71696974612d696d6167652d73746f72652e73332e616d617a6f6e6177732e636f6d2f302f3239383037382f38363964333833372d316161652d333339642d623439322d3633623934313133343266652e706e67)


今回の構成図。色がついている部分が追加分。

for_testing_r2.png

構築に利用したansible資材は以下にpushしてあります。(前回から更新)

構築方法

基本的にはmaster側からansibleを叩けば終わり。
jupyter containerのplaybookはこんな感じ。

roles/container/tasks/main.yml
- name: Install worker package by apt
  apt:
    name: python3-pip
    state: present

- name: Install docker-py
  pip:
    name: "docker"
    state: present

- name: Create container jupyter scipy-notebook
  docker_container:
    name: scipy-notebook
    hostname: scipy-notebook_001
    image: jupyter/scipy-notebook:latest
    detach: yes
    auto_remove: yes
    ports:
      - "10000:8888"
    volumes:
      - /mnt/work:/home/jovyan/work

起動後、クライアントPCから以下URLにアクセスすると、jupyter notebookの認証画面が表示される

http://192.168.32.10/

スクリーンショット (14).png

vagrant@worker001:~$ docker ps -a
CONTAINER ID        IMAGE                           COMMAND                  CREATED             STATUS              PORTS                     NAMES
34e624124079        jupyter/scipy-notebook:latest   "tini -g -- start-no…"   5 seconds ago       Up 5 seconds        0.0.0.0:10000->8888/tcp   scipy-notebook
vagrant@worker001:~$ docker exec -it scipy-notebook /bin/bash
jovyan@scipy-notebook_001:~$ jupyter notebook list
Currently running servers:
http://0.0.0.0:8888/?token=c51fdbe9ed6774a85d89e466fda819729705084f0bec2d67 :: /home/jovyan
jovyan@scipy-notebook_001:~$

token=の後の文字列(c51~2d67)までをコピーして、Password or tokenのテキストボックスに入れて、ログイン。
あとはいつものjupyter notebookと同じ使い方ができる。

スクリーンショット (15).png

残課題

まだまだやり残しが多い。。。

  • ansible playbookのパラメータ化
  • 複数ユーザ、複数環境を考慮したディレクトリ設計
  • ログの集約

次回以降の宿題。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?