Role - backup-and-restore

Role Documentation

Welcome to the “backup-and-restore” role documentation.

Role Defaults

This section highlights all of the defaults and variables set within the “backup-and-restore” role.

tripleo_backup_and_restore_backup_url: nfs://{{ tripleo_backup_and_restore_nfs_server
  }}/ctl_plane_backups
tripleo_backup_and_restore_debug: false
tripleo_backup_and_restore_exclude_paths_common:
- /data/*
- /tmp/*
- '{{ tripleo_backup_and_restore_nfs_storage_folder }}/*'
tripleo_backup_and_restore_exclude_paths_compute:
- /var/lib/nova/instances/*
tripleo_backup_and_restore_exclude_paths_controller:
- /var/lib/mysql/*
tripleo_backup_and_restore_exclude_paths_controller_non_bootrapnode: true
tripleo_backup_and_restore_hiera_config_file: /etc/puppet/hiera.yaml
tripleo_backup_and_restore_local_config:
  BACKUP: NETFS
  BACKUP_PROG_COMPRESS_OPTIONS: ( --gzip)
  BACKUP_PROG_COMPRESS_SUFFIX: '".gz"'
  ISO_DEFAULT: '"automatic"'
  OUTPUT: ISO
  USING_UEFI_BOOTLOADER: 0
tripleo_backup_and_restore_nfs_clients_nets:
- 192.168.24.0/24
- 10.0.0.0/24
- 172.16.0.0/24
tripleo_backup_and_restore_nfs_server: 192.168.24.1
tripleo_backup_and_restore_nfs_storage_folder: /ctl_plane_backups
tripleo_backup_and_restore_output_url: nfs://{{ tripleo_backup_and_restore_nfs_server
  }}/ctl_plane_backups
tripleo_backup_and_restore_rear_simulate: false
tripleo_backup_and_restore_rescue_config: {}
tripleo_backup_and_restore_using_uefi_bootloader: 0

Role Variables: redhat.yml

tripleo_backup_and_restore_nfs_packages:
- nfs-utils
tripleo_backup_and_restore_rear_packages:
- rear
- syslinux
- genisoimage
- nfs-utils

Molecule Scenarios

Molecule is being used to test the “backup-and-restore” role. The following section highlights the drivers in service and provides an example playbook showing how the role is leveraged.

Scenario: default

Driver: delegated
Molecule Options
ansible_connection_options:
  ansible_connection: ssh
login_cmd_template: ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no
  -o Compression=no -o TCPKeepAlive=yes -o VerifyHostKeyDNS=no -o ForwardX11=no -o
  ForwardAgent=no {instance}
managed: false
Molecule Inventory
hosts:
  all:
    hosts:
      instance:
        ansible_host: localhost
Example default playbook
- become: true
  hosts: all
  name: Converge
  roles:
  - role: backup-and-restore
    tripleo_backup_and_restore_hiera_config_file: '{{ ansible_user_dir }}/hiera.yaml'
    tripleo_backup_and_restore_nfs_server: undercloud
    tripleo_backup_and_restore_rear_simulate: true
  vars:
    ansible_python_interpreter: '{{ ansible_user_dir }}/test-python/bin/python'

Usage

This Ansible role allows to do the following tasks:

  1. Install an NFS server.

  2. Install ReaR.

  3. Perform a ReaR backup.

This example is meant to describe a very simple use case in which the user needs to create a set of recovery images from the control plane nodes.

First, the user needs to have access to the environment Ansible inventory.

We will use the tripleo-ansible-inventory command to generate the inventory file.

tripleo-ansible-inventory \
  --ansible_ssh_user heat-admin \
  --static-yaml-inventory ~/tripleo-inventory.yaml

In this particular case, we don’t have an additional NFS server to store the backups from the control plane nodes, so, we will install the NFS server in the Undercloud node (but any other node can be used as the NFS storage backend).

First, we need to create an Ansible playbook to specify that we will install the NFS server in the Undercloud node.

cat <<'EOF' > ~/bar_nfs_setup.yaml
# Playbook
# We will setup the NFS node in the Undercloud node
# (we don't have any other place at the moment to do this)
- become: true
  hosts: undercloud
  name: Setup NFS server for ReaR
  roles:
  - role: backup-and-restore
EOF

Then, we will create another playbook to determine the location in which we will like to install ReaR.

cat <<'EOF' > ~/bar_rear_setup.yaml
# Playbook
# We install and configure ReaR in the control plane nodes
# As they are the only nodes we will like to backup now.
- become: true
  hosts: Controller
  name: Install ReaR
  roles:
  - role: backup-and-restore
EOF

Now we create the playbook to create the actual backup.

cat <<'EOF' > ~/bar_rear_create_restore_images.yaml
# Playbook
# We run ReaR in the control plane nodes.
- become: true
  hosts: Controller
  name: Create the recovery images for the control plane
  roles:
  - role: backup-and-restore
EOF

The last step is to run the previously create playbooks filtering by the corresponding tag.

First, we configure the NFS server.

# Configure NFS server in the Undercloud node
ansible-playbook \
    -v -i ~/tripleo-inventory.yaml \
    --extra="ansible_ssh_common_args='-o StrictHostKeyChecking=no'" \
    --become \
    --become-user root \
    --tags bar_setup_nfs_server \
    ~/bar_nfs_setup.yaml

Then, we install ReaR in the desired nodes.

# Configure ReaR in the control plane
ansible-playbook \
    -v -i ~/tripleo-inventory.yaml \
    --extra="ansible_ssh_common_args='-o StrictHostKeyChecking=no'" \
    --become \
    --become-user root \
    --tags bar_setup_rear \
    ~/bar_rear_setup.yaml

Lastly, we execute the actual backup step.

# Create recovery images of the control plane
ansible-playbook \
    -v -i ~/tripleo-inventory.yaml \
    --extra="ansible_ssh_common_args='-o StrictHostKeyChecking=no'" \
    --become \
    --become-user root \
    --tags bar_create_recover_image \
    ~/bar_rear_create_restore_images.yaml