mg
ffd264e3ec
Co-authored-by: Michael Grote <michael.grote@posteo.de> Reviewed-on: mg/ansible#260 Co-authored-by: mg <michael.grote@posteo.de> Co-committed-by: mg <michael.grote@posteo.de>
66 lines
1.8 KiB
YAML
66 lines
1.8 KiB
YAML
---
|
|
- name: copy smb_password.txt
|
|
become: yes
|
|
ansible.builtin.template:
|
|
src: "smb_password.txt"
|
|
dest: "/etc/restic/smb_password.txt"
|
|
owner: "{{ restic_user }}"
|
|
group: "{{ restic_user_group }}"
|
|
mode: 0600
|
|
|
|
- name: copy restic_backup.sh
|
|
become: yes
|
|
ansible.builtin.template:
|
|
src: "restic_backup.sh"
|
|
dest: "/usr/local/bin/restic_backup.sh"
|
|
mode: 0744
|
|
owner: "{{ restic_user }}"
|
|
group: "{{ restic_user_group }}"
|
|
|
|
- name: create exclude.txt
|
|
become: yes
|
|
ansible.builtin.blockinfile:
|
|
path: "/etc/restic/exclude.txt"
|
|
create: yes
|
|
block: "{{ restic_exclude }}"
|
|
mode: 0644
|
|
|
|
- name: copy password.txt
|
|
become: yes
|
|
ansible.builtin.template:
|
|
src: "password.txt"
|
|
dest: "/etc/restic/password.txt"
|
|
owner: "{{ restic_user }}"
|
|
group: "{{ restic_user_group }}"
|
|
mode: 0600
|
|
|
|
- name: create restic cronjob
|
|
become: yes
|
|
ansible.builtin.cron:
|
|
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
|
|
user: "{{ restic_user }}"
|
|
|
|
- name: Create restic log
|
|
become: true
|
|
ansible.builtin.file:
|
|
path: /var/log/restic.log
|
|
state: touch
|
|
owner: "{{ restic_user }}"
|
|
group: "{{ restic_user_group }}"
|
|
mode: 0644
|
|
access_time: preserve
|
|
modification_time: preserve
|
|
|
|
- name: copy logrotate config
|
|
become: yes
|
|
ansible.builtin.template:
|
|
src: logrotate_restic
|
|
dest: /etc/logrotate.d/restic
|
|
owner: "{{ restic_user }}"
|
|
group: "{{ restic_user_group }}"
|
|
mode: 0644
|