diff --git a/ansible/kayobe-target-venv.yml b/ansible/kayobe-target-venv.yml index 262e4ca04..10cf3ffbd 100644 --- a/ansible/kayobe-target-venv.yml +++ b/ansible/kayobe-target-venv.yml @@ -5,6 +5,8 @@ - name: Ensure a virtualenv exists for kayobe hosts: seed:seed-hypervisor:overcloud gather_facts: False + tags: + - kayobe-target-venv tasks: - name: Set a fact about the kayobe target virtualenv set_fact: diff --git a/ansible/kolla-target-venv.yml b/ansible/kolla-target-venv.yml new file mode 100644 index 000000000..bf015f09c --- /dev/null +++ b/ansible/kolla-target-venv.yml @@ -0,0 +1,44 @@ +--- +# Create a virtualenv for ansible modules to use on the remote target systems +# when running kolla-ansible. + +- name: Ensure a virtualenv exists for kolla-ansible + hosts: seed:seed-hypervisor:overcloud + gather_facts: False + tags: + - kolla-ansible + - kolla-target-venv + tasks: + - block: + - name: Ensure the python-virtualenv package is installed + package: + name: python-virtualenv + state: installed + become: True + + - name: Ensure kolla-ansible virtualenv has the latest version of pip installed + pip: + name: pip + state: latest + virtualenv: "{{ kolla_ansible_target_venv }}" + # Site packages are required for using the yum and selinux python + # modules, which are not available via PyPI. + virtualenv_site_packages: True + become: True + + - name: Ensure kolla-ansible virtualenv has docker SDK for python installed + pip: + name: docker + state: latest + virtualenv: "{{ kolla_ansible_target_venv }}" + become: True + + - name: Ensure kolla-ansible virtualenv has correct ownership + file: + path: "{{ kolla_ansible_target_venv }}" + recurse: True + state: directory + owner: kolla + group: kolla + become: True + when: kolla_ansible_target_venv is not none diff --git a/doc/source/release-notes.rst b/doc/source/release-notes.rst index 53862be9c..035a09308 100644 --- a/doc/source/release-notes.rst +++ b/doc/source/release-notes.rst @@ -66,10 +66,25 @@ Upgrade Notes images for the seed were built on the seed, and container images for the overcloud were built on the controllers. The new design is intended to encourage a build, push, pull workflow. +* It is now possible to configure kayobe to use a virtual environment for + remote execution of ansible modules. If this is required, the following + commands should be run in order to ensure that the virtual environments exist + on the remote hosts:: + + (kayobe) $ kayobe seed hypervisor host upgrade + (kayobe) $ kayobe seed host upgrade + (kayobe) $ kayobe overcloud host upgrade + * The default behaviour is now to configure kolla-ansible to use a virtual - environment for remote execution of ansible modules. The previous behaviour - of installing python dependencies directly to the host can be used by - setting ``kolla_ansible_target_venv`` to ``None`` + environment for remote execution of ansible modules. In order to ensure the + virtual environment exists on the remote hosts, run the following commands:: + + (kayobe) $ kayobe seed hypervisor host upgrade + (kayobe) $ kayobe seed host upgrade + (kayobe) $ kayobe overcloud host upgrade + + The previous behaviour of installing python dependencies directly to the host + can be used by setting ``kolla_ansible_target_venv`` to ``None``. Kayobe 3.0.0 ============ diff --git a/doc/source/upgrading.rst b/doc/source/upgrading.rst index 84ee26f52..81f551c1b 100644 --- a/doc/source/upgrading.rst +++ b/doc/source/upgrading.rst @@ -80,10 +80,27 @@ To upgrade the Ansible control host:: (kayobe) $ kayobe control host upgrade +Upgrading the Seed Hypervisor +============================= + +Currently, upgrading the seed hypervisor services is not supported. It may +however be necessary to upgrade some host services:: + + (kayobe) $ kayobe seed hypervisor host upgrade + +Note that this will not perform full configuration of the host, and will +instead perform a targeted upgrade of specific services where necessary. + Upgrading the Seed ================== -Currently, upgrading the seed services is not supported. +Currently, upgrading the seed services is not supported. It may however be +necessary to upgrade some host services:: + + (kayobe) $ kayobe seed host upgrade + +Note that this will not perform full configuration of the host, and will +instead perform a targeted upgrade of specific services where necessary. Upgrading the Overcloud ======================= diff --git a/kayobe/cli/commands.py b/kayobe/cli/commands.py index 804ddf41a..6074a4a4d 100644 --- a/kayobe/cli/commands.py +++ b/kayobe/cli/commands.py @@ -282,6 +282,21 @@ class SeedHypervisorHostConfigure(KollaAnsibleMixin, KayobeAnsibleMixin, limit="seed-hypervisor") +class SeedHypervisorHostUpgrade(KayobeAnsibleMixin, VaultMixin, Command): + """Upgrade the seed hypervisor host services. + + Performs the changes necessary to make the host services suitable for the + configured OpenStack release. + """ + + def take_action(self, parsed_args): + self.app.LOG.debug("Upgrading seed hypervisor host services") + playbooks = _build_playbook_list( + "kayobe-target-venv", "kolla-target-venv") + self.run_kayobe_playbooks(parsed_args, playbooks, + limit="seed-hypervisor") + + class SeedVMProvision(KollaAnsibleMixin, KayobeAnsibleMixin, VaultMixin, Command): """Provision the seed VM. @@ -398,6 +413,21 @@ class SeedHostConfigure(KollaAnsibleMixin, KayobeAnsibleMixin, VaultMixin, self.run_kayobe_playbooks(parsed_args, playbooks, limit="seed") +class SeedHostUpgrade(KollaAnsibleMixin, KayobeAnsibleMixin, VaultMixin, + Command): + """Upgrade the seed host services. + + Performs the changes necessary to make the host services suitable for the + configured OpenStack release. + """ + + def take_action(self, parsed_args): + self.app.LOG.debug("Upgrading seed host services") + playbooks = _build_playbook_list( + "kayobe-target-venv", "kolla-target-venv") + self.run_kayobe_playbooks(parsed_args, playbooks, limit="seed") + + class SeedServiceDeploy(KollaAnsibleMixin, KayobeAnsibleMixin, VaultMixin, Command): """Deploy the seed services. @@ -668,8 +698,7 @@ class OvercloudHostConfigure(KollaAnsibleMixin, KayobeAnsibleMixin, VaultMixin, self.run_kayobe_playbooks(parsed_args, playbooks, limit="overcloud") -class OvercloudHostUpgrade(KollaAnsibleMixin, KayobeAnsibleMixin, VaultMixin, - Command): +class OvercloudHostUpgrade(KayobeAnsibleMixin, VaultMixin, Command): """Upgrade the overcloud host services. Performs the changes necessary to make the host services suitable for the @@ -679,8 +708,9 @@ class OvercloudHostUpgrade(KollaAnsibleMixin, KayobeAnsibleMixin, VaultMixin, def take_action(self, parsed_args): self.app.LOG.debug("Upgrading overcloud host services") playbooks = _build_playbook_list( + "kayobe-target-venv", "kolla-target-venv", "overcloud-docker-sdk-upgrade", "overcloud-etc-hosts-fixup") - self.run_kayobe_playbooks(parsed_args, playbooks) + self.run_kayobe_playbooks(parsed_args, playbooks, limit="overcloud") class OvercloudServiceConfigurationGenerate(KayobeAnsibleMixin, diff --git a/kayobe/tests/unit/cli/test_commands.py b/kayobe/tests/unit/cli/test_commands.py index 51fc5db9d..c311a895a 100644 --- a/kayobe/tests/unit/cli/test_commands.py +++ b/kayobe/tests/unit/cli/test_commands.py @@ -112,6 +112,28 @@ class TestCase(unittest.TestCase): ] self.assertEqual(expected_calls, mock_run.call_args_list) + @mock.patch.object(commands.KayobeAnsibleMixin, + "run_kayobe_playbooks") + def test_seed_hypervisor_host_upgrade(self, mock_run): + command = commands.SeedHypervisorHostUpgrade(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, + [ + "ansible/kayobe-target-venv.yml", + "ansible/kolla-target-venv.yml", + ], + limit="seed-hypervisor", + ), + ] + self.assertEqual(expected_calls, mock_run.call_args_list) + @mock.patch.object(commands.KayobeAnsibleMixin, "run_kayobe_config_dump") @mock.patch.object(commands.KayobeAnsibleMixin, @@ -283,6 +305,28 @@ class TestCase(unittest.TestCase): ] self.assertEqual(expected_calls, mock_kolla_run.call_args_list) + @mock.patch.object(commands.KayobeAnsibleMixin, + "run_kayobe_playbooks") + def test_seed_host_upgrade(self, mock_run): + command = commands.SeedHostUpgrade(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, + [ + "ansible/kayobe-target-venv.yml", + "ansible/kolla-target-venv.yml", + ], + limit="seed", + ), + ] + self.assertEqual(expected_calls, mock_run.call_args_list) + @mock.patch.object(commands.KayobeAnsibleMixin, "run_kayobe_playbooks") def test_seed_container_image_build(self, mock_run): @@ -502,6 +546,30 @@ class TestCase(unittest.TestCase): ] self.assertEqual(expected_calls, mock_kolla_run.call_args_list) + @mock.patch.object(commands.KayobeAnsibleMixin, + "run_kayobe_playbooks") + def test_overcloud_host_upgrade(self, mock_run): + command = commands.OvercloudHostUpgrade(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, + [ + "ansible/kayobe-target-venv.yml", + "ansible/kolla-target-venv.yml", + "ansible/overcloud-docker-sdk-upgrade.yml", + "ansible/overcloud-etc-hosts-fixup.yml", + ], + limit="overcloud", + ), + ] + self.assertEqual(expected_calls, mock_run.call_args_list) + @mock.patch.object(commands.KayobeAnsibleMixin, "run_kayobe_playbooks") def test_overcloud_container_image_build(self, mock_run):