Bump up Ansible supported versions

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
This commit is contained in:
Pierre Riteau 2021-09-29 22:31:33 +02:00
parent 4e14f9e9c5
commit 0f2b104213
9 changed files with 78 additions and 10 deletions

View File

@ -3,6 +3,7 @@
docker_image:
name: "{{ item.value.image }}"
repository: "{{ item.value.image }}"
source: pull
state: present
with_dict: "{{ docker_registry_services }}"
when:

View File

@ -3,6 +3,7 @@
docker_image:
name: "{{ item.value.image }}"
repository: "{{ item.value.image }}"
source: pull
state: present
with_dict: "{{ inspection_store_services }}"
when:

View File

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

View File

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

View File

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

View File

@ -3,6 +3,7 @@
docker_image:
name: "{{ item.value.image }}"
repository: "{{ item.value.image }}"
source: pull
state: present
with_dict: "{{ opensm_services }}"
when:

View File

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

View File

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

View File

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