67 lines
1.9 KiB
YAML
67 lines
1.9 KiB
YAML
---
|
|
- name: Check if role input is valid
|
|
ansible.builtin.include_tasks:
|
|
file: check.yml
|
|
|
|
- name: Ensure restic is {{ restic_state }}
|
|
ansible.builtin.include_tasks:
|
|
file: install.yml
|
|
|
|
- name: Ensure restic user '{{ restic_user }}' is {{ restic_state }}
|
|
ansible.builtin.user:
|
|
name: "{{ restic_user }}"
|
|
state: "{{ restic_state }}"
|
|
system: "{{ restic_user_system }}"
|
|
create_home: "{{ restic_user_create_home }}"
|
|
when: restic_create_user
|
|
|
|
- name: Ensure restic backup scripts are {{ restic_state }}
|
|
ansible.builtin.copy:
|
|
src: "{{ script.source }}"
|
|
dest: "{{ script.destination }}"
|
|
mode: "{{ script.mode }}"
|
|
loop:
|
|
- source: restic-backup.sh
|
|
destination: "{{ restic_systemd_service_exec_start }}"
|
|
mode: "0510"
|
|
- source: restic-snapshot-metrics.sh
|
|
destination: "{{ restic_script_generate_snapshot_metrics }}"
|
|
mode: "0510"
|
|
loop_control:
|
|
loop_var: script
|
|
label: "{{ script.source }}"
|
|
|
|
- name: Ensure systemd service file for '{{ restic_job_name }}' is templated
|
|
template:
|
|
dest: "/etc/systemd/system/{{ restic_systemd_unit_naming_scheme }}.service"
|
|
src: restic.service.j2
|
|
owner: root
|
|
group: root
|
|
mode: 0640
|
|
notify:
|
|
- reload-systemd
|
|
- trigger-restic
|
|
|
|
- name: Ensure systemd service file for '{{ restic_job_name }}' is templated
|
|
template:
|
|
dest: "/etc/systemd/system/{{ restic_systemd_unit_naming_scheme }}.timer"
|
|
src: restic.timer.j2
|
|
owner: root
|
|
group: root
|
|
mode: 0640
|
|
notify:
|
|
- reload-systemd
|
|
|
|
- name: Flush handlers to ensure systemd knows about '{{ restic_job_name }}'
|
|
meta: flush_handlers
|
|
|
|
- name: Ensure systemd timer for '{{ restic_job_name }}' is activated
|
|
systemd:
|
|
name: "{{ restic_systemd_unit_naming_scheme }}.timer"
|
|
enabled: true
|
|
|
|
- name: Ensure systemd timer for '{{ restic_job_name }}' is started
|
|
systemd:
|
|
name: "{{ restic_systemd_unit_naming_scheme }}.timer"
|
|
state: started
|