Introduce --inflight-validations for standalone / undercloud

Like we do for the overcloud, add the --inflight-validations option,
disabled by default. Disable by default, we'll skip the
"opendev-validations" Ansible tags when running the playbooks.

Related-Bug: #1844446
Change-Id: Ia37b3d4cc657d994b6a63412d5792930d54a14dd
This commit is contained in:
Emilien Macchi 2019-09-18 12:15:39 -04:00
parent 89be0d17c5
commit 64af3ae1fb
3 changed files with 32 additions and 13 deletions

View File

@ -851,8 +851,7 @@ class TestDeployUndercloud(TestPluginV1):
@mock.patch('os.execvp')
def test_launch_ansible_with_args(self, mock_execvp, mock_chdir, mock_run):
args = ['deploy_steps_playbook.yaml', '--skip-tags',
'validation']
args = ['--skip-tags', 'validation']
self.cmd._launch_ansible('/tmp', args, operation='deploy')
mock_chdir.assert_called_once()
mock_run.assert_called_once_with(self.cmd.log, [

View File

@ -899,14 +899,17 @@ class Deploy(command.Command):
return output
# Never returns, calls exec()
def _launch_ansible(self, ansible_dir, list_args=None, operation="deploy"):
def _launch_ansible(self, ansible_dir, extra_args=None,
operation="deploy"):
if list_args is None:
if operation not in constants.DEPLOY_ANSIBLE_ACTIONS.keys():
self.log.error(_('Operation %s is not allowed') % operation)
raise exceptions.DeploymentError('Invalid operation to run in '
'ansible.')
list_args = constants.DEPLOY_ANSIBLE_ACTIONS[operation].split()
if operation not in constants.DEPLOY_ANSIBLE_ACTIONS.keys():
self.log.error(_('Operation %s is not allowed') % operation)
raise exceptions.DeploymentError('Invalid operation to run in '
'ansible.')
list_args = constants.DEPLOY_ANSIBLE_ACTIONS[operation].split()
if extra_args:
list_args.extend(extra_args)
self.log.warning(_('** Running ansible %s tasks **') % operation)
os.chdir(ansible_dir)
@ -1089,6 +1092,16 @@ class Deploy(command.Command):
'openstack stack list\n '
'where 8006 is the port specified by --heat-api-port.')
)
parser.add_argument(
'--inflight-validations',
action='store_true',
default=False,
dest='inflight',
help=_('Activate in-flight validations during the deploy. '
'In-flight validations provide a robust way to ensure '
'deployed services are running right after their '
'activation. Defaults to False.')
)
stack_action_group = parser.add_mutually_exclusive_group()
@ -1287,6 +1300,9 @@ class Deploy(command.Command):
_('Using the existing %s for deployment') % ansible_config)
shutil.copy(ansible_config, self.ansible_dir)
extra_args = []
if not parsed_args.inflight:
extra_args = ['--skip-tags', 'opendev-validation']
# Kill heat, we're done with it now.
if not parsed_args.keep_running:
self._kill_heat(parsed_args)
@ -1294,7 +1310,8 @@ class Deploy(command.Command):
if parsed_args.upgrade:
# Run Upgrade tasks before the deployment
rc = self._launch_ansible(self.ansible_dir,
operation='upgrade')
operation='upgrade',
extra_args=extra_args)
if rc != 0:
raise exceptions.DeploymentError('Upgrade failed')
rc = self._launch_ansible(self.ansible_dir)
@ -1303,12 +1320,14 @@ class Deploy(command.Command):
if parsed_args.upgrade:
# Run Post Upgrade tasks after the deployment
rc = self._launch_ansible(self.ansible_dir,
operation='post-upgrade')
operation='post-upgrade',
extra_args=extra_args)
if rc != 0:
raise exceptions.DeploymentError('Post Upgrade failed')
# Run Online Upgrade tasks after the deployment
rc = self._launch_ansible(self.ansible_dir,
operation='online-upgrade')
operation='online-upgrade',
extra_args=extra_args)
if rc != 0:
raise exceptions.DeploymentError(
'Online Upgrade failed')

View File

@ -753,7 +753,8 @@ def prepare_undercloud_deploy(upgrade=False, no_validations=False,
utils.ansible_symlink()
undercloud_preflight.check(verbose_level, upgrade)
deploy_args += ['-e', os.path.join(
tht_templates, "environments/tripleo-validations.yaml")]
tht_templates, "environments/tripleo-validations.yaml"),
'--inflight-validations']
if CONF.get('custom_env_files'):
for custom_file in CONF['custom_env_files']: