Restore mock up; cleanup

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

View File

@ -1,12 +0,0 @@
---
- name: Say hi playbook
hosts: all
become: true
gather_facts: true
strategy: free
tasks:
- name: Import say-hi playbook
ansible.builtin.include_role:
name: ../roles/say_hi

View File

@ -4,19 +4,30 @@
gather_facts: true gather_facts: true
become: false 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: 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 - name: Check if configuration backup exists
ansible.builtin.stat: ansible.builtin.stat:
path: "/root/etc-rear-backup-{{ rear_backup_workflow }}.tar.gz" path: "/root/etc-rear-backup-{{ rear_backup_workflow }}.tar.gz"
@ -28,7 +39,7 @@
block: block:
- name: Create tmpdir - name: Create tmpdir
ansible.builtin.file: ansible.builtin.file:
path: /tmp/unarchive path: "{{ rear_restore_tmpdir }}"
state: directory state: directory
mode: "0755" mode: "0755"
@ -36,11 +47,11 @@
ansible.builtin.unarchive: ansible.builtin.unarchive:
remote_src: true remote_src: true
src: "/root/etc-rear-backup-{{ rear_backup_workflow }}.tar.gz" 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 - name: Copy local.cfg from backup into /etc/rear
ansible.builtin.copy: ansible.builtin.copy:
src: /tmp/unarchive/rear/local.conf src: "{{ rear_restore_tmpdir }}/rear/local.conf"
dest: /etc/rear/local.conf dest: /etc/rear/local.conf
remote_src: true remote_src: true
mode: "0600" mode: "0600"
@ -52,7 +63,17 @@
- name: Cleanup leftover artifacts - name: Cleanup leftover artifacts
ansible.builtin.file: 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 # - name: Import rear_vars role
# ansible.builtin.import_role: # ansible.builtin.import_role:

View File

@ -6,11 +6,14 @@
# - rear_restore # - rear_restore
rear_backup_workflow: standalone rear_backup_workflow: standalone
# Used by:
# - rear_restore
rear_restore_tmpdir: /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"
# Used by: # Used by:
# - nfs_export # - nfs_export
# - nfs_server_define # - nfs_server_define

View File

@ -1,38 +0,0 @@
Role Name
=========
A brief description of the role goes here.
Requirements
------------
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
Role Variables
--------------
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
Dependencies
------------
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
Example Playbook
----------------
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: servers
roles:
- { role: username.rolename, x: 42 }
License
-------
BSD
Author Information
------------------
An optional section for the role authors to include contact information, or a website (HTML is not allowed).

View File

@ -1,57 +0,0 @@
galaxy_info:
author: Chris Hammer
description: Say Hi.
company: Hi.
# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker
# Choose a valid license ID from https://spdx.org - some suggested licenses:
# - BSD-3-Clause (default)
# - MIT
# - GPL-2.0-or-later
# - GPL-3.0-only
# - Apache-2.0
# - CC-BY-4.0
license: GPL-2.0-or-later
min_ansible_version: "2.14.0"
# If this a Container Enabled role, provide the minimum Ansible Container version.
# min_ansible_container_version:
#
# Provide a list of supported platforms, and for each platform a list of versions.
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
# To view available platforms and versions (or releases), visit:
# https://galaxy.ansible.com/api/v1/platforms/
#
# platforms:
# - name: Fedora
# versions:
# - all
# - 25
# - name: SomePlatform
# versions:
# - all
# - 1.0
# - 7
# - 99.99
platforms:
- name: EL
versions:
- "8"
- "9"
galaxy_tags: []
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.
dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.

View File

@ -1,30 +0,0 @@
---
- name: Say hi role
ansible.builtin.debug:
msg: "Hi."
- name: Debug client_ips
ansible.builtin.debug:
msg: "{{ client_ips }}"
when:
- client_ips is defined
- name: Debug namehost
ansible.builtin.debug:
msg: "{{ namehost }}"
when:
- namehost is defined
- name: Debug roles_path
ansible.builtin.debug:
var: role_path
# - name: Include rear_restore role for fun
# ansible.builtin.import_role:
# name: ../roles/rear_restore
- name: Include rear_restore role for fun
ansible.builtin.import_role:
name: "{{ role_path }}/../rear_restore"
...

View File

@ -1,2 +0,0 @@
---
# vars file for say_hi