Modularity updates

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

3
ansible.cfg Normal file
View File

@ -0,0 +1,3 @@
[defaults]
collections_path = collections
roles_path = roles

View File

@ -5,9 +5,6 @@
gather_facts: true
strategy: free
vars:
rear_backup_workflow: standalone
tasks:
- name: Import rear_vars role
ansible.builtin.import_role:
@ -32,37 +29,3 @@
- name: Include the backup role
ansible.builtin.include_role:
name: rhc.rear.rear_backup
- 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
- 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

@ -7,6 +7,15 @@
vars:
rear_backup_workflow: standalone
# We need to extract the contents of the archive, and then restore /etc/rear/local.conf
# after that THEN run mkrescue + rear_restore
# For /etc/rear/local.conf - first stat and see if exists; if exists use it
# else restore from archive
# How would this work if we restore from a differnt workflow?
# Won't we need to regenerate the local.cfg?
# Could we save the archive to etc-rear-{{ workflow }}.tar.gz and restore from that?
tasks:
- name: Import rear_vars role
ansible.builtin.import_role:

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."

View File

@ -1,11 +1,18 @@
---
# Used by:
# - nfs_export
# - rear_backup
# - rear_local-cfg
# - rear_restore
rear_backup_workflow: standalone
# Used by:
# - rear_backup
rear_backup_success_file_path: "/var/IPE/IPU/el7to8"
# Used by:
# - nfs_exports
# - nfs_export
# - nfs_server_define
# - rear_backup
# - rear_local-cfg