From 599b045636dcca7b0fb61f0b40dd9853f62716a9 Mon Sep 17 00:00:00 2001 From: Pierre Riteau Date: Tue, 5 Feb 2019 14:18:24 +0000 Subject: [PATCH] Allocate IPs separately from configuring network When running one of the `kayobe host configure` commands, in some cases an IP address that is allocated by the ip-allocation.yml playbook fails to be picked up by the network.yml playbook, which uses the address 0.0.0.0 instead. Running ip-allocation.yml separately ensures that the correct IP is used by network.yml. Change-Id: I15529398aef5e21049182b0edc11816876331113 Story: 2004800 Task: 28953 --- kayobe/cli/commands.py | 20 +++++++++++++++++--- kayobe/tests/unit/cli/test_commands.py | 18 +++++++++++++++--- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/kayobe/cli/commands.py b/kayobe/cli/commands.py index f0ae624a7..935be47d6 100644 --- a/kayobe/cli/commands.py +++ b/kayobe/cli/commands.py @@ -314,8 +314,14 @@ class SeedHypervisorHostConfigure(KollaAnsibleMixin, KayobeAnsibleMixin, self.app.LOG.error("Could not determine kayobe_ansible_user " "variable for seed hypervisor host") sys.exit(1) + + # Allocate IP addresses. + playbooks = _build_playbook_list("ip-allocation") + self.run_kayobe_playbooks(parsed_args, playbooks, + limit="seed-hypervisor") + playbooks = _build_playbook_list( - "ip-allocation", "ssh-known-host", "kayobe-ansible-user", + "ssh-known-host", "kayobe-ansible-user", "pip", "kayobe-target-venv") if parsed_args.wipe_disks: playbooks += _build_playbook_list("wipe-disks") @@ -451,9 +457,13 @@ class SeedHostConfigure(KollaAnsibleMixin, KayobeAnsibleMixin, VaultMixin, python_interpreter = hostvars.get("ansible_python_interpreter") kolla_target_venv = hostvars.get("kolla_ansible_target_venv") + # Allocate IP addresses. + playbooks = _build_playbook_list("ip-allocation") + self.run_kayobe_playbooks(parsed_args, playbooks, limit="seed") + # Run kayobe playbooks. playbooks = _build_playbook_list( - "ip-allocation", "ssh-known-host", "kayobe-ansible-user", + "ssh-known-host", "kayobe-ansible-user", "pip", "kayobe-target-venv") if parsed_args.wipe_disks: playbooks += _build_playbook_list("wipe-disks") @@ -848,9 +858,13 @@ class OvercloudHostConfigure(KollaAnsibleMixin, KayobeAnsibleMixin, VaultMixin, python_interpreter = hostvars.get("ansible_python_interpreter") kolla_target_venv = hostvars.get("kolla_ansible_target_venv") + # Allocate IP addresses. + playbooks = _build_playbook_list("ip-allocation") + self.run_kayobe_playbooks(parsed_args, playbooks, limit="overcloud") + # Kayobe playbooks. playbooks = _build_playbook_list( - "ip-allocation", "ssh-known-host", "kayobe-ansible-user", + "ssh-known-host", "kayobe-ansible-user", "pip", "kayobe-target-venv") if parsed_args.wipe_disks: playbooks += _build_playbook_list("wipe-disks") diff --git a/kayobe/tests/unit/cli/test_commands.py b/kayobe/tests/unit/cli/test_commands.py index 7f140ea78..c97b33650 100644 --- a/kayobe/tests/unit/cli/test_commands.py +++ b/kayobe/tests/unit/cli/test_commands.py @@ -248,10 +248,14 @@ class TestCase(unittest.TestCase): self.assertEqual(expected_calls, mock_dump.call_args_list) expected_calls = [ + mock.call( + mock.ANY, + [utils.get_data_files_path("ansible", "ip-allocation.yml")], + limit="seed-hypervisor", + ), mock.call( mock.ANY, [ - utils.get_data_files_path("ansible", "ip-allocation.yml"), utils.get_data_files_path("ansible", "ssh-known-host.yml"), utils.get_data_files_path( "ansible", "kayobe-ansible-user.yml"), @@ -344,10 +348,14 @@ class TestCase(unittest.TestCase): self.assertEqual(expected_calls, mock_dump.call_args_list) expected_calls = [ + mock.call( + mock.ANY, + [utils.get_data_files_path("ansible", "ip-allocation.yml")], + limit="seed", + ), mock.call( mock.ANY, [ - utils.get_data_files_path("ansible", "ip-allocation.yml"), utils.get_data_files_path("ansible", "ssh-known-host.yml"), utils.get_data_files_path( "ansible", "kayobe-ansible-user.yml"), @@ -949,10 +957,14 @@ class TestCase(unittest.TestCase): self.assertEqual(expected_calls, mock_dump.call_args_list) expected_calls = [ + mock.call( + mock.ANY, + [utils.get_data_files_path("ansible", "ip-allocation.yml")], + limit="overcloud", + ), mock.call( mock.ANY, [ - utils.get_data_files_path("ansible", "ip-allocation.yml"), utils.get_data_files_path("ansible", "ssh-known-host.yml"), utils.get_data_files_path( "ansible", "kayobe-ansible-user.yml"),