diff --git a/local.yml b/local.yml index 11970083379939d14b878fcc9fb0358edcb93a6a..466be3f4870aa654eb094a3a7ba39099b2b035ed 100644 --- a/local.yml +++ b/local.yml @@ -1,6 +1,16 @@ --- - hosts: localhost + vars: + target_user: pi + jupyter_service: true + ignore_python_version: false + pre_tasks: + - name: Check python version + fail: + msg: Python version is not supported. Set ignore_python_version to true to ignore this. + when: (not ignore_python_version) and not (ansible_python_version is version('3.7.0', '>=') and ansible_python_version is version('3.10.0', '<')) + # - name: Upgrade packages # become: true # apt: diff --git a/roles/jupyter-lab/files/jupyter.service b/roles/jupyter-lab/files/jupyter.service index 5b44a741e08dac48e962fd815ab93b500174cab1..bdbf4478cc954609169ed9a7aa7ed1ac12b5abee 100644 --- a/roles/jupyter-lab/files/jupyter.service +++ b/roles/jupyter-lab/files/jupyter.service @@ -5,9 +5,9 @@ Description=Jupyter Lab Type=simple PIDFile=/run/jupyter.pid # Password: [empty string] -ExecStart=/usr/bin/python3 -m jupyterlab --ip="0.0.0.0" --notebook-dir=/home/pi/notebooks --no-browser --NotebookApp.password='sha1:9a2d316959ac:843b251c27024afb46174ce40ce0ebebcf29217b' -User=pi -Group=pi +ExecStart=/home/{{ target_user }}/.ml-venv/bin/jupyter-lab --ip="0.0.0.0" --notebook-dir=/home/{{ target_user }}/notebooks --no-browser --NotebookApp.password='sha1:9a2d316959ac:843b251c27024afb46174ce40ce0ebebcf29217b' +User={{ target_user }} +Group={{ target_user }} Restart=always RestartSec=10 diff --git a/roles/jupyter-lab/tasks/main.yml b/roles/jupyter-lab/tasks/main.yml index 6ae98f255535f67a8805d2c9fb4c0c671eeeefd4..f5b9df263bb95ed9ffc86819281131930634a788 100644 --- a/roles/jupyter-lab/tasks/main.yml +++ b/roles/jupyter-lab/tasks/main.yml @@ -3,10 +3,10 @@ - name: Notebooks dir file: - path: /home/pi/notebooks + path: "/home/{{ target_user }}/notebooks" state: directory - owner: pi - group: pi + owner: "{{ target_user }}" + group: "{{ target_user }}" # This should be optimized so that only one check / install is needed # Still we should make sure that pip3 is actually installed before trying to use it @@ -15,23 +15,25 @@ apt: name: - python3-pip + - python3-venv state: present update_cache: true - name: Install jupyter-lab - become: true pip: - executable: pip3 + virtualenv_command: /usr/bin/python3 -m venv + virtualenv: "/home/{{ target_user }}/.ml-venv" name: jupyterlab state: present - name: Install systemd service become: true - copy: + template: src: files/jupyter.service dest: /etc/systemd/system/jupyter.service mode: '0644' - + when: jupyter_service + - name: Start Jupyter-Lab service become: true systemd: @@ -39,3 +41,5 @@ state: started enabled: true daemon_reload: true + when: jupyter_service + diff --git a/roles/misc-applications/tasks/main.yml b/roles/misc-applications/tasks/main.yml index 3903dcf80c72ecfc2fb69bf82c6edfacc54023c3..13052db5da9823aad7b6966da79286ee02979e79 100644 --- a/roles/misc-applications/tasks/main.yml +++ b/roles/misc-applications/tasks/main.yml @@ -1,2 +1,11 @@ --- # roles/misc-applications + +- name: Install useful cli applications + become: true + apt: + name: + - neovim + - tmux + state: present + diff --git a/roles/ml-python-packages/files/requirements.txt b/roles/ml-python-packages/files/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..4a89ed45d5ecb42a6855f0f8a97963ee4d3cf356 --- /dev/null +++ b/roles/ml-python-packages/files/requirements.txt @@ -0,0 +1,6 @@ +numpy==1.21.* +matplotlib==3.4.* +pandas==1.3.* +Pillow==8.4.* +scikit-learn==1.0.* + diff --git a/roles/ml-python-packages/tasks/main.yml b/roles/ml-python-packages/tasks/main.yml index 359f487e855c68e7bd4f9c9dbc9bec901f5feebc..ee1c3cf783e0c088e45077b4421e4ca39fe6ba75 100644 --- a/roles/ml-python-packages/tasks/main.yml +++ b/roles/ml-python-packages/tasks/main.yml @@ -12,25 +12,23 @@ state: present update_cache: true -- name: Remove conflicting apt packages - become: true - apt: - name: - - python3-pil - - python3-numpy - state: absent +- name: Copy requirements.txt to remote fs + copy: + src: files/requirements.txt + dest: /tmp/ml-requirements.txt - name: Install ml python packages - become: true pip: - executable: pip3 - name: - - numpy - - sklearn - - matplotlib - - pandas - - Pillow + virtualenv_command: /usr/bin/python3 -m venv + requirements: /tmp/ml-requirements.txt + virtualenv: "/home/{{ target_user }}/.ml-venv" + # name: + # - numpy + # - sklearn + # - matplotlib + # - pandas + # - Pillow # - torch # - torchvision # - fastai - state: present + # state: present