Slight tweaks
This commit is contained in:
51
playbooks/rear_backup_validate.yml
Normal file
51
playbooks/rear_backup_validate.yml
Normal file
@ -0,0 +1,51 @@
|
||||
---
|
||||
- name: Perform a ReaR backup
|
||||
hosts: all
|
||||
become: true
|
||||
gather_facts: true
|
||||
strategy: free
|
||||
|
||||
vars:
|
||||
rear_backup_success_path: "/var/log/IPE/IPU"
|
||||
rear_backup_success_file: "{{ rear_backup_success_path }}/bigboot_success"
|
||||
|
||||
tasks:
|
||||
- name: Check for backup log presence
|
||||
ansible.builtin.stat:
|
||||
path: "/var/log/rear/rear-{{ ansible_hostname }}.log"
|
||||
register: rear_backup_log_presence
|
||||
|
||||
- name: ReaR Backup Validation
|
||||
when:
|
||||
- rear_backup_log_presence['stat']['exists'] | bool
|
||||
block:
|
||||
- name: Validate ReaR backup completion
|
||||
ansible.builtin.command:
|
||||
cmd: "grep 'Finished running mkbackup workflow' /var/log/rear/rear-{{ ansible_hostname }}.log"
|
||||
changed_when: false
|
||||
register: validate_backup_log
|
||||
|
||||
- name: Debug validate_backup_log
|
||||
ansible.builtin.debug:
|
||||
var: validate_backup_log
|
||||
verbosity: 1
|
||||
|
||||
- name: Create log file directory if not present
|
||||
ansible.builtin.file:
|
||||
path: "{{ rear_backup_success_path }}"
|
||||
state: directory
|
||||
mode: "0755"
|
||||
|
||||
- name: Create Bigboot backup success file
|
||||
ansible.builtin.copy:
|
||||
dest: "{{ rear_backup_success_file }}"
|
||||
content: "success"
|
||||
mode: "0644"
|
||||
rescue:
|
||||
- name: No backup log found
|
||||
ansible.builtin.debug:
|
||||
msg: "ReaR backup log could not be found to verify backup status. Please run the backup and try again."
|
||||
|
||||
- name: OS Failure
|
||||
ansible.builtin.debug:
|
||||
msg: "OS failure: Expecting version {{ ansible_distribution_major_version }}, got {{ ansible_distribution_major_version | int + 1 }}"
|
Reference in New Issue
Block a user