Manage legacy OS::TripleO::RandomString resources in constants
Instead of generated OS::TripleO::RandomString from the Heat Template, make the password generated among other passwords so we can re-use the data across undercloud-container re-install or updates, when Heat and environments are re-generated. Note: it keeps the same password constraints as it was in THT. Co-Authored-By: Dan Prince <dprince@redhat.com> Co-Authored-By: Martin André <m.andre@redhat.com> Change-Id: I9da2220ce5635d06c2ca9a21bd07eb2b6ee50aaa Related-Bug: #1736779
This commit is contained in:
parent
9834382b25
commit
5dc478db69
8
releasenotes/notes/passwords-79661a3f27a33528.yaml
Normal file
8
releasenotes/notes/passwords-79661a3f27a33528.yaml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
HeatAuthEncryptionKey, HorizonSecret, MysqlRootPassword, PcsdPassword
|
||||||
|
and RabbitCookie are now generated by tripleo-common among other
|
||||||
|
passwords managed by TripleO. If existing version of these parameters
|
||||||
|
have been generated by the Heat stack we first harvest those before
|
||||||
|
generating new version.
|
@ -202,6 +202,18 @@ class GeneratePasswordsAction(base.TripleOAction):
|
|||||||
try:
|
try:
|
||||||
stack_env = heat.stacks.environment(
|
stack_env = heat.stacks.environment(
|
||||||
stack_id=self.container)
|
stack_id=self.container)
|
||||||
|
|
||||||
|
# legacy heat resource names from overcloud.yaml
|
||||||
|
# We don't modify these to avoid changing defaults
|
||||||
|
for pw_res in constants.LEGACY_HEAT_PASSWORD_RESOURCE_NAMES:
|
||||||
|
try:
|
||||||
|
res = heat.resources.get(self.container, pw_res)
|
||||||
|
param_defaults = stack_env.get('parameter_defaults', {})
|
||||||
|
param_defaults[pw_res] = res.attributes['value']
|
||||||
|
except heat_exc.HTTPNotFound:
|
||||||
|
LOG.debug('Heat resouce not found: %s' % pw_res)
|
||||||
|
pass
|
||||||
|
|
||||||
except heat_exc.HTTPNotFound:
|
except heat_exc.HTTPNotFound:
|
||||||
stack_env = None
|
stack_env = None
|
||||||
|
|
||||||
|
@ -82,8 +82,10 @@ PASSWORD_PARAMETER_NAMES = (
|
|||||||
'GlancePassword',
|
'GlancePassword',
|
||||||
'GnocchiPassword',
|
'GnocchiPassword',
|
||||||
'HAProxyStatsPassword',
|
'HAProxyStatsPassword',
|
||||||
|
'HeatAuthEncryptionKey',
|
||||||
'HeatPassword',
|
'HeatPassword',
|
||||||
'HeatStackDomainAdminPassword',
|
'HeatStackDomainAdminPassword',
|
||||||
|
'HorizonSecret',
|
||||||
'IronicPassword',
|
'IronicPassword',
|
||||||
'LibvirtTLSPassword',
|
'LibvirtTLSPassword',
|
||||||
'KeystoneCredential0',
|
'KeystoneCredential0',
|
||||||
@ -94,6 +96,7 @@ PASSWORD_PARAMETER_NAMES = (
|
|||||||
'ManilaPassword',
|
'ManilaPassword',
|
||||||
'MistralPassword',
|
'MistralPassword',
|
||||||
'MysqlClustercheckPassword',
|
'MysqlClustercheckPassword',
|
||||||
|
'MysqlRootPassword',
|
||||||
'NeutronMetadataProxySharedSecret',
|
'NeutronMetadataProxySharedSecret',
|
||||||
'NeutronPassword',
|
'NeutronPassword',
|
||||||
'NovaPassword',
|
'NovaPassword',
|
||||||
@ -103,6 +106,8 @@ PASSWORD_PARAMETER_NAMES = (
|
|||||||
'OctaviaPassword',
|
'OctaviaPassword',
|
||||||
'PacemakerRemoteAuthkey',
|
'PacemakerRemoteAuthkey',
|
||||||
'PankoPassword',
|
'PankoPassword',
|
||||||
|
'PcsdPassword',
|
||||||
|
'RabbitCookie',
|
||||||
'RabbitPassword',
|
'RabbitPassword',
|
||||||
'RedisPassword',
|
'RedisPassword',
|
||||||
'SaharaPassword',
|
'SaharaPassword',
|
||||||
@ -113,6 +118,14 @@ PASSWORD_PARAMETER_NAMES = (
|
|||||||
'TrovePassword',
|
'TrovePassword',
|
||||||
'ZaqarPassword',
|
'ZaqarPassword',
|
||||||
)
|
)
|
||||||
|
# List of legacy resource names from overcloud.yaml
|
||||||
|
LEGACY_HEAT_PASSWORD_RESOURCE_NAMES = (
|
||||||
|
'HeatAuthEncryptionKey',
|
||||||
|
'HorizonSecret',
|
||||||
|
'MysqlRootPassword',
|
||||||
|
'PcsdPassword',
|
||||||
|
'RabbitCookie',
|
||||||
|
)
|
||||||
|
|
||||||
PLAN_NAME_PATTERN = '^[a-zA-Z0-9-]+$'
|
PLAN_NAME_PATTERN = '^[a-zA-Z0-9-]+$'
|
||||||
|
|
||||||
|
@ -31,6 +31,11 @@ _EXISTING_PASSWORDS = {
|
|||||||
'CeilometerMeteringSecret': 'CbHTGK4md4Cc8P8ZyzTns6wry',
|
'CeilometerMeteringSecret': 'CbHTGK4md4Cc8P8ZyzTns6wry',
|
||||||
'ZaqarPassword': 'bbFgCTFbAH8vf9n3xvZCP8aMR',
|
'ZaqarPassword': 'bbFgCTFbAH8vf9n3xvZCP8aMR',
|
||||||
'NovaPassword': '7dZATgVPwD7Ergs9kTTDMCr7F',
|
'NovaPassword': '7dZATgVPwD7Ergs9kTTDMCr7F',
|
||||||
|
'MysqlRootPassword': 'VqJYpEdKks',
|
||||||
|
'RabbitCookie': 'BqJYpEdKksAqJYpEdKks',
|
||||||
|
'HeatAuthEncryptionKey': '9xZXehsKc2HbmFFMKjuqxTJHn',
|
||||||
|
'PcsdPassword': 'KjEzeitus8eu751a',
|
||||||
|
'HorizonSecret': 'mjEzeitus8eu751B',
|
||||||
'NovajoinPassword': '7dZATgVPwD7Ergs9kTTDMCr7F',
|
'NovajoinPassword': '7dZATgVPwD7Ergs9kTTDMCr7F',
|
||||||
'IronicPassword': '4hFDgn9ANeVfuqk84pHpD4ksa',
|
'IronicPassword': '4hFDgn9ANeVfuqk84pHpD4ksa',
|
||||||
'RedisPassword': 'xjj3QZDcUQmU6Q7NzWBHRUhGd',
|
'RedisPassword': 'xjj3QZDcUQmU6Q7NzWBHRUhGd',
|
||||||
@ -419,6 +424,11 @@ class GeneratePasswordsActionTest(base.TestCase):
|
|||||||
mock_orchestration.stacks.environment.return_value = {
|
mock_orchestration.stacks.environment.return_value = {
|
||||||
'parameter_defaults': {}
|
'parameter_defaults': {}
|
||||||
}
|
}
|
||||||
|
mock_resource = mock.MagicMock()
|
||||||
|
mock_resource.attributes = {
|
||||||
|
'value': 'existing_value'
|
||||||
|
}
|
||||||
|
mock_orchestration.resources.get.return_value = mock_resource
|
||||||
mock_get_orchestration_client.return_value = mock_orchestration
|
mock_get_orchestration_client.return_value = mock_orchestration
|
||||||
|
|
||||||
action = parameters.GeneratePasswordsAction()
|
action = parameters.GeneratePasswordsAction()
|
||||||
@ -427,6 +437,14 @@ class GeneratePasswordsActionTest(base.TestCase):
|
|||||||
for password_param_name in constants.PASSWORD_PARAMETER_NAMES:
|
for password_param_name in constants.PASSWORD_PARAMETER_NAMES:
|
||||||
self.assertTrue(password_param_name in result,
|
self.assertTrue(password_param_name in result,
|
||||||
"%s is not in %s" % (password_param_name, result))
|
"%s is not in %s" % (password_param_name, result))
|
||||||
|
|
||||||
|
if password_param_name in \
|
||||||
|
constants.LEGACY_HEAT_PASSWORD_RESOURCE_NAMES:
|
||||||
|
self.assertEqual(result[password_param_name], 'existing_value')
|
||||||
|
else:
|
||||||
|
self.assertNotEqual(result[password_param_name],
|
||||||
|
'existing_value')
|
||||||
|
|
||||||
mock_cache.assert_called_once_with(
|
mock_cache.assert_called_once_with(
|
||||||
mock_ctx,
|
mock_ctx,
|
||||||
"overcloud",
|
"overcloud",
|
||||||
|
@ -75,6 +75,21 @@ def generate_passwords(mistralclient=None, stack_env=None):
|
|||||||
passwords[name] = create_ssh_keypair()
|
passwords[name] = create_ssh_keypair()
|
||||||
elif name == 'BarbicanSimpleCryptoKek':
|
elif name == 'BarbicanSimpleCryptoKek':
|
||||||
passwords[name] = create_keystone_credential()
|
passwords[name] = create_keystone_credential()
|
||||||
|
elif name.startswith("MysqlRootPassword"):
|
||||||
|
passwords[name] = passutils.generate_password(
|
||||||
|
size=10)
|
||||||
|
elif name.startswith("RabbitCookie"):
|
||||||
|
passwords[name] = passutils.generate_password(
|
||||||
|
size=20)
|
||||||
|
elif name.startswith("PcsdPassword"):
|
||||||
|
passwords[name] = passutils.generate_password(
|
||||||
|
size=16)
|
||||||
|
elif name.startswith("HorizonSecret"):
|
||||||
|
passwords[name] = passutils.generate_password(
|
||||||
|
size=10)
|
||||||
|
elif name.startswith("HeatAuthEncryptionKey"):
|
||||||
|
passwords[name] = passutils.generate_password(
|
||||||
|
size=32)
|
||||||
else:
|
else:
|
||||||
passwords[name] = passutils.generate_password(
|
passwords[name] = passutils.generate_password(
|
||||||
size=_MIN_PASSWORD_SIZE)
|
size=_MIN_PASSWORD_SIZE)
|
||||||
|
Loading…
Reference in New Issue
Block a user