73 lines
1.8 KiB
YAML
73 lines
1.8 KiB
YAML
---
|
|
- 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:
|
|
url: "\
|
|
https://github.com/restic/restic/releases/download/v0.14.0/restic_0.14.0_linux_amd64.bz2"
|
|
dest: "/usr/local/bin/restic.bz2"
|
|
mode: 0644
|
|
|
|
- name: "install bzip2"
|
|
ansible.builtin.apt:
|
|
name: "bzip2"
|
|
|
|
- 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 restic-batch dependencies"
|
|
ansible.builtin.apt:
|
|
name: "python3-yaml"
|
|
|
|
- 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
|