homeserver/roles/mgrote.cv4pve-autosnap/tasks/main.yml

71 lines
1.8 KiB
YAML
Raw Normal View History

2020-08-18 11:57:53 +02:00
---
- name: include user tasks
include_tasks: user.yml
2020-08-18 11:57:53 +02:00
- name: create directories
become: yes
ansible.builtin.file:
2020-08-18 11:57:53 +02:00
path: "{{ item }}"
state: directory
owner: "{{ cv4pve_user }}"
group: "{{ cv4pve_user_group }}"
2020-08-18 11:57:53 +02:00
loop:
- '/tmp/cv4pve'
- '/usr/local/bin/cv4pve'
- name: download archives
become: yes
ansible.builtin.get_url:
url: "{{ cv4pve_dl_link }}"
2020-08-18 11:57:53 +02:00
dest: /tmp/cv4pve/cv4pve-autosnap-linux-x64.zip
mode: '0775'
- name: extract archives
2020-08-18 11:57:53 +02:00
become: yes
ansible.builtin.unarchive:
2020-08-18 11:57:53 +02:00
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 }}"
2020-08-18 11:57:53 +02:00
- name: copy bash-script
become: yes
ansible.builtin.template:
2020-08-18 11:57:53 +02:00
src: "cv4pve-script.sh"
dest: "/usr/local/bin/cv4pve/cv4pve-script.sh"
mode: a+x
owner: "{{ cv4pve_user }}"
group: "{{ cv4pve_user_group }}"
2020-08-18 11:57:53 +02:00
- name: create cronjob
become: yes
ansible.builtin.cron:
2020-08-18 11:57:53 +02:00
name: cv4pve-autosnap
state: present
job: "/usr/local/bin/cv4pve/cv4pve-script.sh"
minute: "{{ cv4pve_cron_minute }}"
hour: "{{ cv4pve_cron_hour }}"
user: "{{ cv4pve_user }}"
2020-08-18 11:57:53 +02:00
- name: create log
2020-08-18 11:57:53 +02:00
become: true
ansible.builtin.file:
2020-08-18 11:57:53 +02:00
path: /var/log/cv4pve-autosnap.log
state: touch
owner: "{{ cv4pve_user }}"
group: "{{ cv4pve_user_group }}"
mode: 0640
2020-08-18 11:57:53 +02:00
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: "{{ cv4pve_user }}"
group: "{{ cv4pve_user_group }}"
2020-08-18 11:57:53 +02:00
mode: 0644