|
| 1 | +--- |
| 2 | +- name: Verify |
| 3 | + hosts: all |
| 4 | + become: true |
| 5 | + tasks: |
| 6 | + |
| 7 | + - name: VERIFY | Service unit exists |
| 8 | + ansible.builtin.stat: |
| 9 | + path: /etc/systemd/system/restic-backup.service |
| 10 | + register: service_unit |
| 11 | + |
| 12 | + - name: VERIFY | Timer unit exists |
| 13 | + ansible.builtin.stat: |
| 14 | + path: /etc/systemd/system/restic-backup.timer |
| 15 | + register: timer_unit |
| 16 | + |
| 17 | + - name: VERIFY | Assert units are deployed |
| 18 | + ansible.builtin.assert: |
| 19 | + that: |
| 20 | + - service_unit.stat.exists |
| 21 | + - timer_unit.stat.exists |
| 22 | + fail_msg: "Service or timer unit not deployed" |
| 23 | + |
| 24 | + - name: VERIFY | Drop-in directory exists |
| 25 | + ansible.builtin.stat: |
| 26 | + path: /etc/systemd/system/restic-backup.service.d |
| 27 | + register: dropin_dir |
| 28 | + |
| 29 | + - name: VERIFY | Assert drop-in directory present |
| 30 | + ansible.builtin.assert: |
| 31 | + that: |
| 32 | + - dropin_dir.stat.exists |
| 33 | + - dropin_dir.stat.isdir |
| 34 | + fail_msg: "Drop-in directory not created" |
| 35 | + |
| 36 | + - name: VERIFY | Root override drop-in exists |
| 37 | + ansible.builtin.stat: |
| 38 | + path: /etc/systemd/system/restic-backup.service.d/10-user-root.conf |
| 39 | + register: root_dropin |
| 40 | + |
| 41 | + - name: VERIFY | Assert root drop-in present |
| 42 | + ansible.builtin.assert: |
| 43 | + that: |
| 44 | + - root_dropin.stat.exists |
| 45 | + fail_msg: "Root user drop-in not created" |
| 46 | + |
| 47 | + - name: VERIFY | Timer is enabled |
| 48 | + ansible.builtin.command: systemctl is-enabled restic-backup.timer |
| 49 | + register: timer_enabled |
| 50 | + changed_when: false |
| 51 | + failed_when: timer_enabled.rc != 0 |
| 52 | + |
| 53 | + - name: VERIFY | Service unit contains correct repo path |
| 54 | + ansible.builtin.command: grep "RESTIC_REPOSITORY={{ restic_repo_path }}" /etc/systemd/system/restic-backup.service |
| 55 | + register: repo_check |
| 56 | + changed_when: false |
| 57 | + failed_when: repo_check.rc != 0 |
| 58 | + |
| 59 | + - name: VERIFY | Report |
| 60 | + ansible.builtin.debug: |
| 61 | + msg: "restic_backup role verified: service, timer, and drop-ins deployed correctly" |
0 commit comments