This commit is contained in:
Chris Hammer 2025-03-06 00:01:17 -05:00
parent 26638d9728
commit 25e7b03bef
9 changed files with 18 additions and 105 deletions

View File

@ -9,5 +9,4 @@
ansible.builtin.set_stats: ansible.builtin.set_stats:
data: data:
ip_addresses: "{{ ansible_all_ipv4_addresses }}" ip_addresses: "{{ ansible_all_ipv4_addresses }}"
server_hostname: "{{ ansible_hostname }}"
aggregate: true aggregate: true

View File

@ -27,7 +27,7 @@
gather_facts: true gather_facts: true
tasks: tasks:
- name: Grab the template name - name: Capture the job template name
ansible.builtin.set_stats: ansible.builtin.set_stats:
aggregate: false aggregate: false
per_host: false per_host: false
@ -37,10 +37,9 @@
- name: Create IP list and add to NFS exports - name: Create IP list and add to NFS exports
when: not rear_backup_skip | default(false) | bool when: not rear_backup_skip | default(false) | bool
block: block:
- name: Create list with IP addresses and hostnames - name: Create list with IP addresses
ansible.builtin.set_fact: ansible.builtin.set_fact:
client_ips: "{{ ip_addresses | list | flatten }}" client_ips: "{{ ip_addresses | list | flatten }}"
namehost: "{{ server_hostname }}"
- name: Import rear_vars role - name: Import rear_vars role
ansible.builtin.import_role: ansible.builtin.import_role:

View File

@ -8,14 +8,14 @@
tasks: tasks:
- name: Perform ReaR Backup - name: Perform ReaR Backup
when: when:
- ansible_distribution_major_version >= '7' - ansible_distribution_major_version == '7'
- not rear_backup_skip | default(false) | bool - not rear_backup_skip | default(false) | bool
block: block:
- name: Import rear_vars role - name: Import rear_vars role
ansible.builtin.import_role: ansible.builtin.import_role:
name: rhc.rear.rear_vars name: rhc.rear.rear_vars
- name: Fetch the template name from NFS exports - name: Fetch the NFS exports template name
ansible.builtin.set_fact: ansible.builtin.set_fact:
job_template_name: "{{ nfs_exports_template_name }}" job_template_name: "{{ nfs_exports_template_name }}"

View File

@ -1,61 +0,0 @@
---
- name: ReaR Backup Validation
hosts: all
become: true
gather_facts: true
strategy: free
vars:
rear_backup_success_file: "/var/log/IPE/IPU/el7to8/bigboot_rear_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
# ignore_errors: true
# register: validate_backup_log
- name: Validate ReaR backup completion
ansible.builtin.command:
cmd: "grep 'Finished running mkbackup workflow' /var/log/rear/rear-{{ ansible_hostname }}.log"
register: validate_backup_log
failed_when: validate_backup_log['rc'] not in [0, 1]
- name: Debug validate_backup_log
ansible.builtin.debug:
var: validate_backup_log
when:
- validate_backup_log['rc'] == 0
- name: Debug validate_backup_log
ansible.builtin.debug:
msg: "p00p"
when:
- validate_backup_log['rc'] == 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\n"
# mode: "0644"
rescue:
- name: No backup log found
ansible.builtin.debug:
msg: "ReaR backup log could not be found or an error was encountered. Please run the backup and try again."

View File

@ -7,4 +7,4 @@
tasks: tasks:
- name: Run cleanup directly - name: Run cleanup directly
ansible.builtin.include_role: ansible.builtin.include_role:
name: ../roles/rear_remove name: rhc.rear.rear_remove

View File

@ -1,19 +0,0 @@
---
- name: Expose ReaR variables
hosts: all
become: true
gather_facts: true
strategy: free
tasks:
- name: Import rear_vars role
ansible.builtin.import_role:
name: rhc.rear.rear_vars
- name: Debug rear_vars_nfs_share
ansible.builtin.debug:
msg: "{{ rear_vars_nfs_base }}/{{ rear_backup_workflow }} ({{ rear_vars_nfs_fsid[rear_backup_workflow] }})"
- name: Debug rear_vars_grub_label
ansible.builtin.debug:
var: rear_vars_grub_label

View File

@ -1,17 +1,5 @@
--- ---
- name: Ensure share directory exists # We should use Ansible to determine disk space, not command/shell (refactor):
ansible.builtin.file:
path: "{{ rear_vars_nfs_base }}/{{ rear_backup_workflow }}"
state: directory
mode: "0777"
owner: root
group: root
# We should use Ansible to determine disk space, not command/shell:
# - name: Debug mounts
# ansible.builtin.debug:
# var: ansible_facts['mounts']
- name: Check disk space on ReaR Backup filesystem for NFS servers - name: Check disk space on ReaR Backup filesystem for NFS servers
ansible.builtin.shell: | ansible.builtin.shell: |
set -o pipefail set -o pipefail
@ -19,10 +7,6 @@
register: disk_space register: disk_space
changed_when: false changed_when: false
# - name: Debug disk_space
# ansible.builtin.debug:
# var: disk_space
- name: Fail job if less than 50GB space - name: Fail job if less than 50GB space
ansible.builtin.fail: ansible.builtin.fail:
msg: ReaR NFS server {{ inventory_hostname }} has less than 50GB of space on filesystem." msg: ReaR NFS server {{ inventory_hostname }} has less than 50GB of space on filesystem."
@ -34,6 +18,14 @@
when: when:
- client_ips is not defined - client_ips is not defined
- name: Ensure share directory exists
ansible.builtin.file:
path: "{{ rear_vars_nfs_base }}/{{ rear_backup_workflow }}"
state: directory
mode: "0777"
owner: root
group: root
- name: Add remote hosts to /etc/exports - name: Add remote hosts to /etc/exports
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
path: /etc/exports path: /etc/exports

View File

@ -4,7 +4,7 @@
path: "{{ rear_backup_success_file_path }}/{{ rear_backup_workflow }}_rear_success" path: "{{ rear_backup_success_file_path }}/{{ rear_backup_workflow }}_rear_success"
register: rear_backup_success_file register: rear_backup_success_file
- name: End if backup has already completed successfully - name: End host if backup has already completed successfully
ansible.builtin.meta: end_host ansible.builtin.meta: end_host
when: when:
- rear_backup_success_file['stat']['exists'] | bool - rear_backup_success_file['stat']['exists'] | bool

View File

@ -6,10 +6,12 @@
# - rear_restore # - rear_restore
rear_backup_workflow: standalone rear_backup_workflow: standalone
# Used by: # Used by:
# - rear_restore # - rear_restore
rear_restore_tmpdir: /var/tmp/rear_restore rear_restore_tmpdir: /var/tmp/rear_restore
# Used by: # Used by:
# - rear_backup # - rear_backup
rear_backup_success_file_path: "/var/IPE/IPU/el7to8" rear_backup_success_file_path: "/var/IPE/IPU/el7to8"
@ -17,6 +19,7 @@ rear_backup_success_file_path: "/var/IPE/IPU/el7to8"
rear_vars_grub_label: 'Relax-and-Recover *** RESTORES RHEL7 ***' rear_vars_grub_label: 'Relax-and-Recover *** RESTORES RHEL7 ***'
rear_vars_grub_conf: /etc/grub.d/45_rear rear_vars_grub_conf: /etc/grub.d/45_rear
# Used by: # Used by:
# - nfs_export # - nfs_export
# - rear_backup # - rear_backup