2021-04-09 23:29:03 +02:00
|
|
|
---
|
2020-08-18 11:57:53 +02:00
|
|
|
- name: install restic-packages
|
|
|
|
become: yes
|
2021-01-02 10:30:54 +01:00
|
|
|
ansible.builtin.package:
|
2020-08-18 11:57:53 +02:00
|
|
|
name:
|
|
|
|
- restic
|
|
|
|
- logrotate
|
2020-12-22 13:20:29 +01:00
|
|
|
- cifs-utils
|
2020-08-18 11:57:53 +02:00
|
|
|
state: present
|
|
|
|
|
|
|
|
- name: create /etc/restic
|
|
|
|
become: yes
|
2020-11-21 19:41:19 +01:00
|
|
|
ansible.builtin.file:
|
2020-08-18 11:57:53 +02:00
|
|
|
path: /etc/restic
|
|
|
|
state: directory
|
|
|
|
|
|
|
|
- name: create restic mount-directory
|
|
|
|
become: yes
|
2020-11-21 19:41:19 +01:00
|
|
|
ansible.builtin.file:
|
2020-08-18 11:57:53 +02:00
|
|
|
path: "{{ restic_mount }}"
|
|
|
|
state: directory
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0777
|
|
|
|
|
|
|
|
- name: copy smb_password.txt
|
|
|
|
become: yes
|
2020-11-21 19:41:19 +01:00
|
|
|
ansible.builtin.template:
|
2020-08-18 11:57:53 +02:00
|
|
|
src: "smb_password.txt"
|
|
|
|
dest: "/etc/restic/smb_password.txt"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0700
|
|
|
|
|
|
|
|
- name: copy restic_backup.sh
|
|
|
|
become: yes
|
2020-11-21 19:41:19 +01:00
|
|
|
ansible.builtin.template:
|
2020-08-18 11:57:53 +02:00
|
|
|
src: "restic_backup.sh"
|
|
|
|
dest: "/usr/local/bin/restic_backup.sh"
|
|
|
|
mode: a+x
|
|
|
|
|
2020-12-22 12:23:10 +01:00
|
|
|
- name: create exclude.txt
|
2020-08-18 11:57:53 +02:00
|
|
|
become: yes
|
2020-12-22 12:23:10 +01:00
|
|
|
ansible.builtin.blockinfile:
|
|
|
|
path: "/etc/restic/exclude.txt"
|
|
|
|
create: yes
|
|
|
|
block: "{{ restic_exclude }}"
|
|
|
|
mode: 0644
|
2020-08-18 11:57:53 +02:00
|
|
|
|
|
|
|
- name: copy password.txt
|
|
|
|
become: yes
|
2020-11-21 19:41:19 +01:00
|
|
|
ansible.builtin.template:
|
2020-08-18 11:57:53 +02:00
|
|
|
src: "password.txt"
|
|
|
|
dest: "/etc/restic/password.txt"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0700
|
|
|
|
|
|
|
|
- name: create restic cronjob
|
|
|
|
become: yes
|
2020-11-21 19:41:19 +01:00
|
|
|
ansible.builtin.cron:
|
2020-08-18 11:57:53 +02:00
|
|
|
name: restic
|
|
|
|
state: present
|
|
|
|
job: "/usr/local/bin/restic_backup.sh"
|
|
|
|
minute: "{{ 59|random(seed=inventory_hostname) }}"
|
|
|
|
hour: "{{ restic_cron_hours }}"
|
|
|
|
# siehe: https://stackoverflow.com/questions/33379378/idempotence-and-random-variables-in-ansible
|
|
|
|
|
|
|
|
- name: Create restic log
|
|
|
|
become: true
|
2020-11-21 19:41:19 +01:00
|
|
|
ansible.builtin.file:
|
2020-08-18 11:57:53 +02:00
|
|
|
path: /var/log/restic.log
|
|
|
|
state: touch
|
|
|
|
owner: root
|
|
|
|
group: root
|
2021-05-02 14:20:16 +02:00
|
|
|
mode: 0640
|
2020-08-18 11:57:53 +02:00
|
|
|
access_time: preserve
|
|
|
|
modification_time: preserve
|
|
|
|
|
2021-03-13 22:11:57 +01:00
|
|
|
- name: copy logrotate config
|
|
|
|
become: yes
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: logrotate_restic
|
|
|
|
dest: /etc/logrotate.d/restic
|
2020-08-18 11:57:53 +02:00
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|