Skip to content

Commit

Permalink
Bump up Ansible supported versions
Browse files Browse the repository at this point in the history
This change bumps up the maximum supported Ansible version to 4.x
(ansible-core 2.11.x) and minimum to 2.10. This synchronises Kayobe with
Kolla Ansible (see change I8b9212934dfab3831986e8db55671baee32f4bbd).

Uses of docker_image are updated. We must now provide the source
parameter. When source is build (for molecule), we replace force by
force_source and force_tag and move path and dockerfile under the build
parameter.

Use docker_image_info instead of docker_image_facts.

Handle update of ansible inside kolla-ansible virtualenv and document
how to do it for the kayobe virtualenv.

Change-Id: I7a4530f4f63ddb37aa30a617db5944b97bc3e17f
  • Loading branch information
priteau committed Sep 29, 2021
1 parent 4e14f9e commit 0f2b104
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 10 deletions.
1 change: 1 addition & 0 deletions ansible/roles/docker-registry/tasks/pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
docker_image:
name: "{{ item.value.image }}"
repository: "{{ item.value.image }}"
source: pull
state: present
with_dict: "{{ docker_registry_services }}"
when:
Expand Down
1 change: 1 addition & 0 deletions ansible/roles/inspection-store/tasks/pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
docker_image:
name: "{{ item.value.image }}"
repository: "{{ item.value.image }}"
source: pull
state: present
with_dict: "{{ inspection_store_services }}"
when:
Expand Down
32 changes: 31 additions & 1 deletion ansible/roles/kolla-ansible/tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,36 @@
with_items:
- { name: pip }

- block:
- name: Gather list of installed Python packages
pip_package_info:
clients: "{{ kolla_ansible_pip }}"
register: pip_packages

# Upgrading directly from Ansible 2.9 to Ansible 2.10 or from Ansible 2.10
# to Ansible 4 is known to cause problems. Uninstall Ansible first if its
# version is lower than 4.0.0. Although 2.10 is allowed by version limits,
# this is needed even it is present from Wallaby, because we request
# `state: latest`.
- name: Uninstall Ansible if an old version is present
pip:
name: ansible
state: absent
virtualenv: "{{ kolla_ansible_venv }}"
virtualenv_python: "{{ kolla_ansible_venv_python }}"
when:
- "'ansible' in pip_packages.packages[kolla_ansible_pip]"
- pip_packages.packages[kolla_ansible_pip].ansible[0].version is version('4.0.0', '<')

- name: Uninstall ansible-base
pip:
name: ansible-base
state: absent
virtualenv: "{{ kolla_ansible_venv }}"
virtualenv_python: "{{ kolla_ansible_venv_python }}"
vars:
kolla_ansible_pip: "{{ kolla_ansible_venv }}/bin/pip"

- name: Ensure required Python packages are installed
vars:
kolla_ansible_packages:
Expand All @@ -67,7 +97,7 @@
# Limit the version of ansible used by kolla-ansible to avoid new
# releases from breaking tested code. Changes to this limit should be
# tested.
- ansible>=2.9,<2.11,!=2.9.8,!=2.9.12
- ansible>=2.10.0,<5.0
- selinux
pip:
name: "{{ (kolla_ansible_packages + kolla_ansible_venv_extra_requirements) | select | list }}"
Expand Down
11 changes: 7 additions & 4 deletions ansible/roles/kolla-openstack/molecule/default/create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,20 @@
register: platforms

- name: Discover local Docker images
docker_image_facts:
docker_image_info:
name: "molecule_local/{{ item.item.name }}"
with_items: "{{ platforms.results }}"
register: docker_images

- name: Build an Ansible compatible image
docker_image:
path: "{{ molecule_ephemeral_directory }}"
name: "molecule_local/{{ item.item.image }}"
dockerfile: "{{ item.item.dockerfile | default(item.invocation.module_args.dest) }}"
force: "{{ item.item.force | default(true) }}"
source: build
build:
path: "{{ molecule_ephemeral_directory }}"
dockerfile: "{{ item.item.dockerfile | default(item.invocation.module_args.dest) }}"
force_source: "{{ item.item.force | default(true) }}"
force_tag: "{{ item.item.force | default(true) }}"
with_items: "{{ platforms.results }}"
when: platforms.changed or docker_images.results | map(attribute='images') | select('equalto', []) | list | count >= 0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,20 @@
register: platforms

- name: Discover local Docker images
docker_image_facts:
docker_image_info:
name: "molecule_local/{{ item.item.name }}"
with_items: "{{ platforms.results }}"
register: docker_images

- name: Build an Ansible compatible image
docker_image:
path: "{{ molecule_ephemeral_directory }}"
name: "molecule_local/{{ item.item.image }}"
dockerfile: "{{ item.item.dockerfile | default(item.invocation.module_args.dest) }}"
force: "{{ item.item.force | default(true) }}"
source: build
build:
path: "{{ molecule_ephemeral_directory }}"
dockerfile: "{{ item.item.dockerfile | default(item.invocation.module_args.dest) }}"
force_source: "{{ item.item.force | default(true) }}"
force_tag: "{{ item.item.force | default(true) }}"
with_items: "{{ platforms.results }}"
when: platforms.changed or docker_images.results | map(attribute='images') | select('equalto', []) | list | count >= 0

Expand Down
1 change: 1 addition & 0 deletions ansible/roles/opensm/tasks/pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
docker_image:
name: "{{ item.value.image }}"
repository: "{{ item.value.image }}"
source: pull
state: present
with_dict: "{{ opensm_services }}"
when:
Expand Down
8 changes: 8 additions & 0 deletions doc/source/upgrading.rst
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ Update the pip package::

(kayobe) $ pip install -U pip

.. note::

When updating Ansible above version 2.9.x, first uninstall it with ``pip
uninstall ansible``. A newer version will be installed with the next
command, as a Kayobe dependency. If Ansible 2.10.x was installed and you
want to use a newer version, also uninstall the ``ansible-base`` package
with ``pip uninstall ansible-base``.

If upgrading to the latest version of Kayobe::

(kayobe) $ pip install -U kayobe
Expand Down
21 changes: 21 additions & 0 deletions releasenotes/notes/ansible-max-4-f0666c5decc440f1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
upgrade:
- |
Updates the maximum supported version of Ansible from 2.9 to 4.x
(ansible-core 2.11). The minimum supported version is updated from 2.9 to
2.10. This is true for both Kayobe and Kolla Ansible.
- |
Upgrading directly from Ansible 2.9 to Ansible 2.10 or from Ansible 2.10 to
Ansible 4 is known to cause problems. You should uninstall Ansible before
upgrading your Kayobe virtual environment:
.. code-block:: console
pip uninstall ansible
If upgrading from Ansible 2.10 to a newer version, also uninstall
``ansible-base``:
.. code-block:: console
pip uninstall ansible-base
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pbr>=2.0 # Apache-2.0
ansible>=2.9.0,<2.11.0,!=2.9.8,!=2.9.12 # GPLv3
ansible>=2.10.0,<5.0 # GPLv3
cliff>=3.1.0 # Apache
netaddr!=0.7.16,>=0.7.13 # BSD
PyYAML>=3.10.0 # MIT
Expand Down

0 comments on commit 0f2b104

Please sign in to comment.