36 lines
1.7 KiB
YAML

#!/usr/bin/env ansible-playbook
# vim:ft=ansible:
---
# 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"
- 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"
tags: [ packages ]
# The script
- name: template out backup script
ansible.builtin.template: src={{ backup_script }}.sh dest=/opt/backup.sh mode=0700 owner=root group=root
# 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?
- name: template out analyze script
ansible.builtin.template: src={{ backup_script }}-analyze.sh dest=/opt/analyze.sh mode=0700 owner=root group=root
# This restore script doesn't even work???
- name: template out restore script
ansible.builtin.template: src={{ restore_script }}.sh dest=/opt/restore.sh mode=0700 owner=root group=root
# And service/timer definitions
- name: configure systemd service
ansible.builtin.template: src=backup.service dest=/etc/systemd/system/backup.service mode=0644
- name: configure systemd timer
ansible.builtin.template: src=backup.timer dest=/etc/systemd/system/backup.timer mode=0644
notify: restart backup timer
- name: enable timer
ansible.builtin.systemd: name=backup.timer state=started enabled=yes daemon_reload=yes