tripleo deploy: Use Standalone role by default

The tripleo deploy command is designed as a generic command to set up
a standalone deployment. This change ensures the command uses
the standalone by default instead of partially using undercloud and
undercloud install commands override the role name properly.

This change also introduces the option to enable preflight validation.
The validation is disabled by default, to be consistent with inflight
validation, and can be enabled by the --preflight-validation option.

Depends-on: https://review.opendev.org/849607
Change-Id: Ica27ebb06c4d078d6f34a7f70bd0073554554e63
This commit is contained in:
Takashi Kajinami 2022-08-08 16:53:14 +09:00
parent aa8618da4f
commit ad1f50f21c
7 changed files with 72 additions and 28 deletions

View File

@ -0,0 +1,6 @@
---
upgrade:
- |
The ``openstack tripleo deploy`` command no longer executes the preflight
validations by default. The ``--preflight-validation`` option should be
added to enable the validations.

View File

@ -25,6 +25,7 @@ TRIPLEO_HEAT_TEMPLATES = "/usr/share/openstack-tripleo-heat-templates/"
OVERCLOUD_YAML_NAME = "overcloud.yaml"
OVERCLOUD_ROLES_FILE = "roles_data.yaml"
UNDERCLOUD_ROLES_FILE = "roles_data_undercloud.yaml"
STANDALONE_ROLES_FILE = "roles_data_standalone.yaml"
STANDALONE_EPHEMERAL_STACK_VSTATE = '/var/lib/tripleo-heat-installer'
UNDERCLOUD_LOG_FILE = "install-undercloud.log"
OVERCLOUD_NETWORKS_FILE = "network_data_default.yaml"

View File

@ -62,7 +62,8 @@ class TestDeployUndercloud(TestPluginV1):
@mock.patch('tripleoclient.utils.check_hostname')
def test_run_preflight_checks(self, mock_check_hostname, mock_uc):
parsed_args = self.check_parser(self.cmd,
['--local-ip', '127.0.0.1/8'], [])
['--local-ip', '127.0.0.1/8',
'--preflight-validations'], [])
mock_uc.return_value = False
self.cmd._run_preflight_checks(parsed_args)
@ -74,7 +75,8 @@ class TestDeployUndercloud(TestPluginV1):
mock_uc):
parsed_args = self.check_parser(self.cmd,
['--local-ip', '127.0.0.1/8',
'--output-only'], [])
'--output-only',
'--preflight-validations'], [])
mock_uc.return_value = False
self.cmd._run_preflight_checks(parsed_args)
@ -82,10 +84,11 @@ class TestDeployUndercloud(TestPluginV1):
@mock.patch('tripleoclient.v1.tripleo_deploy.Deploy._is_undercloud_deploy')
@mock.patch('tripleoclient.utils.check_hostname')
def test_run_preflight_checks_undercloud(self, mock_check_hostname,
mock_uc):
def test_run_preflight_checks_disabled(self, mock_check_hostname,
mock_uc):
parsed_args = self.check_parser(self.cmd,
['--local-ip', '127.0.0.1/8'], [])
['--local-ip', '127.0.0.1/8'],
[])
mock_uc.return_value = True
self.cmd._run_preflight_checks(parsed_args)
@ -98,7 +101,7 @@ class TestDeployUndercloud(TestPluginV1):
roles_file = self.cmd._get_roles_file_path(parsed_args)
self.assertEqual(roles_file,
'/usr/share/openstack-tripleo-heat-templates/'
'roles_data_undercloud.yaml')
'roles_data_standalone.yaml')
def test_get_roles_file_path_custom_file(self):
parsed_args = self.check_parser(self.cmd,
@ -118,7 +121,7 @@ class TestDeployUndercloud(TestPluginV1):
pprint.pprint(parsed_args)
roles_file = self.cmd._get_roles_file_path(parsed_args)
self.assertEqual(roles_file,
'/tmp/thtroot/roles_data_undercloud.yaml')
'/tmp/thtroot/roles_data_standalone.yaml')
def test_get_networks_file_path(self):
parsed_args = self.check_parser(self.cmd,
@ -161,7 +164,7 @@ class TestDeployUndercloud(TestPluginV1):
self.assertEqual(
self.cmd._get_primary_role_name(parsed_args.roles_file,
parsed_args.templates),
'Undercloud')
'Standalone')
@mock.patch('tripleoclient.utils.fetch_roles_file')
def test_get_primary_role_name_no_primary(self, mock_data):
@ -228,12 +231,12 @@ class TestDeployUndercloud(TestPluginV1):
mock_exists, mock_chmod, mock_user):
pw_dict = {"GeneratedPassword": 123, "LegacyPass": "override me"}
t_pw_conf_path = os.path.join(
self.temp_homedir, 'tripleo-undercloud-passwords.yaml')
self.temp_homedir, 'tripleo-standalone-passwords.yaml')
mock_pw.return_value = pw_dict
old_pw_file = os.path.join(constants.CLOUD_HOME_DIR,
'tripleo-undercloud-passwords.yaml')
'tripleo-standalone-passwords.yaml')
def mock_file_exists(file_name):
return not file_name == old_pw_file

