Compare commits
	
		
			1 Commits
		
	
	
		
			a3f740d74e
			...
			cc8e06f7d5
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						
						
							
						
						cc8e06f7d5
	
				 | 
					
					
						
@@ -8,7 +8,6 @@ restic_user_system: false
 | 
			
		||||
restic_state: present
 | 
			
		||||
restic_version: "0.17.3"
 | 
			
		||||
restic_job_name: default
 | 
			
		||||
restic_job_state: "{{ restic_state }}"
 | 
			
		||||
restic_job_directory: "/etc/restic"
 | 
			
		||||
 | 
			
		||||
restic_package_name: restic
 | 
			
		||||
 
 | 
			
		||||
@@ -1,31 +0,0 @@
 | 
			
		||||
---
 | 
			
		||||
- name: Ensure systemd timer file for '{{ restic_job_name }}' is {{ restic_state }}'
 | 
			
		||||
  template:
 | 
			
		||||
    dest: "/etc/systemd/system/{{ restic_systemd_unit_naming_scheme }}.timer"
 | 
			
		||||
    src: restic.timer.j2
 | 
			
		||||
    owner: root
 | 
			
		||||
    group: root
 | 
			
		||||
    mode: "0640"
 | 
			
		||||
  when: restic_state == 'present'
 | 
			
		||||
  notify:
 | 
			
		||||
    - reload-systemd
 | 
			
		||||
 | 
			
		||||
- name: Ensure restic configuration for '{{ restic_job_name }}' is {{ restic_job_state }}
 | 
			
		||||
  ansible.builtin.template:
 | 
			
		||||
    src: "restic.conf.j2"
 | 
			
		||||
    dest: "{{ restic_job_directory }}/{{ restic_job_name }}.conf"
 | 
			
		||||
    mode: "0640"
 | 
			
		||||
  when: restic_job_state in ['present', 'masked']
 | 
			
		||||
  notify:
 | 
			
		||||
    - trigger-restic
 | 
			
		||||
 | 
			
		||||
- name: Ensure restic configuration for '{{ restic_job_name }}' is {{ restic_job_state }}
 | 
			
		||||
  ansible.builtin.file:
 | 
			
		||||
    path: "{{ restic_job_directory }}/{{ restic_job_name }}.conf"
 | 
			
		||||
    state: "{{ restic_job_state }}"
 | 
			
		||||
  when: restic_job_state not in ['present', 'masked']
 | 
			
		||||
 | 
			
		||||
- name: Flush handlers to ensure systemd knows about '{{ restic_job_name }}'
 | 
			
		||||
  meta: flush_handlers
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -17,32 +17,4 @@
 | 
			
		||||
        state: present
 | 
			
		||||
      when: ansible_os_family not in ['RedHat', 'Debian']
 | 
			
		||||
 | 
			
		||||
- 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 template unit is {{ restic_state }}
 | 
			
		||||
  ansible.builtin.template:
 | 
			
		||||
    dest: "/etc/systemd/system/restic@.service"
 | 
			
		||||
    src: "restic@.service.j2"
 | 
			
		||||
    owner: root
 | 
			
		||||
    group: root
 | 
			
		||||
    mode: "0640"
 | 
			
		||||
  when: restic_state == 'present'
 | 
			
		||||
  notify:
 | 
			
		||||
    - reload-systemd
 | 
			
		||||
    - trigger-restic
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -15,16 +15,52 @@
 | 
			
		||||
    create_home: "{{ restic_user_create_home }}"
 | 
			
		||||
  when: restic_create_user
 | 
			
		||||
 | 
			
		||||
- name: Ensure restic configuration for job is {{ restic_job_state }}
 | 
			
		||||
  ansible.builtin.include_tasks:
 | 
			
		||||
    file: "configure.yml"
 | 
			
		||||
- 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
 | 
			
		||||
  ansible.builtin.systemd:
 | 
			
		||||
  systemd:
 | 
			
		||||
    name: "{{ restic_systemd_unit_naming_scheme }}.timer"
 | 
			
		||||
    enabled: true
 | 
			
		||||
 | 
			
		||||
- name: Ensure systemd timer for '{{ restic_job_name }}' is {{ restic_job_state }}
 | 
			
		||||
  ansible.builtin.systemd:
 | 
			
		||||
- name: Ensure systemd timer for '{{ restic_job_name }}' is started
 | 
			
		||||
  systemd:
 | 
			
		||||
    name: "{{ restic_systemd_unit_naming_scheme }}.timer"
 | 
			
		||||
    state: started # TODO: mask a timer?
 | 
			
		||||
    state: started
 | 
			
		||||
 
 | 
			
		||||
@@ -2,8 +2,3 @@
 | 
			
		||||
restic_states:
 | 
			
		||||
  - "present"
 | 
			
		||||
  - "absent"
 | 
			
		||||
 | 
			
		||||
restic_job_states:
 | 
			
		||||
  - "present"
 | 
			
		||||
  - "masked"
 | 
			
		||||
  - "absent"
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user