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"
|
2020-06-30 06:22:27 -05:00
|
|
|
- name: Template out services
|
|
|
|
template:
|
|
|
|
src: "{{ item.src }}"
|
|
|
|
dest: "{{ item.dest }}"
|
|
|
|
mode: "{{ item.mode }}"
|
|
|
|
loop:
|
|
|
|
- { src: "9iron-backup.service", dest: "/etc/systemd/system/9iron-backup.service", mode: "0644" }
|
|
|
|
- { src: "9iron-backup.timer", dest: "/etc/systemd/system/9iron-backup.timer", mode: "0644" }
|
|
|
|
notify: restart backups timer
|
|
|
|
- name: Enable timer
|
|
|
|
systemd:
|
|
|
|
daemon_reload: yes
|
|
|
|
name: 9iron-backup.timer
|
|
|
|
enabled: yes
|
|
|
|
state: started
|
|
|
|
notify: restart backups timer
|
|
|
|
- name: Remove legacy cronjob
|
2020-05-03 03:06:16 -05:00
|
|
|
cron:
|
2020-06-30 06:22:27 -05:00
|
|
|
state: absent
|
2020-05-03 03:06:16 -05:00
|
|
|
name: ansible-backup
|
|
|
|
become: yes
|