More validation tasks
All checks were successful
Ansible Lint Pipeline / Ansible-Development-Pipeline (ansible-dev-centos) (push) Successful in 48s
All checks were successful
Ansible Lint Pipeline / Ansible-Development-Pipeline (ansible-dev-centos) (push) Successful in 48s
This commit is contained in:
@ -10,6 +10,6 @@
|
||||
ansible.builtin.import_role:
|
||||
name: rhc.rear.rear_vars
|
||||
|
||||
- name: Validiate ReaR backup completion
|
||||
- name: Validiate ReaR Backup Completion
|
||||
ansible.builtin.include_role:
|
||||
name: rhc.rear.rear_backup_validation
|
||||
|
@ -1,11 +1,40 @@
|
||||
---
|
||||
- name: Validate ReaR backup completion
|
||||
ansible.builtin.command:
|
||||
cmd: "grep 'Finished running mkbackup workflow' /var/log/rear/rear-{{ ansible_hostname }}.log"
|
||||
register: rear_backup_validate
|
||||
failed_when: rear_backup_validate['rc'] not in [0]
|
||||
- name: Check if ReaR backup log exists
|
||||
ansible.builtin.stat:
|
||||
path: "/var/log/rear/rear-{{ ansible_hostname }}.log"
|
||||
register: rear_backup_log_presence
|
||||
|
||||
- name: Debug rear_backup_validate
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ rear_backup_validate }}"
|
||||
- name: Validate backup completion and other stuff
|
||||
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"
|
||||
register: rear_backup_validate
|
||||
failed_when: rear_backup_validate['rc'] not in [0]
|
||||
|
||||
- name: Debug rear_backup_validate
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ rear_backup_validate }}"
|
||||
|
||||
- name: Set current time and capture ReaR backup timestamp
|
||||
ansible.builtin.set_fact:
|
||||
rear_backup_date_now: "{{ ansible_date_time['date'] }}"
|
||||
# rear_backup_timestamp: "{{ rear_backup_validate['stdout'] | split(' ') | first }}"
|
||||
rear_backup_timestamp: '2025-09-24'
|
||||
|
||||
- name: Capture number of days since last backup
|
||||
ansible.builtin.set_fact:
|
||||
rear_backup_age: "{{ ((rear_backup_date_now | to_datetime('%Y-%m-%d')) - (rear_backup_timestamp | to_datetime('%Y-%m-%d'))).days }}"
|
||||
|
||||
- name: Debug rear_backup_age
|
||||
ansible.builtin.debug:
|
||||
msg: "Number of days since last backup success: {{ rear_backup_age }}."
|
||||
|
||||
- name: Fail if backup older than desired
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- rear_backup_age | int <= 6
|
||||
success_msg: "Backup is new enough."
|
||||
fail_msg: "Backup is too old like your stinky grandma!"
|
||||
|
Reference in New Issue
Block a user