ReaR restore initial
This commit is contained in:
parent
1cbc9699d8
commit
13ff9b24d6
@ -9,80 +9,6 @@
|
||||
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.{{ rear_backup_workflow }}*"
|
||||
register: rear_restore_file
|
||||
|
||||
- name: Check for ReaR restore
|
||||
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"
|
||||
register: rear_config_backup_stat
|
||||
|
||||
- name: Create tmpdir and extract archive
|
||||
when:
|
||||
- rear_config_backup_stat['stat']['exists'] | bool
|
||||
block:
|
||||
- name: Create tmpdir
|
||||
ansible.builtin.file:
|
||||
path: "{{ rear_restore_tmpdir }}"
|
||||
state: directory
|
||||
mode: "0755"
|
||||
|
||||
- name: Extract archive contents
|
||||
ansible.builtin.unarchive:
|
||||
remote_src: true
|
||||
src: "/root/etc-rear-backup-{{ rear_backup_workflow }}.tar.gz"
|
||||
dest: "{{ rear_restore_tmpdir }}"
|
||||
|
||||
- name: Copy local.cfg from backup into /etc/rear
|
||||
ansible.builtin.copy:
|
||||
src: "{{ rear_restore_tmpdir }}/rear/local.conf"
|
||||
dest: /etc/rear/local.conf
|
||||
remote_src: true
|
||||
mode: "0600"
|
||||
|
||||
# - name: Rebuild ReaR initrd
|
||||
# ansible.builtin.command:
|
||||
# cmd: rear -d -v mkrescue
|
||||
# register: rear_initrd_cmd
|
||||
|
||||
- name: Cleanup leftover artifacts
|
||||
ansible.builtin.file:
|
||||
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.{{ rear_backup_workflow }}.{{ ansible_date_time.iso8601_basic }}"
|
||||
state: touch
|
||||
mode: "0664"
|
||||
|
||||
# - name: Import rear_vars role
|
||||
# ansible.builtin.import_role:
|
||||
# name: rhc.rear.rear_vars
|
||||
|
||||
# - name: Configure ReaR local.conf file
|
||||
# ansible.builtin.include_role:
|
||||
# name: rhc.rear.rear_local_cfg
|
||||
|
||||
# - name: Perform ReaR restore
|
||||
# ansible.builtin.include_role:
|
||||
# name: rhc.rear.rear_restore
|
||||
- name: Include ReaR restore role
|
||||
ansible.builtin.include_role:
|
||||
name: rhc.rear.rear_restore
|
||||
|
@ -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).
|
@ -25,13 +25,9 @@
|
||||
changed_when: true
|
||||
register: rear_mkbackup
|
||||
|
||||
- name: Update ReaR Grub menu item
|
||||
ansible.builtin.lineinfile:
|
||||
path: "{{ rear_vars_grub_conf }}"
|
||||
regexp: '^menuentry '
|
||||
line: "menuentry '{{ rear_vars_grub_label }}' --class os {"
|
||||
state: present
|
||||
notify: Update Grub
|
||||
- name: Update menu item for ReaR in Grub config
|
||||
ansible.builtin.include_role:
|
||||
name: rhc.rear.rear_grub_cfg
|
||||
|
||||
- name: Archive backup log
|
||||
ansible.builtin.include_tasks:
|
||||
|
8
roles/rear_grub_cfg/tasks/main.yml
Normal file
8
roles/rear_grub_cfg/tasks/main.yml
Normal file
@ -0,0 +1,8 @@
|
||||
---
|
||||
- name: Update menu item for ReaR in Grub config
|
||||
ansible.builtin.lineinfile:
|
||||
path: "{{ rear_vars_grub_conf }}"
|
||||
regexp: '^menuentry '
|
||||
line: "menuentry '{{ rear_vars_grub_label }}' --class os {"
|
||||
state: present
|
||||
notify: Update Grub
|
@ -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).
|
@ -1,52 +0,0 @@
|
||||
galaxy_info:
|
||||
author: your name
|
||||
description: your role description
|
||||
company: your company (optional)
|
||||
|
||||
# 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: license (GPL-2.0-or-later, MIT, etc)
|
||||
|
||||
min_ansible_version: 2.1
|
||||
|
||||
# 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
|
||||
|
||||
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.
|
@ -1,7 +1,83 @@
|
||||
---
|
||||
- name: Restore the server using ReaR backup
|
||||
ansible.builtin.command: "grub2-reboot 'Relax-and-Recover {{ rear_vars_grub_label }}'"
|
||||
- name: Check if ReaR restore was already completed
|
||||
ansible.builtin.find:
|
||||
paths:
|
||||
- /var/tmp
|
||||
patterns:
|
||||
- "rear_restore.{{ rear_backup_workflow }}*"
|
||||
register: rear_restore_file
|
||||
|
||||
- name: Reboot host
|
||||
ansible.builtin.import_role:
|
||||
name: verified_reboot
|
||||
- name: Check for ReaR restore
|
||||
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 /etc/rear backup exists
|
||||
ansible.builtin.stat:
|
||||
path: "/root/etc-rear-backup-{{ rear_backup_workflow }}.tar.gz"
|
||||
register: rear_config_backup_stat
|
||||
|
||||
- name: Restore the server
|
||||
when:
|
||||
- rear_config_backup_stat['stat']['exists'] | bool
|
||||
block:
|
||||
- name: Create tmpdir
|
||||
ansible.builtin.file:
|
||||
path: "{{ rear_restore_tmpdir }}"
|
||||
state: directory
|
||||
mode: "0755"
|
||||
|
||||
- name: Extract /etc/rear archive contents
|
||||
ansible.builtin.unarchive:
|
||||
remote_src: true
|
||||
src: "/root/etc-rear-backup-{{ rear_backup_workflow }}.tar.gz"
|
||||
dest: "{{ rear_restore_tmpdir }}"
|
||||
|
||||
- name: Copy local.cfg from backup into /etc/rear
|
||||
ansible.builtin.copy:
|
||||
src: "{{ rear_restore_tmpdir }}/rear/local.conf"
|
||||
dest: /etc/rear/local.conf
|
||||
remote_src: true
|
||||
mode: "0600"
|
||||
|
||||
- name: Rebuild ReaR initrd
|
||||
ansible.builtin.command:
|
||||
cmd: rear -d -v mkrescue
|
||||
register: rear_initrd_cmd
|
||||
|
||||
- name: Update menu item for ReaR in Grub config
|
||||
ansible.builtin.include_role:
|
||||
name: rhc.rear.rear_grub_cfg
|
||||
|
||||
- name: Restore the server using ReaR backup
|
||||
ansible.builtin.command: "grub2-reboot 'Relax-and-Recover {{ rear_vars_grub_label }}'"
|
||||
|
||||
- name: Reboot host to restore server
|
||||
ansible.builtin.import_role:
|
||||
name: verified_reboot
|
||||
|
||||
- name: Cleanup leftover artifacts
|
||||
ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
state: absent
|
||||
loop:
|
||||
- "{{ rear_restore_tmpdir }}"
|
||||
- "{{ rear_restore_file['files'] | json_query('[].path') }}"
|
||||
# - "{{ rear_backup_success_file_path }}/{{ rear_backup_workflow }}_rear_success"
|
||||
|
||||
- name: Create file for ReaR restore success
|
||||
ansible.builtin.file:
|
||||
path: "/var/tmp/rear_restore.{{ rear_backup_workflow }}.{{ ansible_date_time.iso8601_basic }}"
|
||||
state: touch
|
||||
mode: "0664"
|
||||
|
||||
- name: Show ReaR restore results
|
||||
ansible.builtin.debug:
|
||||
msg: "ReaR restore has successfully completed."
|
||||
|
Loading…
x
Reference in New Issue
Block a user