Modularity updates

This commit is contained in:
2025-03-04 14:54:39 -05:00
parent ee6912995c
commit e42fb554a6
7 changed files with 62 additions and 38 deletions

View File

@ -0,0 +1,22 @@
---
- name: Confirm ReaR backup log is present
ansible.builtin.stat:
path: "/var/log/rear/rear-{{ ansible_hostname }}.log"
register: rear_backup_log_stat
- name: Backup ReaR log file and create success file
when:
- rear_backup_log_stat['stat']['exists']
block:
- name: Copy ReaR log file to backup location
ansible.builtin.copy:
src: "/var/log/rear/rear-{{ ansible_hostname }}.log"
dest: "/var/log/rear-{{ ansible_hostname }}-{{ '%Y-%m-%d' | strftime(rear_backup_log_stat['stat']['mtime']) }}.log"
mode: "0644"
backup: true
remote_src: true
- name: Remove ReaR log file
ansible.builtin.file:
path: "/var/log/rear/rear-{{ ansible_hostname }}.log"
state: absent

View File

@ -0,0 +1,12 @@
---
- name: Create success file directory if not present
ansible.builtin.file:
path: "{{ rear_backup_success_file_path }}"
state: directory
mode: "0755"
- name: Create backup success file
ansible.builtin.copy:
dest: "{{ rear_backup_success_file_path }}/{{ rear_backup_workflow }}_rear_success"
content: "success\n"
mode: "0644"

View File

@ -33,6 +33,14 @@
state: present
notify: Update Grub
- name: Archive backup log
ansible.builtin.include_tasks:
file: archive_backup_log.yml
- name: Write backup success file
ansible.builtin.include_tasks:
file: create_success_file.yml
- name: ReaR backup success
ansible.builtin.debug:
msg: "ReaR backup has completed successfully."