Remove mistral cli from the backup playbook

The undercloud backup playbook was using mistral to pull the mysql root
password from the available environment. While this works, its not needed
because the authoratative source is already in the deployment users home
folder. This change removes the use of the mistral cli calls, it will now
read the generated password file from the deployers home folder. The
playbook will read from the `tripleo-undercloud-passwords.yaml` file
first, if there are any issues with that file it will fallback to
`undercloud-passwords.conf`.

This removes our usage of mistral and speeds up the total playbook
runtime.

Story: 2007414
Task: 39060

Change-Id: I8bc3207129b60fca6e3205106bb967e414ce4984
Signed-off-by: Kevin Carter <kecarter@redhat.com>
This commit is contained in:
Kevin Carter 2020-03-13 16:05:22 -05:00
parent a3ebb9be72
commit a9ce6766e9
No known key found for this signature in database
GPG Key ID: CE94BD890A47B20A
1 changed files with 29 additions and 9 deletions

View File

@ -33,6 +33,14 @@
- "{{ tmpdir.path }}/"
pre_tasks:
- name: Set local connection user facts
set_fact:
ansible_home: "{{ lookup('env', 'HOME') }}"
ansible_user: "{{ lookup('env', 'USER') }}"
run_once: true
when:
- (tripleo_target_host is defined) | ternary('ssh', 'local') == 'local'
# Action to know if there is enough available space
# to run the Undercloud backup
- name: Get free space
@ -66,14 +74,21 @@
notify:
- cleanup the backup
# The Undercloud database password for the root
# user is stored in a Mistral environment, we
# need the password in order to run the database dump
- name: get_database_credentials
shell: |-
set -o pipefail
mistral environment-get tripleo.undercloud-config -f json | jq -r ".Variables" | jq -r ".undercloud_db_password"
register: undercloud_db_password
- name: Mysql root password block
block:
- name: Read tripleo password file
slurp:
src: "{{ ansible_home }}/tripleo-undercloud-passwords.yaml"
register: tripleo_undercloud_passwords
no_log: true
- name: Set mysql root password
set_fact:
MysqlRootPassword: "{{ (tripleo_undercloud_passwords['content'] | b64decode | from_yaml)['parameter_defaults']['MysqlRootPassword'] }}"
rescue:
- name: Set mysql root password (fallback)
set_fact:
MysqlRootPassword: "{{ lookup('ini', 'undercloud_mysql_root_password section=auth file=' ~ ansible_home ~ '/undercloud-passwords.conf') }}"
- name: Create the names for the temporary backup files
set_fact:
@ -87,7 +102,12 @@
become: true
shell: |-
set -o pipefail
podman exec -i mysql mysqldump -u root -p{{ undercloud_db_password.stdout }} --opt --all-databases | gzip > {{ db_path }}
podman exec -i mysql mysqldump \
-u root \
-p{{ MysqlRootPassword }} \
--opt \
--all-databases | gzip > {{ db_path }}
no_log: true
- name: Backup the filesystem
become: true