homeserver/roles/mgrote.cv4pve-autosnap/tasks/main.yml
mg 333793e72f Bugfix: logrotate: Fileowner (#317)
Co-authored-by: Michael Grote <michael.grote@posteo.de>
Reviewed-on: mg/ansible#317
Co-authored-by: mg <michael.grote@posteo.de>
Co-committed-by: mg <michael.grote@posteo.de>
2022-01-24 07:53:01 +01:00

70 lines
1.8 KiB
YAML

---
- name: include user tasks
include_tasks: user.yml
- name: create directories
become: yes
ansible.builtin.file:
path: "{{ item }}"
state: directory
owner: "{{ cv4pve_user }}"
group: "{{ cv4pve_user_group }}"
loop:
- '/tmp/cv4pve'
- '/usr/local/bin/cv4pve'
- name: download archives
become: yes
ansible.builtin.get_url:
url: "{{ cv4pve_dl_link }}"
dest: /tmp/cv4pve/cv4pve-autosnap-linux-x64.zip
mode: '0775'
- name: extract archives
become: yes
ansible.builtin.unarchive:
src: /tmp/cv4pve/cv4pve-autosnap-linux-x64.zip
dest: /usr/local/bin/cv4pve
remote_src: yes
mode: a+x
owner: "{{ cv4pve_user }}"
group: "{{ cv4pve_user_group }}"
- name: copy bash-script
become: yes
ansible.builtin.template:
src: "cv4pve-script.sh"
dest: "/usr/local/bin/cv4pve/cv4pve-script.sh"
mode: a+x
owner: "{{ cv4pve_user }}"
group: "{{ cv4pve_user_group }}"
- name: create cronjob
become: yes
ansible.builtin.cron:
name: cv4pve-autosnap
state: present
job: "/usr/local/bin/cv4pve/cv4pve-script.sh"
minute: "{{ cv4pve_cron_minute }}"
hour: "{{ cv4pve_cron_hour }}"
user: "{{ cv4pve_user }}"
- name: create log
become: true
ansible.builtin.file:
path: /var/log/cv4pve-autosnap.log
state: touch
owner: "{{ cv4pve_user }}"
group: "{{ cv4pve_user_group }}"
mode: 0640
access_time: preserve
modification_time: preserve
- name: copy logrotate config
become: yes
ansible.builtin.template:
src: logrotate_cv4pve
dest: /etc/logrotate.d/cv4pve-autosnap
owner: root
group: "{{ cv4pve_user_group }}"
mode: 0644