Add new option for setup-only
This change implements the ability to run all of the required setup tasks to enable manual playbook execution. When the option is invoked, the following workflows will be run: * Generate the new Ansible content * Downlad the Ansible content * SSH key validation and application to overcloud nodes This new option allows us to retain the current logic of stack-only which will ensure legacy workflows are not interupted while also enabling a more ansible centric user experience. rhbz: 1873246 Change-Id: I3c0466aeed8cd7d2248c0d769b24821110a0e0a5 Signed-off-by: Kevin Carter <kecarter@redhat.com>
This commit is contained in:
4 files changed
+138
-6
No files matched your search
@@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- The --setup-only option has been added to facilitate the generation
|
||||
of ansible content and ensure the environment is accessible via the
|
||||
current stack.
|
||||
@@ -1178,6 +1178,45 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
||||
)
|
||||
mock_copy.assert_called_once()
|
||||
|
||||
@mock.patch('tripleoclient.utils.get_rc_params', autospec=True)
|
||||
@mock.patch('tripleoclient.utils.copy_clouds_yaml')
|
||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||
'_get_undercloud_host_entry', autospec=True,
|
||||
return_value='192.168.0.1 uc.ctlplane.localhost uc.ctlplane')
|
||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||
'_deploy_tripleo_heat_templates_tmpdir', autospec=True)
|
||||
def test_config_download_setup_only(
|
||||
self, mock_deploy_tmpdir,
|
||||
mock_get_undercloud_host_entry,
|
||||
mock_copy, mock_rc_params):
|
||||
fixture = deployment.DeploymentWorkflowFixture()
|
||||
self.useFixture(fixture)
|
||||
utils_fixture = deployment.UtilsOvercloudFixture()
|
||||
self.useFixture(utils_fixture)
|
||||
clients = self.app.client_manager
|
||||
orchestration_client = clients.orchestration
|
||||
orchestration_client.stacks.get.return_value = fakes.create_tht_stack()
|
||||
|
||||
arglist = ['--templates', '--config-download', '--setup-only']
|
||||
verifylist = [
|
||||
('templates', '/usr/share/openstack-tripleo-heat-templates/'),
|
||||
('config_download', True),
|
||||
('setup_only', True)
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
mock_rc_params.return_value = {'password': 'password',
|
||||
'region': 'region1'}
|
||||
self.cmd.take_action(parsed_args)
|
||||
self.assertTrue(mock_deploy_tmpdir.called)
|
||||
self.assertTrue(fixture.mock_get_hosts_and_enable_ssh_admin.called)
|
||||
self.assertTrue(fixture.mock_config_download.called)
|
||||
self.assertTrue(fixture.mock_set_deployment_status.called)
|
||||
self.assertEqual(
|
||||
'DEPLOY_SUCCESS',
|
||||
fixture.mock_set_deployment_status.call_args[-1]['status']
|
||||
)
|
||||
mock_copy.assert_called_once()
|
||||
|
||||
@mock.patch('tripleoclient.utils.get_rc_params', autospec=True)
|
||||
@mock.patch('tripleoclient.utils.copy_clouds_yaml')
|
||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||
@@ -1353,8 +1392,8 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
||||
deployment_options={},
|
||||
deployment_timeout=448, # 451 - 3, total time left
|
||||
in_flight_validations=False, limit_hosts=None,
|
||||
skip_tags=None, tags=None, timeout=42, verbosity=3,
|
||||
forks=None)],
|
||||
setup_only=False, skip_tags=None, tags=None, timeout=42,
|
||||
verbosity=3, forks=None)],
|
||||
fixture.mock_config_download.mock_calls)
|
||||
fixture.mock_config_download.assert_called()
|
||||
mock_copy.assert_called_once()
|
||||
|
||||
@@ -971,6 +971,44 @@ class DeployOvercloud(command.Command):
|
||||
'config-download workflow to apply the software '
|
||||
'configuration.')
|
||||
)
|
||||
parser.add_argument(
|
||||
'--setup-only',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help=_('option will automate the setup and download steps '
|
||||
'required to prepare the environment for manual '
|
||||
'ansible execution.')
|
||||
)
|
||||
parser.add_argument(
|
||||
'--config-dir',
|
||||
dest='config_dir',
|
||||
default=os.path.join(
|
||||
constants.CLOUD_HOME_DIR,
|
||||
'tripleo-config'
|
||||
),
|
||||
help=_('The directory where the configuration files will be '
|
||||
'pushed'),
|
||||
)
|
||||
parser.add_argument(
|
||||
'--config-type',
|
||||
dest='config_type',
|
||||
type=list,
|
||||
default=None,
|
||||
help=_('Only used when "--setup-only" is invoked. '
|
||||
'Type of object config to be extract from the deployment, '
|
||||
'defaults to all keys available'),
|
||||
)
|
||||
parser.add_argument(
|
||||
'--no-preserve-config',
|
||||
dest='preserve_config_dir',
|
||||
action='store_false',
|
||||
default=True,
|
||||
help=('Only used when "--setup-only" is invoked. '
|
||||
'If specified, will delete and recreate the --config-dir '
|
||||
'if it already exists. Default is to use the existing dir '
|
||||
'location and overwrite files. Files in --config-dir not '
|
||||
'from the stack will be preserved by default.')
|
||||
)
|
||||
parser.add_argument(
|
||||
'--output-dir',
|
||||
action='store',
|
||||
@@ -1111,7 +1149,7 @@ class DeployOvercloud(command.Command):
|
||||
rcpath = deployment.create_overcloudrc(
|
||||
stack, rc_params, parsed_args.no_proxy)
|
||||
|
||||
if parsed_args.config_download:
|
||||
if parsed_args.config_download or parsed_args.setup_only:
|
||||
self.log.info("Deploying overcloud configuration")
|
||||
deployment.set_deployment_status(
|
||||
clients=self.clients,
|
||||
@@ -1119,7 +1157,8 @@ class DeployOvercloud(command.Command):
|
||||
status='DEPLOYING'
|
||||
)
|
||||
|
||||
if not parsed_args.config_download_only:
|
||||
if not parsed_args.config_download_only and \
|
||||
not parsed_args.setup_only:
|
||||
deployment.get_hosts_and_enable_ssh_admin(
|
||||
stack,
|
||||
parsed_args.overcloud_ssh_network,
|
||||
@@ -1160,8 +1199,43 @@ class DeployOvercloud(command.Command):
|
||||
limit_hosts=utils.playbook_limit_parse(
|
||||
limit_nodes=parsed_args.limit
|
||||
),
|
||||
forks=parsed_args.ansible_forks
|
||||
forks=parsed_args.ansible_forks,
|
||||
setup_only=parsed_args.setup_only
|
||||
)
|
||||
|
||||
if parsed_args.setup_only:
|
||||
# Download config
|
||||
config_dir = os.path.abspath(parsed_args.config_dir)
|
||||
config_type = parsed_args.config_type
|
||||
preserve_config_dir = parsed_args.preserve_config_dir
|
||||
extra_vars = {
|
||||
'plan': stack.stack_name,
|
||||
'config_dir': config_dir,
|
||||
'preserve_config': preserve_config_dir
|
||||
}
|
||||
if parsed_args.config_type:
|
||||
extra_vars['config_type'] = config_type
|
||||
|
||||
with utils.TempDirs() as tmp:
|
||||
utils.run_ansible_playbook(
|
||||
playbook='cli-config-download-export.yaml',
|
||||
inventory='localhost,',
|
||||
workdir=tmp,
|
||||
playbook_dir=constants.ANSIBLE_TRIPLEO_PLAYBOOKS,
|
||||
verbosity=utils.playbook_verbosity(self=self),
|
||||
extra_vars=extra_vars
|
||||
)
|
||||
|
||||
# Run admin authorize
|
||||
deployment.get_hosts_and_enable_ssh_admin(
|
||||
stack,
|
||||
parsed_args.overcloud_ssh_network,
|
||||
parsed_args.overcloud_ssh_user,
|
||||
self.get_key_pair(parsed_args),
|
||||
parsed_args.overcloud_ssh_port_timeout,
|
||||
verbosity=utils.playbook_verbosity(self=self)
|
||||
)
|
||||
|
||||
deployment.set_deployment_status(
|
||||
clients=self.clients,
|
||||
plan=stack.stack_name,
|
||||
|
||||
@@ -271,7 +271,7 @@ def config_download(log, clients, stack, ssh_network='ctlplane',
|
||||
ansible_playbook_name='deploy_steps_playbook.yaml',
|
||||
limit_hosts=None, extra_vars=None, inventory_path=None,
|
||||
ssh_user='tripleo-admin', tags=None, skip_tags=None,
|
||||
deployment_timeout=None, forks=None):
|
||||
deployment_timeout=None, forks=None, setup_only=False):
|
||||
"""Run config download.
|
||||
|
||||
:param log: Logging object
|
||||
@@ -330,6 +330,9 @@ def config_download(log, clients, stack, ssh_network='ctlplane',
|
||||
:param deployment_timeout: Deployment timeout in minutes.
|
||||
:type deployment_timeout: Integer
|
||||
|
||||
:param setup_only: Only generates the config-download directory
|
||||
without executing the actual playbooks.
|
||||
:type setup_only: Boolean
|
||||
"""
|
||||
|
||||
def _log_and_print(message, logger, level='info', print_msg=True):
|
||||
@@ -417,6 +420,17 @@ def config_download(log, clients, stack, ssh_network='ctlplane',
|
||||
}
|
||||
)
|
||||
|
||||
# If we only want to generate config-download directory, we can quit here.
|
||||
if setup_only:
|
||||
_log_and_print(
|
||||
message='Overcloud configuration generated for stack: {}'.format(
|
||||
stack.stack_name
|
||||
),
|
||||
logger=log,
|
||||
print_msg=(verbosity == 0)
|
||||
)
|
||||
return
|
||||
|
||||
_log_and_print(
|
||||
message='Executing deployment playbook for stack: {}'.format(
|
||||
stack.stack_name
|
||||
|
||||
Reference in new issue
Block a user