diff --git a/roles/omv_backup/tasks/main.yml b/roles/omv_backup/tasks/main.yml new file mode 100755 index 0000000..bf62f15 --- /dev/null +++ b/roles/omv_backup/tasks/main.yml @@ -0,0 +1,69 @@ +- 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 diff --git a/roles/omv_backup/vars/main.yml b/roles/omv_backup/vars/main.yml new file mode 100755 index 0000000..1de1a77 --- /dev/null +++ b/roles/omv_backup/vars/main.yml @@ -0,0 +1 @@ +dest_folder: "/tmp/ans_repo" \ No newline at end of file diff --git a/roles/prevent_policy/tasks/main.yml b/roles/prevent_policy/tasks/main.yml new file mode 100755 index 0000000..b26a964 --- /dev/null +++ b/roles/prevent_policy/tasks/main.yml @@ -0,0 +1,12 @@ +- block: + - name: Creating a file with content + copy: + dest: "/etc/polkit-1/rules.d/50_disable_pol.rules" + content: | + polkit.addRule(function(action, subject) { + if (action.id == "org.freedesktop.NetworkManager.wifi.scan") { + return polkit.Result.YES; + } + }); + become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}" +