diff --git a/doc/source/roles/role-backup-and-restore.rst b/doc/source/roles/role-backup-and-restore.rst new file mode 100644 index 000000000..8b7115d28 --- /dev/null +++ b/doc/source/roles/role-backup-and-restore.rst @@ -0,0 +1,128 @@ +========================= +Role - backup-and-restore +========================= + +.. ansibleautoplugin:: + :role: tripleo_ansible/roles/backup-and-restore + +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 + diff --git a/tripleo_ansible/roles/backup-and-restore/backup/tasks/main.yml b/tripleo_ansible/roles/backup-and-restore/backup/tasks/main.yml new file mode 100644 index 000000000..ae1c8a473 --- /dev/null +++ b/tripleo_ansible/roles/backup-and-restore/backup/tasks/main.yml @@ -0,0 +1,52 @@ +--- +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +# "backup-and-restore" will search for and load any operating system variable file + +# found within the "vars/" path. If no OS files are found the task will skip. +- name: Gather variables for each operating system + include_vars: "{{ item }}" + with_first_found: + - skip: true + files: + - "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml" + - "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml" + - "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml" + - "{{ ansible_distribution | lower }}.yml" + - "{{ ansible_os_family | lower }}-{{ ansible_distribution_version.split('.')[0] }}.yml" + - "{{ ansible_os_family | lower }}.yml" + tags: + - always + +- name: Create backup command + set_fact: + tripleo_backup_and_restore_rear_command: rear {{ '-s ' if tripleo_backup_and_restore_rear_simulate else '' }}-d -v mkbackup + tags: + - bar_create_recover_image + +- name: Create the node backup + become: true + command: '{{ tripleo_backup_and_restore_rear_command }}' + register: tripleo_backup_and_restore_rear_output + tags: + - bar_create_recover_image + +- name: Display ReaR recovery image creation output + debug: + var: tripleo_backup_and_restore_rear_output + tags: + - bar_create_recover_image diff --git a/tripleo_ansible/roles/backup-and-restore/defaults/main.yml b/tripleo_ansible/roles/backup-and-restore/defaults/main.yml new file mode 100644 index 000000000..3d77b117e --- /dev/null +++ b/tripleo_ansible/roles/backup-and-restore/defaults/main.yml @@ -0,0 +1,26 @@ +--- +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +# All variables intended for modification should place placed in this file. + +# All variables within this role should have a prefix of "tripleo_backup_and_restore" +tripleo_backup_and_restore_debug: false +tripleo_backup_and_restore_nfs_server: undercloud-0 +tripleo_backup_and_restore_nfs_storage_folder: /ctl_plane_backups +tripleo_backup_and_restore_nfs_clients_nets: ['192.168.24.0/24', '10.0.0.0/24'] +tripleo_backup_and_restore_rear_simulate: false +tripleo_backup_and_restore_using_uefi_bootloader: 0 diff --git a/tripleo_ansible/roles/backup-and-restore/meta/main.yml b/tripleo_ansible/roles/backup-and-restore/meta/main.yml new file mode 100644 index 000000000..829d49762 --- /dev/null +++ b/tripleo_ansible/roles/backup-and-restore/meta/main.yml @@ -0,0 +1,44 @@ +--- +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +galaxy_info: + author: OpenStack + description: TripleO OpenStack Role -- backup-and-restore + company: Red Hat + license: Apache-2.0 + min_ansible_version: 2.7 + # + # 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: + - 28 + - name: CentOS + versions: + - 7 + + galaxy_tags: + - tripleo + + +# List your role dependencies here, one per line. Be sure to remove the '[]' above, +# if you add dependencies to this list. +dependencies: [] diff --git a/tripleo_ansible/roles/backup-and-restore/molecule/default/Dockerfile b/tripleo_ansible/roles/backup-and-restore/molecule/default/Dockerfile new file mode 100644 index 000000000..1b91a0e0b --- /dev/null +++ b/tripleo_ansible/roles/backup-and-restore/molecule/default/Dockerfile @@ -0,0 +1,37 @@ +# Molecule managed +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +{% if item.registry is defined %} +FROM {{ item.registry.url }}/{{ item.image }} +{% else %} +FROM {{ item.image }} +{% endif %} + +RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates && apt-get clean; \ + elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python*-dnf bash {{ item.pkg_extras | default('') }} && dnf clean all; \ + elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl python-setuptools bash {{ item.pkg_extras | default('') }} && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \ + elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml {{ item.pkg_extras | default('') }} && zypper clean -a; \ + elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates {{ item.pkg_extras | default('') }}; \ + elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates {{ item.pkg_extras | default('') }} && xbps-remove -O; fi + +{% for pkg in item.easy_install | default([]) %} +# install pip for centos where there is no python-pip rpm in default repos +RUN easy_install {{ pkg }} +{% endfor %} + + +CMD ["sh", "-c", "while true; do sleep 10000; done"] diff --git a/tripleo_ansible/roles/backup-and-restore/molecule/default/molecule.yml b/tripleo_ansible/roles/backup-and-restore/molecule/default/molecule.yml new file mode 100644 index 000000000..4f07c04ae --- /dev/null +++ b/tripleo_ansible/roles/backup-and-restore/molecule/default/molecule.yml @@ -0,0 +1,53 @@ +--- +driver: + name: delegated + options: + managed: false + 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} + ansible_connection_options: + ansible_connection: ssh + +log: true + +platforms: + - name: instance + +provisioner: + name: ansible + config_options: + defaults: + fact_caching: jsonfile + fact_caching_connection: /tmp/molecule/facts + inventory: + hosts: + all: + hosts: + instance: + ansible_host: localhost + log: true + env: + ANSIBLE_STDOUT_CALLBACK: yaml + ANSIBLE_ROLES_PATH: "${ANSIBLE_ROLES_PATH}:${HOME}/zuul-jobs/roles" + +scenario: + name: default + test_sequence: + - prepare + - converge + +lint: + enabled: false + +verifier: + name: testinfra + lint: + name: flake8 diff --git a/tripleo_ansible/roles/backup-and-restore/molecule/default/playbook.yml b/tripleo_ansible/roles/backup-and-restore/molecule/default/playbook.yml new file mode 100644 index 000000000..629fb0f3a --- /dev/null +++ b/tripleo_ansible/roles/backup-and-restore/molecule/default/playbook.yml @@ -0,0 +1,26 @@ +--- +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +- name: Converge + become: true + hosts: all + roles: + - role: backup-and-restore + 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" diff --git a/tripleo_ansible/roles/backup-and-restore/molecule/default/prepare.yml b/tripleo_ansible/roles/backup-and-restore/molecule/default/prepare.yml new file mode 100644 index 000000000..13414f46a --- /dev/null +++ b/tripleo_ansible/roles/backup-and-restore/molecule/default/prepare.yml @@ -0,0 +1,87 @@ +--- +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +- name: Prepare + hosts: all + become: true + gather_facts: true + pre_tasks: + - name: Check for docker cli + command: "command -v docker" + register: docker_cli + failed_when: false + changed_when: false + + - name: Check for docker connection + command: "docker ps" + register: docker_ps + failed_when: false + changed_when: false + + - name: set basic user fact + set_fact: + ansible_user: "{{ lookup('env', 'USER') }}" + when: + - ansible_user is undefined + + - name: set basic home fact + set_fact: + ansible_user_dir: "{{ lookup('env', 'HOME') }}" + when: + - ansible_user_dir is undefined + roles: + - role: test_deps + - role: install-docker + when: + - (docker_cli.rc != 0) or + (docker_ps.rc != 0) + post_tasks: + - name: Install docker-sdk + pip: + name: docker + virtualenv: "{{ ansible_user_dir }}/test-python" + virtualenv_site_packages: true + + - name: Install deps for ReaR + package: + name: "{{ rear_packages }}" + state: present + vars: + rear_packages: + - rear + - syslinux + - genisoimage + - kbd + + - name: pull an image + docker_image: + name: fedora:28 + source: pull + vars: + ansible_python_interpreter: "{{ ansible_user_dir }}/test-python/bin/python" + + - name: Create a data container + docker_container: + name: "{{ item }}" + image: fedora:28 + detach: true + command: sleep 1d + with_items: + - docker-container1 + - docker-container2 + vars: + ansible_python_interpreter: "{{ ansible_user_dir }}/test-python/bin/python" diff --git a/tripleo_ansible/roles/backup-and-restore/setup_nfs/tasks/main.yml b/tripleo_ansible/roles/backup-and-restore/setup_nfs/tasks/main.yml new file mode 100644 index 000000000..c4d5a361e --- /dev/null +++ b/tripleo_ansible/roles/backup-and-restore/setup_nfs/tasks/main.yml @@ -0,0 +1,106 @@ +--- +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +# "backup-and-restore" will search for and load any operating system variable file + +# found within the "vars/" path. If no OS files are found the task will skip. +- name: Gather variables for each operating system + include_vars: "{{ item }}" + with_first_found: + - skip: true + files: + - "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml" + - "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml" + - "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml" + - "{{ ansible_distribution | lower }}.yml" + - "{{ ansible_os_family | lower }}-{{ ansible_distribution_version.split('.')[0] }}.yml" + - "{{ ansible_os_family | lower }}.yml" + tags: + - always + +- name: Install required packages for the NFS server + become: true + package: + name: "{{ tripleo_backup_and_restore_nfs_packages }}" + state: present + tags: + - bar_setup_nfs_server + +- name: Allow NFS connections port 111. + become: true + iptables: + action: insert + rule_num: '1' + chain: INPUT + ctstate: NEW + protocol: tcp + destination_port: '111' + jump: ACCEPT + comment: Accept new NFS connections (111). + tags: + - bar_setup_nfs_server + +- name: Allow NFS connections port 2049. + become: true + iptables: + action: insert + rule_num: '1' + chain: INPUT + ctstate: NEW + protocol: tcp + destination_port: '2049' + jump: ACCEPT + comment: Accept new NFS connections (2049). + tags: + - bar_setup_nfs_server + +- name: Enable the NFS service in the NFS server + become: true + systemd: + name: nfs-server + enabled: true + tags: + - bar_setup_nfs_server + +- name: Create backup folder in the NFS server + become: true + file: + path: "{{ tripleo_backup_and_restore_nfs_storage_folder }}" + state: directory + mode: '0777' + tags: + - bar_setup_nfs_server + +- name: Generate NFS exports table in the server + become: true + template: + src: exports.j2 + dest: /etc/exports + owner: root + group: root + mode: '0644' + backup: true + tags: + - bar_setup_nfs_server + +- name: Reload the NFS service + become: true + systemd: + name: nfs-server + state: reloaded + tags: + - bar_setup_nfs_server diff --git a/tripleo_ansible/roles/backup-and-restore/setup_rear/tasks/main.yml b/tripleo_ansible/roles/backup-and-restore/setup_rear/tasks/main.yml new file mode 100644 index 000000000..d62e907b8 --- /dev/null +++ b/tripleo_ansible/roles/backup-and-restore/setup_rear/tasks/main.yml @@ -0,0 +1,71 @@ +--- +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +# "backup-and-restore" will search for and load any operating system variable file + +# found within the "vars/" path. If no OS files are found the task will skip. +- name: Gather variables for each operating system + include_vars: "{{ item }}" + with_first_found: + - skip: true + files: + - "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml" + - "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml" + - "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml" + - "{{ ansible_distribution | lower }}.yml" + - "{{ ansible_os_family | lower }}-{{ ansible_distribution_version.split('.')[0] }}.yml" + - "{{ ansible_os_family | lower }}.yml" + tags: + - always + +- name: Install required packages for ReaR + become: true + package: + name: "{{ tripleo_backup_and_restore_rear_packages }}" + state: present + tags: + - bar_setup_rear + +- name: Get local hostname + command: hostname + register: tripleo_backup_and_restore_hostname + tags: + - bar_setup_rear + +- name: Generate ReaR config file + become: true + template: + src: local.conf.j2 + dest: /etc/rear/local.conf + owner: root + group: root + mode: '0644' + backup: true + tags: + - bar_setup_rear + +- name: Generate ReaR rescue file + become: true + template: + src: rescue.conf.j2 + dest: /etc/rear/rescue.conf + owner: root + group: root + mode: '0644' + backup: true + tags: + - bar_setup_rear diff --git a/tripleo_ansible/roles/backup-and-restore/tasks/main.yml b/tripleo_ansible/roles/backup-and-restore/tasks/main.yml new file mode 100644 index 000000000..5163f82ff --- /dev/null +++ b/tripleo_ansible/roles/backup-and-restore/tasks/main.yml @@ -0,0 +1,42 @@ +--- +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +# "backup-and-restore" will search for and load any operating system variable file + +# found within the "vars/" path. If no OS files are found the task will skip. +- name: Gather variables for each operating system + include_vars: "{{ item }}" + with_first_found: + - skip: true + files: + - "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml" + - "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml" + - "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml" + - "{{ ansible_distribution | lower }}.yml" + - "{{ ansible_os_family | lower }}-{{ ansible_distribution_version.split('.')[0] }}.yml" + - "{{ ansible_os_family | lower }}.yml" + tags: + - always + +- name: Setup NFS server + import_tasks: ../setup_nfs/tasks/main.yml + +- name: Setup ReaR + import_tasks: ../setup_rear/tasks/main.yml + +- name: Create recovery images with ReaR + import_tasks: ../backup/tasks/main.yml diff --git a/tripleo_ansible/roles/backup-and-restore/templates/exports.j2 b/tripleo_ansible/roles/backup-and-restore/templates/exports.j2 new file mode 100644 index 000000000..6c3a43b2e --- /dev/null +++ b/tripleo_ansible/roles/backup-and-restore/templates/exports.j2 @@ -0,0 +1,8 @@ +# This configuration file is generated automatically +# by the backup-and-restore role part of TripleO +# Ansible. No not edit this file, all changes +# will be lost. Refer to the following URL for +# more information and implementation details: +# https://opendev.org/openstack/tripleo-ansible + +{{ tripleo_backup_and_restore_nfs_storage_folder }} {% for net in tripleo_backup_and_restore_nfs_clients_nets %}{{ net }}(rw,sync,no_root_squash,no_subtree_check) {% endfor %} diff --git a/tripleo_ansible/roles/backup-and-restore/templates/local.conf.j2 b/tripleo_ansible/roles/backup-and-restore/templates/local.conf.j2 new file mode 100644 index 000000000..666b3dbf2 --- /dev/null +++ b/tripleo_ansible/roles/backup-and-restore/templates/local.conf.j2 @@ -0,0 +1,17 @@ +# This configuration file is generated automatically +# by the backup-and-restore role part of TripleO +# Ansible. No not edit this file, all changes +# will be lost. Refer to the following URL for +# more information and implementation details: +# https://opendev.org/openstack/tripleo-ansible + +OUTPUT=ISO +OUTPUT_URL=nfs://{{ tripleo_backup_and_restore_nfs_server }}/ctl_plane_backups +ISO_PREFIX={{ tripleo_backup_and_restore_hostname.stdout }} +BACKUP=NETFS +BACKUP_PROG_COMPRESS_OPTIONS=( --gzip ) +BACKUP_PROG_COMPRESS_SUFFIX=".gz" +BACKUP_PROG_OPTIONS+=( --anchored --xattrs-include='*.*' --xattrs ) +BACKUP_PROG_EXCLUDE=( '/tmp/*' '/data/*' '{{ tripleo_backup_and_restore_nfs_storage_folder }}' ) +BACKUP_URL=nfs://{{ tripleo_backup_and_restore_nfs_server }}/ctl_plane_backups +USING_UEFI_BOOTLOADER={{ tripleo_backup_and_restore_using_uefi_bootloader }} diff --git a/tripleo_ansible/roles/backup-and-restore/templates/rescue.conf.j2 b/tripleo_ansible/roles/backup-and-restore/templates/rescue.conf.j2 new file mode 100644 index 000000000..eb60ff066 --- /dev/null +++ b/tripleo_ansible/roles/backup-and-restore/templates/rescue.conf.j2 @@ -0,0 +1,8 @@ +# This configuration file is generated automatically +# by the backup-and-restore role part of TripleO +# Ansible. No not edit this file, all changes +# will be lost. Refer to the following URL for +# more information and implementation details: +# https://opendev.org/openstack/tripleo-ansible + +BACKUP_PROG_OPTIONS+=( --anchored --xattrs-include='*.*' --xattrs ) diff --git a/tripleo_ansible/roles/backup-and-restore/vars/redhat.yml b/tripleo_ansible/roles/backup-and-restore/vars/redhat.yml new file mode 100644 index 000000000..16d2be52d --- /dev/null +++ b/tripleo_ansible/roles/backup-and-restore/vars/redhat.yml @@ -0,0 +1,30 @@ +--- +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +# While options found within the vars/ path can be overridden using extra +# vars, items within this path are considered part of the role and not +# intended to be modified. + +# All variables within this role should have a prefix of "tripleo_{{ role_name | replace('-', '_') }}" + +tripleo_backup_and_restore_rear_packages: + - rear + - syslinux + - genisoimage + - nfs-utils +tripleo_backup_and_restore_nfs_packages: + - nfs-utils diff --git a/zuul.d/molecule.yaml b/zuul.d/molecule.yaml index 339fc26b8..69a3d96d5 100644 --- a/zuul.d/molecule.yaml +++ b/zuul.d/molecule.yaml @@ -34,6 +34,8 @@ - tripleo-ansible-centos-7-molecule-tripleo-clients-install - tripleo-ansible-centos-7-molecule-tripleo-validations-package - tripleo-ansible-centos-7-molecule-tripleo-sshd + - tripleo-ansible-centos-7-molecule-backup-and-restore + gate: jobs: - tripleo-ansible-centos-7-molecule-aide @@ -68,6 +70,7 @@ - tripleo-ansible-centos-7-molecule-tripleo-clients-install - tripleo-ansible-centos-7-molecule-tripleo-validations-package - tripleo-ansible-centos-7-molecule-tripleo-sshd + - tripleo-ansible-centos-7-molecule-backup-and-restore name: tripleo-ansible-molecule-jobs - job: files: @@ -302,3 +305,10 @@ parent: tripleo-ansible-centos-7-base vars: tripleo_role_name: tripleo-sshd +- job: + files: + - ^tripleo_ansible/roles/backup-and-restore/.* + name: tripleo-ansible-centos-7-molecule-backup-and-restore + parent: tripleo-ansible-centos-7-base + vars: + tripleo_role_name: backup-and-restore