Compare commits
1 Commits
99a8c19aa3
...
0aba4024de
Author | SHA1 | Date | |
---|---|---|---|
0aba4024de |
@ -20,8 +20,8 @@ restic_policy_backup_frequency: hourly
|
|||||||
|
|
||||||
restic_base_environment:
|
restic_base_environment:
|
||||||
RESTIC_REPOSITORY: "{{ restic_repo_url }}"
|
RESTIC_REPOSITORY: "{{ restic_repo_url }}"
|
||||||
RESTIC_PASSWORD: "{{ restic_password }}"
|
RESTIC_PASSWORD: "{{ restic_repo_password }}"
|
||||||
RESTIC_JOBNAME: "{{ restic_job_name | default('unknown') }}"
|
RESTIC_JOBNAME: "{{ restic_job_name }}"
|
||||||
RESTIC_FORGET_KEEP_WITHIN: "{{ restic_policy_keep_all_within }}"
|
RESTIC_FORGET_KEEP_WITHIN: "{{ restic_policy_keep_all_within }}"
|
||||||
RESTIC_FORGET_KEEP_HOURLY: "{{ restic_policy_keep_hourly }}"
|
RESTIC_FORGET_KEEP_HOURLY: "{{ restic_policy_keep_hourly }}"
|
||||||
RESTIC_FORGET_KEEP_DAILY: "{{ restic_policy_keep_daily }}"
|
RESTIC_FORGET_KEEP_DAILY: "{{ restic_policy_keep_daily }}"
|
||||||
|
@ -13,3 +13,4 @@ restic_job_directory: "/etc/restic"
|
|||||||
|
|
||||||
restic_package_name: restic
|
restic_package_name: restic
|
||||||
restic_script_generate_snapshot_metrics: "/opt/restic-generate-snapshot-metrics.sh"
|
restic_script_generate_snapshot_metrics: "/opt/restic-generate-snapshot-metrics.sh"
|
||||||
|
restic_start_job_on_unit_change: true
|
||||||
|
@ -1,7 +1,16 @@
|
|||||||
---
|
---
|
||||||
restic_systemd_job_name: ~
|
restic_systemd_job_description: "Restic backup service"
|
||||||
restic_systemd_job_description: "Restic backup job for {{ restic_job_name }}"
|
restic_systemd_unit_naming_scheme: "restic-{{ restic_job_name }}"
|
||||||
|
restic_systemd_timer_naming_scheme: >-2
|
||||||
|
{{ restic_systemd_unit_naming_scheme }}.timer
|
||||||
|
restic_systemd_timer_state_map:
|
||||||
|
present: "started"
|
||||||
|
absent: "stopped"
|
||||||
|
masked: "started"
|
||||||
|
restic_systemd_timer_state: >-2
|
||||||
|
{{ restic_systemd_timer_state_map[restic_job_state] }}
|
||||||
|
|
||||||
|
restic_systemd_syslog_identifier: "restic@%i"
|
||||||
restic_systemd_working_directory: /tmp
|
restic_systemd_working_directory: /tmp
|
||||||
restic_systemd_install_wanted_by: "basic.target"
|
restic_systemd_install_wanted_by: "basic.target"
|
||||||
restic_systemd_install_default_instance: "default"
|
restic_systemd_install_default_instance: "default"
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
- name: Ensure system daemon is reloaded
|
- name: Ensure system daemon is reloaded
|
||||||
listen: reload-systemd
|
listen: reload-systemd
|
||||||
systemd:
|
ansible.builtin.systemd:
|
||||||
daemon_reload: true
|
daemon_reload: true
|
||||||
|
|
||||||
- name: Ensure systemd service for '{{ restic_job_name }}' is started immediately
|
- name: Ensure systemd service for '{{ restic_job_name }}' is started immediately
|
||||||
listen: trigger-restic
|
listen: trigger-restic
|
||||||
systemd:
|
ansible.builtin.systemd:
|
||||||
name: "{{ restic_systemd_unit_naming_scheme }}.service"
|
name: "{{ restic_systemd_timer_naming_scheme }}"
|
||||||
state: started
|
state: started
|
||||||
when: restic_start_job_on_unit_change
|
when: (not ansible_check_mode) and restic_start_job_on_unit_change
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
---
|
---
|
||||||
- name: Ensure systemd timer file for '{{ restic_job_name }}' is {{ restic_state }}'
|
- name: Ensure systemd timer file for '{{ restic_job_name }}' is {{ restic_state }}'
|
||||||
template:
|
ansible.builtin.template:
|
||||||
dest: "/etc/systemd/system/{{ restic_systemd_unit_naming_scheme }}.timer"
|
dest: "/etc/systemd/system/{{ restic_systemd_unit_naming_scheme }}.timer"
|
||||||
src: restic.timer.j2
|
src: restic.timer.j2
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: "0640"
|
mode: "0640"
|
||||||
when: restic_state == 'present'
|
when: restic_state == 'present'
|
||||||
|
register: restic_systemd_timer_info
|
||||||
notify:
|
notify:
|
||||||
- reload-systemd
|
- reload-systemd
|
||||||
|
|
||||||
@ -27,5 +28,3 @@
|
|||||||
|
|
||||||
- name: Flush handlers to ensure systemd knows about '{{ restic_job_name }}'
|
- name: Flush handlers to ensure systemd knows about '{{ restic_job_name }}'
|
||||||
meta: flush_handlers
|
meta: flush_handlers
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,10 +21,19 @@
|
|||||||
|
|
||||||
- name: Ensure systemd timer for '{{ restic_job_name }}' is activated
|
- name: Ensure systemd timer for '{{ restic_job_name }}' is activated
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
name: "{{ restic_systemd_unit_naming_scheme }}.timer"
|
name: "{{ restic_systemd_timer_naming_scheme }}"
|
||||||
enabled: true
|
enabled: true
|
||||||
|
when:
|
||||||
|
- restic_systemd_timer_info.changed
|
||||||
|
- not restic_systemd_timer_info.failed
|
||||||
|
- not ansible_check_mode
|
||||||
|
|
||||||
- name: Ensure systemd timer for '{{ restic_job_name }}' is {{ restic_job_state }}
|
- name: Ensure systemd timer for '{{ restic_job_name }}' is {{ restic_job_state }}
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
name: "{{ restic_systemd_unit_naming_scheme }}.timer"
|
name: "{{ restic_systemd_timer_naming_scheme }}"
|
||||||
state: started # TODO: mask a timer?
|
state: "{{ restic_job_state }}"
|
||||||
|
masked: "{{ (restic_job_state == 'masked') | ternary('true', omit) }}"
|
||||||
|
when:
|
||||||
|
- restic_systemd_timer_info.changed
|
||||||
|
- not restic_systemd_timer_info.failed
|
||||||
|
- not ansible_check_mode
|
||||||
|
Loading…
x
Reference in New Issue
Block a user