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
|
|
|
|
|
2023-02-12 19:37:33 +01:00
|
|
|
- name: "install bzip2"
|
|
|
|
ansible.builtin.apt:
|
|
|
|
name: "bzip2"
|
|
|
|
|
2022-12-18 17:06:27 +01:00
|
|
|
- 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:
|
2023-07-23 00:37:19 +02:00
|
|
|
path: "{{ system_etc_root_directory }}/restic-batch.d"
|
2022-12-18 17:06:27 +01:00
|
|
|
state: "directory"
|
|
|
|
mode: 0755
|
|
|
|
|
2023-02-13 00:12:30 +01:00
|
|
|
- name: "install restic-batch dependencies"
|
|
|
|
ansible.builtin.apt:
|
|
|
|
name: "python3-yaml"
|
|
|
|
|
2022-12-18 17:06:27 +01:00
|
|
|
- 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"
|
2023-07-23 00:37:19 +02:00
|
|
|
ansible.builtin.template:
|
2022-12-18 17:06:27 +01:00
|
|
|
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
|