diff --git a/doc/source/administration/overcloud.rst b/doc/source/administration/overcloud.rst index f1ca0d229..6a2aa60c6 100644 --- a/doc/source/administration/overcloud.rst +++ b/doc/source/administration/overcloud.rst @@ -130,6 +130,18 @@ and/or kolla-ansible:: (kayobe) $ kayobe overcloud service upgrade --tags config --kolla-tags keystone +Running Prechecks +================= + +Sometimes it may be useful to run prechecks without deploying services:: + + (kayobe) $ kayobe overcloud service prechecks + +As for other similar commands, it is possible to specify tags for Kayobe and/or +kolla-ansible:: + + (kayobe) $ kayobe overcloud service upgrade --tags config --kolla-tags keystone + Stopping the Overcloud Services =============================== diff --git a/kayobe/cli/commands.py b/kayobe/cli/commands.py index ba1bca569..38afdc6fe 100644 --- a/kayobe/cli/commands.py +++ b/kayobe/cli/commands.py @@ -1293,6 +1293,29 @@ class OvercloudServiceDeployContainers(KollaAnsibleMixin, KayobeAnsibleMixin, extra_vars=extra_vars, limit="overcloud") +class OvercloudServicePrechecks(KollaAnsibleMixin, KayobeAnsibleMixin, + VaultMixin, Command): + """Run prechecks against overcloud services. + + * Configure kolla-ansible. + * Configure overcloud services in kolla-ansible. + * Perform kolla-ansible prechecks to verify the system state for + deployment. + + This can be used in conjunction with the --tags and --kolla-tags arguments + to check specific services. + """ + + def take_action(self, parsed_args): + self.app.LOG.debug("Running overcloud prechecks") + + # First prepare configuration. + self.generate_kolla_ansible_config(parsed_args) + + # Run the kolla-ansible prechecks. + self.run_kolla_ansible_overcloud(parsed_args, "prechecks") + + class OvercloudServiceReconfigure(KollaAnsibleMixin, KayobeAnsibleMixin, VaultMixin, Command): """Reconfigure the overcloud services. diff --git a/kayobe/tests/unit/cli/test_commands.py b/kayobe/tests/unit/cli/test_commands.py index 7d941c650..4e2a0f55b 100644 --- a/kayobe/tests/unit/cli/test_commands.py +++ b/kayobe/tests/unit/cli/test_commands.py @@ -1450,6 +1450,44 @@ class TestCase(unittest.TestCase): ] self.assertEqual(expected_calls, mock_kolla_run.call_args_list) + @mock.patch.object(commands.KayobeAnsibleMixin, + "run_kayobe_playbooks") + @mock.patch.object(commands.KollaAnsibleMixin, + "run_kolla_ansible_overcloud") + def test_overcloud_service_prechecks(self, mock_kolla_run, mock_run): + command = commands.OvercloudServicePrechecks(TestApp(), []) + parser = command.get_parser("test") + parsed_args = parser.parse_args([]) + + result = command.run(parsed_args) + self.assertEqual(0, result) + + expected_calls = [ + mock.call( + mock.ANY, + [utils.get_data_files_path("ansible", "kolla-ansible.yml")], + ignore_limit=True, + tags="config", + ), + mock.call( + mock.ANY, + [ + utils.get_data_files_path("ansible", + "kolla-openstack.yml"), + ], + ignore_limit=True, + ), + ] + self.assertEqual(expected_calls, mock_run.call_args_list) + + expected_calls = [ + mock.call( + mock.ANY, + "prechecks", + ), + ] + self.assertEqual(expected_calls, mock_kolla_run.call_args_list) + @mock.patch.object(commands.KayobeAnsibleMixin, "run_kayobe_playbooks") @mock.patch.object(commands.KollaAnsibleMixin, diff --git a/releasenotes/notes/prechecks-command-a9153f667659c315.yaml b/releasenotes/notes/prechecks-command-a9153f667659c315.yaml new file mode 100644 index 000000000..be7f01773 --- /dev/null +++ b/releasenotes/notes/prechecks-command-a9153f667659c315.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + Adds a new ``kayobe overcloud service prechecks`` command to run Kolla + Ansible prechecks without deploying services. diff --git a/setup.cfg b/setup.cfg index d1344bbd4..282c192e7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -72,6 +72,7 @@ kayobe.cli= overcloud_service_deploy = kayobe.cli.commands:OvercloudServiceDeploy overcloud_service_deploy_containers = kayobe.cli.commands:OvercloudServiceDeployContainers overcloud_service_destroy = kayobe.cli.commands:OvercloudServiceDestroy + overcloud_service_prechecks = kayobe.cli.commands:OvercloudServicePrechecks overcloud_service_reconfigure = kayobe.cli.commands:OvercloudServiceReconfigure overcloud_service_stop = kayobe.cli.commands:OvercloudServiceStop overcloud_service_upgrade = kayobe.cli.commands:OvercloudServiceUpgrade @@ -159,6 +160,8 @@ kayobe.cli.overcloud_service_deploy_containers = hooks = kayobe.cli.commands:HookDispatcher kayobe.cli.overcloud_service_destroy = hooks = kayobe.cli.commands:HookDispatcher +kayobe.cli.overcloud_service_prechecks = + hooks = kayobe.cli.commands:HookDispatcher kayobe.cli.overcloud_service_reconfigure = hooks = kayobe.cli.commands:HookDispatcher kayobe.cli.overcloud_service_stop =