Restore mock up; cleanup

This commit is contained in:
2025-03-05 13:52:08 -05:00
parent 73a2e22c1e
commit 8c4ce22fe0
7 changed files with 41 additions and 156 deletions

View File

@ -4,19 +4,30 @@
gather_facts: true
become: false
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:
name: rhc.rear.rear_vars
- name: Check if ReaR restore was already completed
ansible.builtin.find:
paths:
- /var/tmp
patterns:
- rear_restore*
register: rear_restore_file
- name: Check for previous restore and end host if already completed
when:
- rear_restore_file['files'] | length > 0
block:
- name: Check for ReaR restore
ansible.builtin.debug:
msg: "ReaR restore was already completed - {{ rear_restore_file['files'] | json_query('[].path') | string }}"
- name: End host for servers that already completed a ReaR restore
ansible.builtin.meta: end_host
- name: Check if configuration backup exists
ansible.builtin.stat:
path: "/root/etc-rear-backup-{{ rear_backup_workflow }}.tar.gz"
@ -28,7 +39,7 @@
block:
- name: Create tmpdir
ansible.builtin.file:
path: /tmp/unarchive
path: "{{ rear_restore_tmpdir }}"
state: directory
mode: "0755"
@ -36,11 +47,11 @@
ansible.builtin.unarchive:
remote_src: true
src: "/root/etc-rear-backup-{{ rear_backup_workflow }}.tar.gz"
dest: /tmp/unarchive
dest: "{{ rear_restore_tmpdir }}"
- name: Copy local.cfg from backup into /etc/rear
ansible.builtin.copy:
src: /tmp/unarchive/rear/local.conf
src: "{{ rear_restore_tmpdir }}/rear/local.conf"
dest: /etc/rear/local.conf
remote_src: true
mode: "0600"
@ -52,7 +63,17 @@
- name: Cleanup leftover artifacts
ansible.builtin.file:
path: /tmp/unarchive
path: "{{ item }}"
state: absent
loop:
- "{{ rear_backup_success_file_path }}/{{ rear_backup_workflow }}_rear_success"
- "{{ rear_restore_tmpdir }}"
- name: Create file for ReaR restore success
ansible.builtin.file:
path: "/var/tmp/rear_restore.{{ ansible_date_time.iso8601_basic }}"
state: touch
mode: "0664"
# - name: Import rear_vars role
# ansible.builtin.import_role: