Create and install virtualenvs on seed/seed-hv/overcloud host upgrade

Adds two new commands:

kayobe seed hypervisor host upgrade
kayobe seed host upgrade

These commands can be used prior to performing an upgrade, in addition
to the existing command 'kayobe overcloud host upgrade'. These commands
will ensure that if kayobe and kolla-ansible remote virtualenvs are in
use, they exist and have all dependencies installed.
This commit is contained in:
Mark Goddard 2017-12-19 14:45:14 +00:00
parent 5e82121505
commit 7f04e9ccc6
6 changed files with 183 additions and 7 deletions

View File

@ -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:

View File

@ -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

View File

@ -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
============

View File

@ -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
=======================

View File

@ -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,

View File

@ -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):