ansible-edda/playbooks/roles/backups/restic/setup/tasks/main.yml

65 lines
1.7 KiB
YAML
Raw Normal View History

2022-12-18 23:43:40 +01:00
---
2022-12-18 17:06:27 +01:00
- name: "check if restic is installed"
ansible.builtin.stat:
path: "/usr/local/bin/restic"
register: backups_restic_binary_path
- block:
- name: "download restic binary"
ansible.builtin.get_url:
2022-12-18 23:43:40 +01:00
url: "\
https://github.com/restic/restic/releases/download/v0.14.0/restic_0.14.0_linux_amd64.bz2"
2022-12-18 17:06:27 +01:00
dest: "/usr/local/bin/restic.bz2"
mode: 0644
- name: "unpack restic binary"
command: "bunzip2 /usr/local/bin/restic.bz2"
when:
not backups_restic_binary_path.stat.exists
- name: "ensure restic is executable"
ansible.builtin.file:
path: "/usr/local/bin/restic"
mode: 0755
- name: "create a cache directory for restic"
ansible.builtin.file:
path: "/var/cache/restic"
state: "directory"
mode: 0755
- name: "create resic-batch config directory"
ansible.builtin.file:
path: "/etc/restic-batch.d"
state: "directory"
mode: 0755
- name: "install the restic-batch script"
ansible.builtin.copy:
src: "./restic-batch"
dest: "/usr/local/sbin/restic-batch"
mode: 0755
- name: "install the restic-batch service"
ansible.builtin.copy:
src: "./restic-batch.service"
dest: "/etc/systemd/system/restic-batch.service"
mode: 0644
register: backups_restic_restic_batch_service_file
- name: "install the restic-batch timer"
ansible.builtin.copy:
src: "./restic-batch.timer"
dest: "/etc/systemd/system/restic-batch.timer"
mode: 0644
register: backups_restic_restic_batch_timer_file
- name: "systemd daemon reload"
ansible.builtin.systemd:
daemon_reload: true
when:
backups_restic_restic_batch_service_file.changed or
backups_restic_restic_batch_timer_file.changed