diff --git a/ansible/roles/kolla-ansible/defaults/main.yml b/ansible/roles/kolla-ansible/defaults/main.yml index 2a5220a14..02cd4df75 100644 --- a/ansible/roles/kolla-ansible/defaults/main.yml +++ b/ansible/roles/kolla-ansible/defaults/main.yml @@ -23,13 +23,17 @@ kolla_ansible_venv_extra_requirements: [] # Pip requirement specifier for the ansible package. NOTE: This limits the # version of ansible used by kolla-ansible to avoid new releases from breaking -# tested code. Changes to this limit should be tested. -kolla_ansible_venv_ansible: 'ansible>=8,<10.0' +# tested code. Changes to this limit should be tested. It is possible to only +# install ansible-core by setting kolla_ansible_venv_ansible to None. +kolla_ansible_venv_ansible: kolla_ansible_venv_ansible_core: 'ansible-core>=2.15,<2.17' # Path to a requirements.yml file for Ansible collections. kolla_ansible_requirements_yml: "{{ kolla_ansible_venv }}/share/kolla-ansible/requirements.yml" +# Path to a an additional requirements.yml file for Ansible collections when using ansible-core. +kolla_ansible_core_requirements_yml: "{{ kolla_ansible_venv }}/share/kolla-ansible/requirements-core.yml" + # Virtualenv directory where Kolla-ansible's ansible modules will execute # remotely on the target nodes. If None, no virtualenv will be used. kolla_ansible_target_venv: diff --git a/ansible/roles/kolla-ansible/tasks/install.yml b/ansible/roles/kolla-ansible/tasks/install.yml index fb0662745..c1fdf1362 100644 --- a/ansible/roles/kolla-ansible/tasks/install.yml +++ b/ansible/roles/kolla-ansible/tasks/install.yml @@ -108,6 +108,13 @@ - name: Ensure Ansible collections are installed command: cmd: >- - ansible-galaxy collection install + ansible-galaxy collection install --force -r {{ kolla_ansible_requirements_yml }} + {% if not kolla_ansible_venv_ansible %}-r {{ kolla_ansible_core_requirements_yml }}{% endif %} -p {{ kolla_ansible_venv }}/share/kolla-ansible/ansible/collections/ + environment: + # NOTE(wszumski): Ignore collections shipped with ansible, so that we can install + # newer versions. + ANSIBLE_COLLECTIONS_SCAN_SYS_PATH: "False" + # NOTE(wszumski): Don't use path configured for kayobe + ANSIBLE_COLLECTIONS_PATH: diff --git a/kayobe/tests/unit/test_utils.py b/kayobe/tests/unit/test_utils.py index dbd057486..88fb96da3 100644 --- a/kayobe/tests/unit/test_utils.py +++ b/kayobe/tests/unit/test_utils.py @@ -48,11 +48,13 @@ class TestCase(unittest.TestCase): mock_read.return_value = {"collections": []} utils.galaxy_collection_install("/path/to/collection/file", "/path/to/collections") + env = {'ANSIBLE_COLLECTIONS_SCAN_SYS_PATH': 'False'} | os.environ mock_run.assert_called_once_with(["ansible-galaxy", "collection", "install", "--collections-path", "/path/to/collections", "--requirements-file", - "/path/to/collection/file"]) + "/path/to/collection/file"], + env=env) @mock.patch.object(utils, "run_command") @mock.patch.object(utils, "read_yaml_file") @@ -77,11 +79,13 @@ class TestCase(unittest.TestCase): mock_read.return_value = {"roles": []} utils.galaxy_collection_install("/path/to/collection/file", "/path/to/collections") + env = {'ANSIBLE_COLLECTIONS_SCAN_SYS_PATH': 'False'} | os.environ mock_run.assert_called_once_with(["ansible-galaxy", "collection", "install", "--collections-path", "/path/to/collections", "--requirements-file", - "/path/to/collection/file"]) + "/path/to/collection/file"], + env=env) @mock.patch.object(utils, "run_command") @mock.patch.object(utils, "read_yaml_file") diff --git a/kayobe/utils.py b/kayobe/utils.py index 04094db48..4d10e924c 100644 --- a/kayobe/utils.py +++ b/kayobe/utils.py @@ -118,10 +118,16 @@ def galaxy_collection_install(requirements_file, collections_path, cmd = ["ansible-galaxy", "collection", "install"] cmd += ["--collections-path", collections_path] cmd += ["--requirements-file", requirements_file] + env_defaults = { + # NOTE(wszumski): Allow overriding of ansible builtin collections in + # kayobe requirements.yml. + "ANSIBLE_COLLECTIONS_SCAN_SYS_PATH": "False", + } + env = env_defaults | os.environ if force: cmd += ["--force"] try: - run_command(cmd) + run_command(cmd, env=env) except subprocess.CalledProcessError as e: LOG.error("Failed to install Ansible collections from %s via Ansible " "Galaxy: returncode %d", requirements_file, e.returncode) diff --git a/releasenotes/notes/switch-to-using-newer-docker-collection-7594e079325bfa8d.yaml b/releasenotes/notes/switch-to-using-newer-docker-collection-7594e079325bfa8d.yaml new file mode 100644 index 000000000..968e91e3d --- /dev/null +++ b/releasenotes/notes/switch-to-using-newer-docker-collection-7594e079325bfa8d.yaml @@ -0,0 +1,12 @@ +--- +fixes: + - | + Switches to using ``ansible-core`` based kolla-ansible install. This is a + workaround for `LP#2072979 + `__, but also results in a + lighter weight install. + - | + Switches to using a newer version of the docker community collection to + workaround issues using the docker ansible modules with certain + combinations of python libraries. See `LP#2072979 + `__. diff --git a/requirements.yml b/requirements.yml index bfb834d4c..0ae3495ed 100644 --- a/requirements.yml +++ b/requirements.yml @@ -3,6 +3,8 @@ collections: - name: https://opendev.org/openstack/ansible-collection-kolla type: git version: master + - name: community.docker + version: 3.11.0 - name: dellemc.os10 version: 1.1.1 - name: openstack.cloud