diff --git a/local.yml b/local.yml index 4a61bae86cb16ffa072ebc4f1ba48868520a5e7c..52a6d83fe6647b2bb4dfe99631dea7213ea53913 100644 --- a/local.yml +++ b/local.yml @@ -1,35 +1,26 @@ ---- -- 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: - # upgrade: true - # update_cache: true - # force_apt_get: true - - - name: Update apt cache & install base requirements - become: true - apt: - update_cache: true - state: present - name: - - python3-pip - - python3-venv - # - libffi-dev # This is needed for jupyter on aarch64 to compile its C backend - - - roles: - - jupyter-lab - - ml-python-packages - - misc-applications +--- +- 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: Update apt cache & install base requirements + become: true + apt: + update_cache: true + state: present + name: + - python3-pip + - python3-venv + + roles: + - jupyter-lab + - ml-python-packages + - misc-applications diff --git a/roles/jupyter-lab/files/jupyter.service b/roles/jupyter-lab/files/jupyter.service index bdbf4478cc954609169ed9a7aa7ed1ac12b5abee..462c8df0c68c4ad8c325ce3b3c0e5ff7ede0bc80 100644 --- a/roles/jupyter-lab/files/jupyter.service +++ b/roles/jupyter-lab/files/jupyter.service @@ -1,15 +1,15 @@ -[Unit] -Description=Jupyter Lab - -[Service] -Type=simple -PIDFile=/run/jupyter.pid -# Password: [empty string] -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 - -[Install] -WantedBy=multi-user.target +[Unit] +Description=Jupyter Lab + +[Service] +Type=simple +PIDFile=/run/jupyter.pid +# Password: [empty string] +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 + +[Install] +WantedBy=multi-user.target diff --git a/roles/jupyter-lab/tasks/main.yml b/roles/jupyter-lab/tasks/main.yml index f7ded5a3554bf3ac3edd8e2452aa62ecda4934c5..c98db86ffef390ccc623852ad1eabc69c1c286cc 100644 --- a/roles/jupyter-lab/tasks/main.yml +++ b/roles/jupyter-lab/tasks/main.yml @@ -1,34 +1,35 @@ ---- -# roles/jupyter-lab - -- name: Notebooks dir - file: - path: "/home/{{ target_user }}/notebooks" - state: directory - owner: "{{ target_user }}" - group: "{{ target_user }}" - -- name: Install jupyter-lab - pip: - virtualenv_command: /usr/bin/python3 -m venv - virtualenv: "/home/{{ target_user }}/.ml-venv" - name: jupyterlab - state: present - -- name: Install systemd service - become: true - template: - src: files/jupyter.service - dest: /etc/systemd/system/jupyter.service - mode: '0644' - when: jupyter_service - -- name: Start Jupyter-Lab service - become: true - systemd: - name: jupyter - state: started - enabled: true - daemon_reload: true - when: jupyter_service - +--- +# roles/jupyter-lab + +- name: Notebooks dir + file: + path: "/home/{{ target_user }}/notebooks" + state: directory + owner: "{{ target_user }}" + group: "{{ target_user }}" + +- name: Install jupyter-lab + become: true + become_user: "{{ target_user }}" + pip: + virtualenv_command: /usr/bin/python3 -m venv + virtualenv: "/home/{{ target_user }}/.ml-venv" + name: jupyterlab==3.2.4 + state: present + +- name: Install systemd service + become: true + template: + src: files/jupyter.service + dest: /etc/systemd/system/jupyter.service + mode: '0644' + when: jupyter_service + +- name: Start Jupyter-Lab service + become: true + systemd: + name: jupyter + 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 13052db5da9823aad7b6966da79286ee02979e79..3eab41574767b21fbd141828714dff8e308b2eb8 100644 --- a/roles/misc-applications/tasks/main.yml +++ b/roles/misc-applications/tasks/main.yml @@ -1,11 +1,10 @@ ---- -# roles/misc-applications - -- name: Install useful cli applications - become: true - apt: - name: - - neovim - - tmux - state: present - +--- +# 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 index 4a89ed45d5ecb42a6855f0f8a97963ee4d3cf356..e0c328cad5afb1940548470a6d119ac8f7949fd2 100644 --- a/roles/ml-python-packages/files/requirements.txt +++ b/roles/ml-python-packages/files/requirements.txt @@ -3,4 +3,3 @@ 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 168e1aede0d33e76b57516e8c188f5b63f916abd..ccfc69093d419746b64c3a3ada29ea4d5ef6a91a 100644 --- a/roles/ml-python-packages/tasks/main.yml +++ b/roles/ml-python-packages/tasks/main.yml @@ -1,21 +1,22 @@ ---- -# roles/ml-python-packages - -- name: Install dependecies - become: true - apt: - name: - - libatlas-base-dev - state: present - -- name: Copy requirements.txt to remote fs - copy: - src: files/requirements.txt - dest: /tmp/ml-requirements.txt - -- name: Install ml python packages - pip: - virtualenv_command: /usr/bin/python3 -m venv - requirements: /tmp/ml-requirements.txt - virtualenv: "/home/{{ target_user }}/.ml-venv" - +--- +# roles/ml-python-packages + +- name: Install APT dependecies + become: true + apt: + name: + - libatlas-base-dev + state: present + +- name: Copy requirements.txt to remote fs + copy: + src: files/requirements.txt + dest: /tmp/ml-requirements.txt + +- name: Install ml python packages + become: true + become_user: "{{ target_user }}" + pip: + virtualenv_command: /usr/bin/python3 -m venv + requirements: /tmp/ml-requirements.txt + virtualenv: "/home/{{ target_user }}/.ml-venv"