2020-12-24 09:06:20 -06:00
|
|
|
#!/usr/bin/env ansible-playbook
|
|
|
|
# vim:ft=ansible:
|
|
|
|
---
|
2025-01-19 12:43:10 -06:00
|
|
|
# Install restic if we can
|
|
|
|
- name: install restic
|
|
|
|
block:
|
|
|
|
- name: install restic through apt
|
|
|
|
ansible.builtin.apt: name=restic state=present
|
|
|
|
when: ansible_pkg_mgr == "apt"
|
2025-01-19 12:54:00 -06:00
|
|
|
- name: install restic through rpm-ostree
|
|
|
|
community.general.rpm_ostree_pkg: name=restic state=present
|
|
|
|
when: ansible_os_family == "RedHat" and ansible_pkg_mgr == "atomic_container"
|
2025-01-19 12:43:10 -06:00
|
|
|
# The script
|
2020-12-24 09:06:20 -06:00
|
|
|
- name: template out backup script
|
2022-06-16 23:45:29 -05:00
|
|
|
ansible.builtin.template: src={{ backup_script }}.sh dest=/opt/backup.sh mode=0700 owner=root group=root
|
2025-01-19 12:43:10 -06:00
|
|
|
# Some restic-specific stuff
|
|
|
|
- name: template out restic password file
|
|
|
|
ansible.builtin.template: src={{ backup_script }}-password dest=/opt/restic-password mode=0700 owner=root group=root
|
|
|
|
- name: template out restic wrapper
|
|
|
|
ansible.builtin.template: src=restic-wrapper.sh dest=/opt/restic-wrapper mode=0700 owner=root group=root
|
|
|
|
# An analyzer for... reasons?
|
2023-11-11 09:24:48 -06:00
|
|
|
- name: template out analyze script
|
|
|
|
ansible.builtin.template: src={{ backup_script }}-analyze.sh dest=/opt/analyze.sh mode=0700 owner=root group=root
|
2025-01-19 12:43:10 -06:00
|
|
|
# This restore script doesn't even work???
|
2022-05-23 01:48:13 -05:00
|
|
|
- name: template out restore script
|
2022-06-16 23:45:29 -05:00
|
|
|
ansible.builtin.template: src={{ restore_script }}.sh dest=/opt/restore.sh mode=0700 owner=root group=root
|
2025-01-19 12:43:10 -06:00
|
|
|
# And service/timer definitions
|
2021-01-16 23:23:07 -06:00
|
|
|
- name: configure systemd service
|
2022-06-16 23:45:29 -05:00
|
|
|
ansible.builtin.template: src=backup.service dest=/etc/systemd/system/backup.service mode=0644
|
2021-01-16 23:23:07 -06:00
|
|
|
- name: configure systemd timer
|
2022-06-16 23:45:29 -05:00
|
|
|
ansible.builtin.template: src=backup.timer dest=/etc/systemd/system/backup.timer mode=0644
|
2020-12-24 09:06:20 -06:00
|
|
|
notify: restart backup timer
|
2021-01-16 23:23:07 -06:00
|
|
|
- name: enable timer
|
2022-06-16 23:45:29 -05:00
|
|
|
ansible.builtin.systemd: name=backup.timer state=started enabled=yes daemon_reload=yes
|