2020-05-03 03:06:16 -05:00
|
|
|
#!/usr/bin/ansible-playbook
|
|
|
|
# vim:ft=ansible:
|
|
|
|
---
|
|
|
|
- name: Set up general backups
|
|
|
|
block:
|
|
|
|
- name: Create backups directories
|
|
|
|
file:
|
|
|
|
state: directory
|
|
|
|
mode: "0700"
|
|
|
|
path: "{{ item }}"
|
|
|
|
loop:
|
2020-05-03 05:48:01 -05:00
|
|
|
- "/opt/backups"
|
|
|
|
- "/opt/backups/modules"
|
2020-05-06 02:10:26 -05:00
|
|
|
- "{{ backups_outdir }}"
|
|
|
|
- name: Create /backups symlink
|
|
|
|
file:
|
|
|
|
state: link
|
|
|
|
path: "/backups"
|
|
|
|
src: "{{ backups_outdir }}"
|
2020-05-03 03:06:16 -05:00
|
|
|
- name: Template out backup script
|
|
|
|
template:
|
|
|
|
src: "backup.sh"
|
2020-05-03 05:48:01 -05:00
|
|
|
dest: "/opt/backups/backup.sh"
|
2020-05-03 03:06:16 -05:00
|
|
|
mode: "0700"
|
|
|
|
- name: Set backup cronjob
|
|
|
|
cron:
|
|
|
|
minute: "0"
|
|
|
|
hour: "2"
|
|
|
|
name: ansible-backup
|
2020-05-03 05:48:01 -05:00
|
|
|
job: "/opt/backups/backup.sh >> /backups/backups.log 2>&1"
|
2020-05-03 03:06:16 -05:00
|
|
|
become: yes
|