|
| 1 | +--- |
| 2 | +- name: Install Python | Combine Jupyter packages |
| 3 | + ansible.builtin.set_fact: |
| 4 | + python_jupyter_packages: "{{ python_jupyter_packages + python_jupyter_workbench_packages }}" |
| 5 | + when: python_jupyter_workbench |
| 6 | + |
| 7 | +- name: Install Python | Install Jupyter packages (virtualenv method) |
| 8 | + ansible.builtin.pip: |
| 9 | + name: "{{ python_jupyter_packages }}" |
| 10 | + virtualenv_command: "/opt/python/{{ python_jupyter_python_version }}/bin/python -m venv" |
| 11 | + virtualenv: "{{ python_jupyter_virtualenv_path }}" |
| 12 | + when: python_jupyter_install_method == "virtualenv" |
| 13 | + |
| 14 | +- name: Install Python | Install Jupyter packages (system method) |
| 15 | + ansible.builtin.pip: |
| 16 | + name: "{{ python_jupyter_packages }}" |
| 17 | + executable: pip3 |
| 18 | + when: python_jupyter_install_method == "system" |
| 19 | + |
| 20 | +- name: Install Python | Set path to jupyter-nbextension |
| 21 | + ansible.builtin.set_fact: |
| 22 | + jupyter_nbextension_path: "{{ (python_jupyter_install_method == 'virtualenv') | ternary(python_jupyter_virtualenv_path + '/bin/', '') }}jupyter-nbextension" |
| 23 | + jupyter_etc_nbconfig: "{{ (python_jupyter_install_method == 'virtualenv') | ternary('/opt/jupyter', '/usr') }}/etc/jupyter/nbconfig" |
| 24 | + |
| 25 | +- name: Install Python | Install Workbench's Jupyter plugin |
| 26 | + ansible.builtin.command: | |
| 27 | + {{ jupyter_nbextension_path }} install --sys-prefix --py rsp_jupyter |
| 28 | + register: command_result |
| 29 | + # jupyter-nbextension returns the needed information in stderr |
| 30 | + changed_when: "'Copying:' in command_result.stderr" |
| 31 | + when: python_jupyter_workbench |
| 32 | + |
| 33 | +- name: Install Python | Enable Workbench's Jupyter plugin |
| 34 | + ansible.builtin.shell: | |
| 35 | + grep 'rsp_jupyter/index' {{ jupyter_etc_nbconfig }}/notebook.json || echo "File doesn't exist yet" |
| 36 | + {{ jupyter_nbextension_path }} enable --sys-prefix --py rsp_jupyter |
| 37 | + register: command_result |
| 38 | + changed_when: "'\"rsp_jupyter/index\": true' not in command_result.stdout" |
| 39 | + when: python_jupyter_workbench |
0 commit comments