The Ansible project for creating backups for the core OpenStack services form the MariaDB database as well as restoring them. This project is exclusively set up for the needs of the BUTCA (Brno University of Technology Cyber Arena). In addition to backuping MariaDB, it is possible to backup OS Glance images and snapshots and store them in the external server.
This project is intended to be run from the AWX platform, so the inventory and vault credentials are configured there, with few modification, it can be run from the CLI as well (the major difference is the configuration of the Ansible vault).
In the file globals.yaml
are defined databases, which can be backuped (restored respectively). Currently, the possible databases are:
- cinder
- glance
- heat
- keystone
- neutron
- nova
- nova_api
- nova_cell0
- placement
Please note, that the databases will differ based on the individual OpenStack environment, in that case, this list must be changed properly.
If the MariaDB databases will differ in the future, the parameter 'mariadb_databases' can be changed accordingly. Based on the values in the 'mariadb_databases' parameter, the extra-vars can be executed along with the backup or restore playbook.
Edit the variables box, e.g.:
---
selected_databases:
- cinder
- keystone
- neutron
or, if all databases should be backuped:
---
selected_databases:
- all
ansible-playbook <path_to_the_backup.yaml> -e '{"selected_databases": ["cinder", "keystone", "neutron"]}'
Edit the variables box, e.g.:
---
selected_backups:
- cinder
- keystone
- neutron
timestamp:
- 2023-03-25_14:53:50
or, if all databases should be restored:
---
selected_backups:
- all
timestamp:
- 2023-03-25_14:53:50
Both 'selected_backups' and 'timestamp' vars are mandatory for successful playbook run!
The 'timestamp' value can be found in the '{{ backup_path}}' directory as it is the default directory on the host machine for storing the backup files. Timestamp is automatically generated by Ansible before creating the backup files.
ansible-playbook <path_to_the_backup.yaml> -e '{"selected_backups": ["all"], "timestamp": ["2023-03-25_14:53:50"]}'
For both backup and restore, you can pass extra vars as a file in the valid YAML format and pass it as, e.g.:
ansible-playbook <path_to_the_backup.yaml> -e @vars_file.yml
- Ansible >= 2.10
- Ansible vault
- Python >= 3.6
- Docker API >= 1.20
- Docker SDK for Python
- openstacksdk with the
clouds.yaml
file specified on the host machine to suit the individual OpenStack environment, for more information, please refer to the OpenStack.Cloud collection.
According to the OpenStack.Cloud collection, the openstacksdk version must be with the interval <0.36, 0.99.0). But, the playbook run ends with the error:
Incompatible openstacksdk library found: Version MUST be >=1.0 and <=None, but 0.61.0 is smaller than minimum version 1.0.
I advise to install openstacksdk version 1.0 and higher as the run ends with RC=0, even if the version is not correct according to the documentation.
- Automate the copying of the backup files to the storage server
- Make the recources testing more complex