View File

@ -78,6 +78,8 @@ class TestUndercloudInstall(TestPluginV1):
'undercloud', '--local-domain=localdomain',
'--local-ip=192.168.24.1/24',
'--templates=/usr/share/openstack-tripleo-heat-templates/',
'--roles-file=/usr/share/openstack-tripleo-heat-templates/'
'roles_data_undercloud.yaml',
'--networks-file=/usr/share/openstack-tripleo-heat-templates/'
'network_data_undercloud.yaml',
'--heat-native', '-e',
@ -133,6 +135,8 @@ class TestUndercloudInstall(TestPluginV1):
'undercloud', '--local-domain=localdomain',
'--local-ip=192.168.24.1/24',
'--templates=/usr/share/openstack-tripleo-heat-templates/',
'--roles-file=/usr/share/openstack-tripleo-heat-templates/'
'roles_data_undercloud.yaml',
'--networks-file=/usr/share/openstack-tripleo-heat-templates/'
'network_data_undercloud.yaml',
'--heat-native', '-e',
@ -345,6 +349,8 @@ class TestUndercloudInstall(TestPluginV1):
'undercloud', '--local-domain=localdomain',
'--local-ip=192.168.24.1/24',
'--templates=/usr/share/openstack-tripleo-heat-templates/',
'--roles-file=/usr/share/openstack-tripleo-heat-templates/'
'roles_data_undercloud.yaml',
'--networks-file=/usr/share/openstack-tripleo-heat-templates/'
'network_data_undercloud.yaml',
'--heat-native', '-e',
@ -408,6 +414,8 @@ class TestUndercloudInstall(TestPluginV1):
'undercloud', '--local-domain=localdomain',
'--local-ip=192.168.24.1/24',
'--templates=/usr/share/openstack-tripleo-heat-templates/',
'--roles-file=/usr/share/openstack-tripleo-heat-templates/'
'roles_data_undercloud.yaml',
'--networks-file=/usr/share/openstack-tripleo-heat-templates/'
'network_data_undercloud.yaml',
'--heat-native', '-e',
@ -464,6 +472,8 @@ class TestUndercloudInstall(TestPluginV1):
'undercloud', '--local-domain=localdomain',
'--local-ip=192.168.24.1/24',
'--templates=/usr/share/openstack-tripleo-heat-templates/',
'--roles-file=/usr/share/openstack-tripleo-heat-templates/'
'roles_data_undercloud.yaml',
'--networks-file=/usr/share/openstack-tripleo-heat-templates/'
'network_data_undercloud.yaml',
'--heat-native', '-e',
@ -545,6 +555,8 @@ class TestUndercloudUpgrade(TestPluginV1):
'undercloud', '--local-domain=localdomain',
'--local-ip=192.168.24.1/24',
'--templates=/usr/share/openstack-tripleo-heat-templates/',
'--roles-file=/usr/share/openstack-tripleo-heat-templates/'
'roles_data_undercloud.yaml',
'--networks-file=/usr/share/openstack-tripleo-heat-templates/'
'network_data_undercloud.yaml',
'--upgrade', '-e',
@ -630,6 +642,8 @@ class TestUndercloudUpgrade(TestPluginV1):
'undercloud', '--local-domain=localdomain',
'--local-ip=192.168.24.1/24',
'--templates=/usr/share/openstack-tripleo-heat-templates/',
'--roles-file=/usr/share/openstack-tripleo-heat-templates/'
'roles_data_undercloud.yaml',
'--networks-file=/usr/share/openstack-tripleo-heat-templates/'
'network_data_undercloud.yaml',
'--upgrade', '-e',
@ -690,6 +704,8 @@ class TestUndercloudUpgrade(TestPluginV1):
'undercloud', '--local-domain=localdomain',
'--local-ip=192.168.24.1/24',
'--templates=/usr/share/openstack-tripleo-heat-templates/',
'--roles-file=/usr/share/openstack-tripleo-heat-templates/'
'roles_data_undercloud.yaml',
'--networks-file=/usr/share/openstack-tripleo-heat-templates/'
'network_data_undercloud.yaml',
'--upgrade', '-e',
@ -749,6 +765,8 @@ class TestUndercloudUpgrade(TestPluginV1):
'undercloud', '--local-domain=localdomain',
'--local-ip=192.168.24.1/24',
'--templates=/usr/share/openstack-tripleo-heat-templates/',
'--roles-file=/usr/share/openstack-tripleo-heat-templates/'
'roles_data_undercloud.yaml',
'--networks-file=/usr/share/openstack-tripleo-heat-templates/'
'network_data_undercloud.yaml',
'--upgrade', '-e',
@ -809,6 +827,8 @@ class TestUndercloudUpgrade(TestPluginV1):
'undercloud', '--local-domain=localdomain',
'--local-ip=192.168.24.1/24',
'--templates=/usr/share/openstack-tripleo-heat-templates/',
'--roles-file=/usr/share/openstack-tripleo-heat-templates/'
'roles_data_undercloud.yaml',
'--networks-file=/usr/share/openstack-tripleo-heat-templates/'
'network_data_undercloud.yaml',
'-y', '--upgrade', '-e',
@ -872,6 +892,8 @@ class TestUndercloudUpgrade(TestPluginV1):
'undercloud', '--local-domain=localdomain',
'--local-ip=192.168.24.1/24',
'--templates=/usr/share/openstack-tripleo-heat-templates/',
'--roles-file=/usr/share/openstack-tripleo-heat-templates/'
'roles_data_undercloud.yaml',
'--networks-file=/usr/share/openstack-tripleo-heat-templates/'
'network_data_undercloud.yaml',
'--upgrade', '-e',

