Use configured passwords

The tripleo deploy command automatically loads passwords from
tripleo-<stackname>-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
(cherry picked from commit 778351abe6)
This commit is contained in:
Alex Schultz 2019-12-03 17:01:57 -07:00
parent 467967ab9d
commit d24b159f9b
2 changed files with 19 additions and 2 deletions

View File

@ -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)

View File

@ -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-<stack name>-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.