Skip to content
74 changes: 33 additions & 41 deletions jupyter-collaboration/playbook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,68 +3,60 @@
become: true
tasks:

- apt: update_cache=yes

- name: Installing notebook and nbgrader
pip:
name: jupyter-collaboration
- name: Has jupyter
command: which jupyter
register: jupyter_path
ignore_errors: yes
become: yes
become_user: codio
become_method: su
become_flags: -l
register: aptout

- debug: var=aptout

- name: Remove jupyter-server-ydoc
pip:
name: jupyter-server-ydoc
state: absent
become: yes
become_user: codio
become_method: su
become_flags: -l
register: aptout1
- debug: var=jupyter_path

- debug: var=aptout1
- name: Fail if no jupyter
fail:
msg: "Jupyter is not installed"
when: jupyter_path.stdout == ""

- name: Install jupyter-server-ydoc-codio
pip:
name: jupyter-server-ydoc-codio
state: present
version: 2.1.1
# Jupyter Lab
- name: Check JupyterLab version
ansible.builtin.shell: |
jupyter --version 2>/dev/null |
sed -nE 's/^jupyterlab[[:space:]]*:[[:space:]]*(.*)$/\1/p'
register: jupyterlab_version
changed_when: false
failed_when: false
become: yes
become_user: codio
become_method: su
become_flags: -l
register: aptout2

- debug: var=aptout2
- name: Fail jupyter lab is less than 4.4 or does not exist
fail:
msg: "Jupyter Lab version must be 4.4 or higher"
when: >
jupyterlab_version.rc != 0 or
jupyterlab_version.stdout | trim == '' or
(jupyterlab_version.stdout | trim).split('.')[0] | int < 4 or
((jupyterlab_version.stdout | trim).split('.')[0] | int == 4 and
(jupyterlab_version.stdout | trim).split('.')[1] | int < 4)

- name: Remove jupyter-docprovider
pip:
name: jupyter-docprovider
state: absent
become: yes
become_user: codio
become_method: su
become_flags: -l
register: aptoutdocprovider

- debug: var=aptoutdocprovider
- apt: update_cache=yes

- name: Install jupyter-docprovider-codio
- name: Installing jupyter-collaboration-codio
pip:
name: jupyter-docprovider-codio
name: jupyter-collaboration-codio
extra_args: -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/
state: present
version: 2.1.1
version: 4.1.4rc0
become: yes
become_user: codio
become_method: su
become_flags: -l
register: aptoutdocprovider2
register: aptout

- debug: var=aptoutdocprovider2
- debug: var=aptout

- name: jupyter restarted
systemd:
Expand Down