View File

@ -45,13 +45,11 @@ class GenerateAnsibleConfig(command.Command):
help=_('User who executes the tripleo config generate command. '
'Defaults to stack.')
)
# TODO(bogdando): find a better UNDERCLOUD_OUTPUT_DIR constant name
# Add more params as far as the imported ansible actions support it
parser.add_argument('--output-dir',
dest='output_dir',
help=_("Directory to output ansible.cfg and "
"ansible.log files."),
default=constants.UNDERCLOUD_OUTPUT_DIR)
default=constants.CLOUD_HOME_DIR)
return parser

View File

@ -113,8 +113,8 @@ class Deploy(command.Command):
:param parsed_args: parsed arguments from the cli
"""
# we skip preflight checks for output only and undercloud
if parsed_args.output_only or self._is_undercloud_deploy(parsed_args):
# we skip preflight checks for output only
if parsed_args.output_only or not parsed_args.preflight:
return
# in standalone we don't want to fixup the /etc/hosts as we'll be
@ -161,7 +161,7 @@ class Deploy(command.Command):
"""Return roles_file for the deployment"""
if not parsed_args.roles_file:
roles_file = os.path.join(parsed_args.templates,
constants.UNDERCLOUD_ROLES_FILE)
constants.STANDALONE_ROLES_FILE)
else:
roles_file = parsed_args.roles_file
return roles_file
@ -178,7 +178,7 @@ class Deploy(command.Command):
roles_data = utils.fetch_roles_file(
roles_file_path, templates)
if not roles_data:
return 'Undercloud'
return 'Standalone'
for r in roles_data:
if 'tags' in r and 'primary' in r['tags']:
@ -191,7 +191,7 @@ class Deploy(command.Command):
"""Creates temporary working directories"""
utils.makedirs(constants.STANDALONE_EPHEMERAL_STACK_VSTATE)
def _create_working_dirs(self, stack_name='undercloud'):
def _create_working_dirs(self, stack_name='standalone'):
"""Creates temporary working directories"""
if self.output_dir:
utils.makedirs(self.output_dir)
@ -208,7 +208,7 @@ class Deploy(command.Command):
prefix=stack_name + '-ansible-', dir=self.output_dir)
def _populate_templates_dir(self, source_templates_dir,
stack_name='undercloud'):
stack_name='standalone'):
"""Creates template dir with templates
* Copy --templates content into a working dir
@ -256,7 +256,7 @@ class Deploy(command.Command):
constants.PUPPET_BASE)
def _update_passwords_env(self, output_dir, user, passwords=None,
stack_name='undercloud'):
stack_name='standalone'):
old_pw_file = os.path.join(constants.CLOUD_HOME_DIR,
'tripleo-' + stack_name + '-passwords.yaml')
pw_file = os.path.join(output_dir,
@ -317,8 +317,8 @@ class Deploy(command.Command):
return data
def _generate_portmap_parameters(self, ip_addr, ip_nw, ctlplane_vip_addr,
public_vip_addr, stack_name='Undercloud',
role_name='Undercloud'):
public_vip_addr, stack_name='standalone',
role_name='Standalone'):
hostname = utils.get_short_hostname()
# in order for deployed server network information to match correctly,
@ -851,7 +851,7 @@ class Deploy(command.Command):
'Roles file, overrides the default %s in the t-h-t templates '
'directory used for deployment. May be an '
'absolute path or the path relative to the templates dir.'
) % constants.UNDERCLOUD_ROLES_FILE
) % constants.STANDALONE_ROLES_FILE
)
parser.add_argument(
'--networks-file', '-n', dest='networks_file',
@ -917,18 +917,18 @@ class Deploy(command.Command):
parser.add_argument(
'--local-ip', metavar='<LOCAL_IP>',
dest='local_ip',
help=_('Local IP/CIDR for undercloud traffic. Required.')
help=_('Local IP/CIDR for standalone traffic. Required.')
)
parser.add_argument(
'--control-virtual-ip', metavar='<CONTROL_VIRTUAL_IP>',
dest='control_virtual_ip',
help=_('Control plane VIP. This allows the undercloud installer '
help=_('Control plane VIP. This allows the standalone installer '
'to configure a custom VIP on the control plane.')
)
parser.add_argument(
'--public-virtual-ip', metavar='<PUBLIC_VIRTUAL_IP>',
dest='public_virtual_ip',
help=_('Public nw VIP. This allows the undercloud installer '
help=_('Public nw VIP. This allows the standalone installer '
'to configure a custom VIP on the public (external) NW.')
)
parser.add_argument(
@ -968,6 +968,14 @@ class Deploy(command.Command):
'openstack stack list\n'
'where 8006 is the port specified by --heat-api-port.')
)
parser.add_argument(
'--preflight-validations',
action='store_true',
default=False,
dest='preflight',
help=_('Activate pre-flight validations before starting '
'the actual deployment process.')
)
parser.add_argument(
'--inflight-validations',
action='store_true',
@ -1040,7 +1048,7 @@ class Deploy(command.Command):
def _process_hieradata_overrides(self, override_file=None,
tripleo_role_name='Standalone',
stack_name='undercloud'):
stack_name='standalone'):
"""Count in hiera data overrides including legacy formats
Return a file name that points to processed hiera data overrides file
@ -1071,7 +1079,7 @@ class Deploy(command.Command):
self._create_working_dirs(stack_name)
# NOTE(bogdando): In t-h-t, hiera data should come in wrapped as
# {parameter_defaults: {UndercloudExtraConfig: ... }}
# {parameter_defaults: {StandaloneExtraConfig: ... }}
extra_config_var = '%sExtraConfig' % tripleo_role_name
if (extra_config_var not in hiera_data.get('parameter_defaults', {})):
hiera_override_file = os.path.join(
@ -1112,9 +1120,11 @@ class Deploy(command.Command):
def _standalone_deploy(self, parsed_args):
extra_env_var = dict()
if self._is_undercloud_deploy(parsed_args):
extra_env_var['ANSIBLE_LOG_PATH'] = os.path.join(
parsed_args.output_dir, constants.UNDERCLOUD_LOG_FILE)
if not parsed_args.local_ip:
msg = _('Please set --local-ip to the correct '
'ipaddress/cidr for this machine.')
@ -1138,6 +1148,7 @@ class Deploy(command.Command):
parsed_args.stack)
self.output_dir = os.path.abspath(output_dir)
self._create_working_dirs(parsed_args.stack.lower())
# The state that needs to be persisted between serial deployments
# and cannot be contained in ephemeral heat stacks or working dirs

View File

@ -541,6 +541,9 @@ def prepare_undercloud_deploy(upgrade=False, no_validations=True,
if CONF.get('roles_file'):
deploy_args.append('--roles-file=%s' % CONF['roles_file'])
else:
deploy_args.append('--roles-file=%s' % os.path.join(
tht_templates, constants.UNDERCLOUD_ROLES_FILE))
networks_file = (CONF.get('networks_file') or
os.path.join(tht_templates,