RETIRED, Ansible role to perform common tasks to manage OpenStack clouds
Go to file
Jeremy Stanley 55889cb0df Correct the tox option for skipping sdist generation
The tox option to skip source distribution building is skipsdist,
but this seems to be often misspelled skipdist instead, which gets
silently ignored and so does not take effect. Correct it
everywhere, in hopes that new projects will finally stop copying
this mistake around.

See https://tox.readthedocs.io/en/latest/config.html#conf-skipsdist
and https://github.com/tox-dev/tox/issues/1388 for details.

Change-Id: Ie0667de615e02284cb6302d9df7165651a16f988
2021-06-25 15:48:47 +00:00
ci-scripts Fix the gate 2019-02-25 08:56:53 +01:00
defaults Added filesystem backup 2019-03-05 09:45:17 +01:00
handlers Initial commit 2018-04-23 12:04:58 -04:00
library Fix ci 2021-06-25 09:48:30 -06:00
meta Initial commit 2018-04-23 12:04:58 -04:00
tasks Merge "Redis backup, restore, and validation tasks" 2019-03-26 15:37:25 +00:00
templates Merge "Fix temp. inventory on the backup host" 2019-03-15 10:51:50 +00:00
vars Complete missing service_map vars data 2018-08-08 12:57:12 -07:00
zuul.d Add basic jobs in Zuul Layout and .gitreview 2018-07-24 16:54:47 -06:00
.gitreview OpenDev Migration Patch 2019-04-19 19:36:14 +00:00
ansible-requirements.txt Bump pyflakes and pin ansible-lint 2020-11-09 09:33:54 -07:00
LICENSE Add missing license file 2018-07-27 16:42:23 +00:00
non-galaxy.txt Fix the gate 2019-02-25 08:56:53 +01:00
README-backup-ops.md Redis backup, restore, and validation tasks 2019-03-21 16:33:21 +00:00
README.rst Fixing the README RST formatting 2020-01-15 13:36:46 -05:00
requirements.txt Bump pyflakes and pin ansible-lint 2020-11-09 09:33:54 -07:00
setup.cfg Mailing lists change openstack-dev to openstack-discuss 2019-07-01 18:56:08 +08:00
setup.py Add basic jobs in Zuul Layout and .gitreview 2018-07-24 16:54:47 -06:00
test-requirements.txt Fix ci 2021-06-25 09:48:30 -06:00
tox.ini Correct the tox option for skipping sdist generation 2021-06-25 15:48:47 +00:00

OpenStack Operations

Perform various common OpenStack operations by calling this role with an action and appropriate variables.

Restart Services

Restarting OpenStack services is complex. This role aims to intelligently evaluate the environment and determine how a service is running, what components constitute that service, and restart those components appropriately. This allows the operator to think in terms of the service that needs restarting rather than having to remember all the details required to restart that service.

This role uses a service map located in vars/main.yml. The service map is a dictionary with one key per service name. Each service name key contains three additional keys that list the SystemD unit files, container names, and vhosts used by each service. It is possible to extend this list of services by defining custom services in operations_custom_service_map. This will be combined with the default service map and passed to the service_map_facts module.

The service_map_facts module will evalute the target system and return a list of services or containers that need to be restarted. Those lists will then be used in subsequent tasks to restart a service or a container.

Fetch Logs

To fetch logs with this role, use the fetch_logs.yml tasks file. By default, every log file in /var/log matching the *.log pattern will be fetched from the remote and put into a folder adjacent to the playbook named for each host, preserving the directory structure as found on the remote host.

See defaults/main.yml for the dictionary of options to control logs that are fetched.

Cleanup Container Items

WARNING: This will delete images, containers, and volumes from the target system(s).

To perform the most common cleanup tasks --- delete dangling images and volumes and delete exited or dead containers --- use the container_cleanup.yml tasks file.

This role includes modules for listing image, volume, and container IDs. The filtered lists (one each for images, containers, and volumes) returned by this module are used to determine which items to remove. Specifying multiple filters creates an and match, so all filters must match.

If using Docker, see these guides for images, containers, and volumes for filter options.

Backup and Restore Operations

See Backup and Restore Operations for more details.

Requirements

  • ansible >= 2.4

If using Docker:

  • docker-py >= 1.7.0
  • Docker API >= 1.20

Role Variables

Variables used for cleaning up Docker
Name Default Value Description
operations_container_runtime docker Container runtime to use. Currently supports docker and podman.
operations_image_filter ['dangling=true'] List of image filters.
operations_volume_filter ['dangling=true'] List of volume filters.
operations_container_filter ['status=exited', 'status=dead'] List of container filters.
Variables for fetching logs
Name Default Value Description
operations_log_destination {{ playbook_dir }} Path where logs will be stored when fetched from remote systems.
Variables for restarting services
Name Default Value Description
operations_services_to_restart [] List of services to restart on target systems.
operations_custom_service_map {} Dictionary of services and their systemd unit files, container names, and vhosts. This will be combined with the builtin list of services in vars/main.yml.
Variables for backup
Name Default Value Description
backup_tmp_dir /var/tmp/openstack-backup Temporary directory created on host to store backed up data.
backup_directory /home/{{ ansible_user }} Directory on backup host where backup archive will be saved.
backup_host {{ hostvars[groups[backup_server_hostgroup][0]]['inventory_hostname'] }} Backup host where data will be archived.
backup_host_ssh_args -F /var/tmp/{{ ansible_hostname }}_config ssh arguments used for connectiong to backup host.

Dependencies

None

Example Playbooks

Restart Services playbook

- hosts: all
  tasks:
    - name: Restart a service
      import_role:
        name: openstack-operations
        tasks_from: restart_service.yml
      vars:
        operations_services_to_restart:
          - docker
          - keystone
          - mariadb

Cleanup Container Items playbook

- name: Cleanup dangling and dead images, containers, and volumes
  hosts: all
  tasks:
    - name: Cleanup unused images, containers, and volumes
      import_role:
        name: openstack-operations
        tasks_from: container_cleanup.yml

- name: Use custom filters for cleaning
  hosts: all
  tasks:
    - name: Cleanup unused images, containers, and volumes
      import_role:
        name: openstack-operations
        tasks_from: container_cleanup.yml
      vars:
        operations_image_filters:
          - before=image1
        operations_volume_filters:
          - label=my_volume
        operations_container_filters:
          - name=keystone

Fetch Logs playbook

- hosts: all
  tasks:
    - name: Fetch logs
      import_role:
        name: openstack-operations
        tasks_from: fetch_logs.yml

License

Apache 2.0