From 166803d05fe05899c8613c96f627cda4f2a2aa26 Mon Sep 17 00:00:00 2001
From: Carlos Camacho <ccamacho@redhat.com>
Date: Tue, 22 Jan 2019 12:50:01 +0100
Subject: [PATCH] Include the DB password in a Mistral environment for creating
 backups and restores

We need to include also the Undercloud DB in a Mistral
environment to be able to create the DB backup from the CLI.

Now, we do this using python and THT but we didn't include it.

Change-Id: If503e733b103a34ae5639eb56dfae05f9783d59a
Closes-Bug: 1812839
---
 extraconfig/post_deploy/undercloud_post.py   | 10 ++++++----
 extraconfig/post_deploy/undercloud_post.yaml |  5 +++++
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/extraconfig/post_deploy/undercloud_post.py b/extraconfig/post_deploy/undercloud_post.py
index dc0d107539..e67ecc13a3 100755
--- a/extraconfig/post_deploy/undercloud_post.py
+++ b/extraconfig/post_deploy/undercloud_post.py
@@ -112,12 +112,14 @@ def _create_logging_cron(mistral):
     print('INFO: Undercloud post - Cron triggers configured successfully.')
 
 
-def _store_snmp_password_in_mistral_env(mistral):
-    """ Store the SNMP password in a mistral environment """
+def _store_passwords_in_mistral_env(mistral):
+    """ Store required passwords in a mistral environment """
     env_name = 'tripleo.undercloud-config'
     config_data = {
         'undercloud_ceilometer_snmpd_password':
-            CONF['snmp_readonly_user_password']
+            CONF['snmp_readonly_user_password'],
+        'undercloud_db_password':
+            CONF['undercloud_db_password']
     }
     try:
         mistral.environments.get(env_name).variables
@@ -179,7 +181,7 @@ try:
                                        session=sdk.session)
         _configure_wrokbooks_and_workflows(mistral)
         _create_logging_cron(mistral)
-        _store_snmp_password_in_mistral_env(mistral)
+        _store_passwords_in_mistral_env(mistral)
         _create_default_plan(mistral)
         if tripleo_validations_enabled:
             _prepare_ssh_environment(mistral)
diff --git a/extraconfig/post_deploy/undercloud_post.yaml b/extraconfig/post_deploy/undercloud_post.yaml
index 8fbd568eda..b0db158323 100644
--- a/extraconfig/post_deploy/undercloud_post.yaml
+++ b/extraconfig/post_deploy/undercloud_post.yaml
@@ -37,6 +37,10 @@ parameters:
     description: The user password for SNMPd with readonly rights running on all Overcloud nodes
     type: string
     hidden: true
+  MysqlRootPassword:
+    type: string
+    hidden: true
+    default: ''
   DnsServers:
     default: []
     description: >
@@ -212,6 +216,7 @@ resources:
                 cloud_name: {get_param: UndercloudCloudName}
                 home_dir: {get_param: UndercloudHomeDir}
                 snmp_readonly_user_password: {get_param: SnmpdReadonlyUserPassword}
+                undercloud_db_password: {get_param: MysqlRootPassword}
 
 
   UndercloudCtlplaneNetworkConfig: