From 778351abe687fbaaae59450631a8e461c238e7fe Mon Sep 17 00:00:00 2001 From: Alex Schultz Date: Tue, 3 Dec 2019 17:01:57 -0700 Subject: [PATCH] Use configured passwords The tripleo deploy command automatically loads passwords from tripleo--passwords.yaml. We have a configuration items in the minion configuration to point at the undercloud config. We need to copy the configure file into the correct name to ensure it gets loaded correctly. Change-Id: I0bbda8857473566a9ad18f20af9da8a34dd6ed0f Closes-Bug: #1855010 --- .../tests/v1/undercloud/minion/test_config.py | 6 ++++-- tripleoclient/v1/minion_config.py | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/tripleoclient/tests/v1/undercloud/minion/test_config.py b/tripleoclient/tests/v1/undercloud/minion/test_config.py index 1b9de8612..3667e3acc 100644 --- a/tripleoclient/tests/v1/undercloud/minion/test_config.py +++ b/tripleoclient/tests/v1/undercloud/minion/test_config.py @@ -34,6 +34,7 @@ class TestMinionDeploy(base.TestCase): # set timezone so we don't have to mock it everywhere self.conf.set_default('minion_timezone', 'UTC') + @mock.patch('tripleoclient.v1.minion_config._process_undercloud_passwords') @mock.patch('tripleoclient.v1.undercloud_preflight.minion_check') @mock.patch('tripleoclient.utils.ansible_symlink') @mock.patch('os.path.isdir', return_value=True) @@ -46,7 +47,7 @@ class TestMinionDeploy(base.TestCase): def test_basic_deploy(self, mock_load_config, mock_get_user, mock_write_env, mock_undercloud_output, mock_images_config, mock_isdir, mock_ans_symlink, - mock_check): + mock_check, mock_pass): mock_get_user.return_value = 'foo' cmd = minion_config.prepare_minion_deploy() expected_cmd = ['sudo', '--preserve-env', @@ -99,6 +100,7 @@ class TestMinionDeploy(base.TestCase): env_data, '/home/stack/tripleo-config-generated-env-files/' 'minion_parameters.yaml', {}) + @mock.patch('tripleoclient.v1.minion_config._process_undercloud_passwords') @mock.patch('tripleoclient.v1.undercloud_preflight.minion_check') @mock.patch('tripleoclient.utils.ansible_symlink') @mock.patch('os.path.exists', return_value=True) @@ -111,7 +113,7 @@ class TestMinionDeploy(base.TestCase): def test_configured_deploy(self, mock_load_config, mock_write_env, mock_undercloud_output, mock_images_config, mock_isdir, mock_exists, - mock_ans_symlink, mock_check): + mock_ans_symlink, mock_check, mock_pass): self.conf.set_default('deployment_user', 'bar') self.conf.set_default('enable_heat_engine', False) self.conf.set_default('enable_ironic_conductor', True) diff --git a/tripleoclient/v1/minion_config.py b/tripleoclient/v1/minion_config.py index a9ecdd419..9f26daf42 100644 --- a/tripleoclient/v1/minion_config.py +++ b/tripleoclient/v1/minion_config.py @@ -120,6 +120,16 @@ def _process_undercloud_output(templates_dir, output_file_path): return env_file +def _process_undercloud_passwords(src_file, dest_file): + try: + shutil.copy(os.path.abspath(src_file), dest_file) + except Exception: + msg = _('Cannot copy undercloud password file %(src)s to ' + '%(dest)s') % {'src': src_file, 'dest': dest_file} + LOG.error(msg) + raise exceptions.DeploymentError(msg) + + def prepare_minion_deploy(upgrade=False, no_validations=False, verbose_level=1, yes=False, force_stack_update=False, dry_run=False): @@ -206,6 +216,11 @@ def prepare_minion_deploy(upgrade=False, no_validations=False, tempdir, CONF['minion_undercloud_output_file']) deploy_args += ['-e', output_file] + # copy undercloud password file (the configuration is minion_password_file + # to the place that triple deploy looks for it + # tripleo--passwords.yaml) + _process_undercloud_passwords(CONF['minion_password_file'], + 'tripleo-minion-passwords.yaml') if upgrade: # TODO(aschultz): validate minion upgrade, should be the same as the # undercloud one.