- block: - name: include vault ansible.builtin.include_vars: file: jaydee.yml - name: Delete content & directory ansible.builtin.file: state: absent path: "{{ dest_folder }}" - name: GIT pull tags: - git_pull git: repo: "https://{{ git_user | urlencode }}:{{ git_password_mqtt | urlencode }}@gitlab.sectorq.eu/jaydee/omv_backup.git" dest: "{{ dest_folder }}" update: yes clone: yes version: main - debug: msg: "{{ inventory_hostname }}" - name: Create a directory if it does not exist ansible.builtin.file: path: /myapps state: directory mode: '0755' owner: root group: root - name: Upload script ansible.builtin.copy: src: "{{ dest_folder }}/omv_backup.py" dest: /myapps/omv_backup.py remote_src: true mode: '0755' owner: root group: root when: inventory_hostname != 'nas.home.lan' - name: Upload requirements ansible.builtin.copy: src: "{{ dest_folder }}/requirements.txt" dest: /myapps/requirements.txt remote_src: true when: inventory_hostname != 'nas.home.lan' - name: Install venv ansible.builtin.apt: name: - python3-virtualenv - name: Install specified python requirements in indicated (virtualenv) ansible.builtin.pip: requirements: /myapps/requirements.txt virtualenv: /myapps/venv - name: 'Ensure an old job is no longer present. Removes any job that is prefixed by "#Ansible: an old job" from the crontab' ansible.builtin.cron: name: "omv_backup" state: absent - name: Ensure a job that runs at 2 and 5 exists. Creates an entry like "0 5,2 * * ls -alh > /dev/null" ansible.builtin.cron: name: "omv_backup" minute: "0" hour: "8" job: "/myapps/venv/bin/python3 /myapps/omv_backup.py -b > /dev/null 2>&1 &" become: true