diff --git a/roles/jupyter/tasks/enable-or-disable.yml b/roles/jupyter/tasks/enable-or-disable.yml new file mode 100644 index 000000000..ad8bb17ad --- /dev/null +++ b/roles/jupyter/tasks/enable-or-disable.yml @@ -0,0 +1,25 @@ +- name: systemd daemon-reload + systemd: + daemon_reload: yes + + +# enable or disable +- name: Enable & Restart jupyterhub + systemd: + name: "{{ item }}" + enabled: yes + state: restarted + with_items: + - jupyter + when: jupyter_enabled + +- name: Disable jupyterhub + systemd: + name: "{{ item }}" + enabled: no + state: stopped + with_items: + - jupyter + when: not jupyter_enabled + + diff --git a/roles/jupyter/tasks/install.yml b/roles/jupyter/tasks/install.yml index 3330ba743..4e2981584 100644 --- a/roles/jupyter/tasks/install.yml +++ b/roles/jupyter/tasks/install.yml @@ -1,13 +1,16 @@ - name: Make the directories to hold notebooks file: state: directory - path: '{{ notebook_dir }}' + path: '{{ item }}' + with_items: + - '{{ notebook_dir }}/etc/jupyter' + - '{{ notebook_dir }}/etc/jupyterhub' + - '{{ notebook_dir }}/etc/systemd' - name: Use pip to install into a virtual environment pip: name: - - jupyterlab - #- jupyter_vim + - pip virtualenv: "{{ jupyter_venv }}" # /opt/iiab/jupyter virtualenv_site_packages: no virtualenv_command: /usr/bin/virtualenv @@ -15,3 +18,13 @@ extra_args: "--no-cache-dir" when: internet_available +- name: Fetch the Littlest JupyterHub code + ansible.builtin.git: + repo: '{{ jupyterhub_url }} + dest: '{{ jupyter_venv }}' + +- name: Install a bootstrap.py that permits installation on other than Ubunt + template: + src: bootstrap.py + dest: '{{ jupyter_venv }}' + diff --git a/roles/jupyter/tasks/main.yml b/roles/jupyter/tasks/main.yml index 9f1804b38..137a01b84 100644 --- a/roles/jupyter/tasks/main.yml +++ b/roles/jupyter/tasks/main.yml @@ -3,7 +3,7 @@ when: jupyter_installed is undefined -#- include_tasks: enable-or-disable.yml +- include_tasks: enable-or-disable.yml - name: Add 'jupyter' variable values to {{ iiab_ini_file }} diff --git a/roles/jupyter/templates/jupyter.service b/roles/jupyter/templates/jupyter.service new file mode 100644 index 000000000..81cee0dd2 --- /dev/null +++ b/roles/jupyter/templates/jupyter.service @@ -0,0 +1,11 @@ +[Unit] +Description=JupyterHub +After=syslog.target network.target + +[Service] +User=hubuser +Environment="PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/opt/iiab/jupyterhub/bin" +ExecStart=/opt/iiab/jupyterhub/bin/jupyterhub -f /opt/iiab/jupyterhub/etc/jupyterhub/jupyterhub_config.py + +[Install] +WantedBy=multi-user.target