Modularity updates
This commit is contained in:
parent
ee6912995c
commit
e42fb554a6
3
ansible.cfg
Normal file
3
ansible.cfg
Normal file
@ -0,0 +1,3 @@
|
||||
[defaults]
|
||||
collections_path = collections
|
||||
roles_path = roles
|
@ -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"
|
||||
|
@ -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:
|
||||
|
22
roles/rear_backup/tasks/archive_backup_log.yml
Normal file
22
roles/rear_backup/tasks/archive_backup_log.yml
Normal 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
|
12
roles/rear_backup/tasks/create_success_file.yml
Normal file
12
roles/rear_backup/tasks/create_success_file.yml
Normal 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"
|
@ -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."
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user