From 01e24f9ddf3828e44b176cf3ae0e1754d2dac7ef Mon Sep 17 00:00:00 2001 From: Alex Willmer Date: Mon, 24 Nov 2025 11:02:14 +0000 Subject: [PATCH] ci: Use highest supported Ansible version during image prep It was necessary to split setup.yml because there is no common subset of supported include/import keywords across Ansible 2.3 - 2.11. The yaml stdout callback is unavailabe in Ansible 2.3. --- tests/image_prep/_container_create.yml | 5 --- tests/image_prep/_container_setup.yml | 2 +- tests/image_prep/ansible.cfg | 1 + tests/image_prep/hosts.ini | 20 +++++++++++ tests/image_prep/setup.yml | 19 ++++++++--- tests/image_prep/setup_ansible2.3.yml | 15 +++++++++ tests/image_prep/tox.ini | 46 ++++++++++++++++++++++---- tox.ini | 6 ++-- 8 files changed, 95 insertions(+), 19 deletions(-) create mode 100644 tests/image_prep/setup_ansible2.3.yml diff --git a/tests/image_prep/_container_create.yml b/tests/image_prep/_container_create.yml index 2fec8bd9..ab52b73b 100644 --- a/tests/image_prep/_container_create.yml +++ b/tests/image_prep/_container_create.yml @@ -3,11 +3,6 @@ strategy: mitogen_free gather_facts: false tasks: - - name: Fetch container images - docker_image: - name: "{{ docker_base }}" - delegate_to: localhost - - name: Start containers docker_container: name: "{{ inventory_hostname }}" diff --git a/tests/image_prep/_container_setup.yml b/tests/image_prep/_container_setup.yml index 3ec75760..93d9a7ce 100644 --- a/tests/image_prep/_container_setup.yml +++ b/tests/image_prep/_container_setup.yml @@ -16,7 +16,7 @@ pre_tasks: - meta: end_play when: - - ansible_facts.virtualization_type != "docker" + - ansible_virtualization_type != "docker" roles: - role: package_manager diff --git a/tests/image_prep/ansible.cfg b/tests/image_prep/ansible.cfg index e46bedcb..0d5771ee 100644 --- a/tests/image_prep/ansible.cfg +++ b/tests/image_prep/ansible.cfg @@ -5,6 +5,7 @@ any_errors_fatal = true callback_result_format = yaml deprecation_warnings = false duplicate_dict_key = error +inventory = hosts.ini strategy_plugins = ../../ansible_mitogen/plugins/strategy retry_files_enabled = false display_args_to_stdout = True diff --git a/tests/image_prep/hosts.ini b/tests/image_prep/hosts.ini index 68f8be62..a6d6b6b0 100644 --- a/tests/image_prep/hosts.ini +++ b/tests/image_prep/hosts.ini @@ -21,3 +21,23 @@ debian11 ubuntu1604 ubuntu1804 ubuntu2004 + +[ansible_2_3] +# Python 2.4 on targets +centos5 + +[ansible_5] +# Python 2.6 on targets +centos6 + +[ansible_9] +# Python 2.7 and/or 3.6 on targets +centos7 +centos8 +debian9 +debian10 +ubuntu1804 + +[ansible_11] +# Python >= 3.8 on targets +debian11 diff --git a/tests/image_prep/setup.yml b/tests/image_prep/setup.yml index b820e1bc..afe189a5 100755 --- a/tests/image_prep/setup.yml +++ b/tests/image_prep/setup.yml @@ -1,6 +1,17 @@ #!/usr/bin/env ansible-playbook -- include_playbook: _container_create.yml -- include_playbook: _container_setup.yml -- include_playbook: _user_accounts.yml -- include_playbook: _container_finalize.yml +- name: Get base images + hosts: all + # strategy: mitogen_free + gather_facts: false + tasks: + - name: Fetch container base images + docker_image: + name: "{{ docker_base }}" + source: pull # Added in Ansible 2.8, required circa 2.12 + delegate_to: localhost + +- import_playbook: _container_create.yml +- import_playbook: _container_setup.yml +- import_playbook: _user_accounts.yml +- import_playbook: _container_finalize.yml diff --git a/tests/image_prep/setup_ansible2.3.yml b/tests/image_prep/setup_ansible2.3.yml new file mode 100644 index 00000000..cc7025c8 --- /dev/null +++ b/tests/image_prep/setup_ansible2.3.yml @@ -0,0 +1,15 @@ +#!/usr/bin/env ansible-playbook + +- name: Get base images + hosts: all + gather_facts: false + tasks: + - name: Fetch container base images + docker_image: + name: "{{ docker_base }}" + delegate_to: localhost + +- include: _container_create.yml +- include: _container_setup.yml +- include: _user_accounts.yml +- include: _container_finalize.yml diff --git a/tests/image_prep/tox.ini b/tests/image_prep/tox.ini index d28d1512..2e32cdce 100644 --- a/tests/image_prep/tox.ini +++ b/tests/image_prep/tox.ini @@ -1,7 +1,9 @@ [tox] envlist = ansible2.3, - ansible2.10, + ansible5 + ansible9 + ansible11 skipsdist = true [testenv] @@ -13,17 +15,47 @@ basepython = python2 deps = ansible>=2.3,<2.4 docker-py>=1.7.0 - mitogen>=0.2.10rc1,<0.3 + mitogen~=0.2.0 install_command = python -m pip --no-python-version-warning install {opts} {packages} commands = - ./setup.yml -i hosts.ini -l 'localhost,centos5' {posargs} + ansible-playbook -l 'localhost,ansible_2_3' setup_ansible2.3.yml -[testenv:ansible2.10] +[testenv:ansible5] basepython = python3 deps = - ansible>=2.10,<2.11 + ansible~=5.0 docker>=1.8.0 - mitogen>=0.3.0rc1,<0.4 + mitogen~=0.3.0 + passlib +setenv = + ANSIBLE_PYTHON_INTERPRETER=auto_silent + ANSIBLE_STDOUT_CALLBACK=yaml +commands = + ansible-playbook -l 'localhost,ansible_5' setup.yml + +[testenv:ansible9] +basepython = python3 +deps = + ansible~=9.0 + docker>=1.8.0 + mitogen~=0.3.0 + passlib +setenv = + ANSIBLE_PYTHON_INTERPRETER=auto_silent + ANSIBLE_STDOUT_CALLBACK=yaml +commands = + ansible-playbook -l 'localhost,ansible_9' setup.yml + +[testenv:ansible11] +basepython = python3 +deps = + ansible~=11.0 + docker>=1.8.0 + mitogen~=0.3.0 + passlib +setenv = + ANSIBLE_PYTHON_INTERPRETER=auto_silent + ANSIBLE_STDOUT_CALLBACK=yaml commands = - ./setup.yml -i hosts.ini -l '!centos5' {posargs} + ansible-playbook -l 'localhost,ansible_11' setup.yml diff --git a/tox.ini b/tox.ini index 08b2eb98..c2a51dda 100644 --- a/tox.ini +++ b/tox.ini @@ -6,8 +6,8 @@ # Py A cntrllr A target coverage Django Jinja2 pip psutil pytest tox virtualenv # ==== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== -# 2.4 2.3? <= 3.7.1 <= 1.3.7 <= 1.1 <= 2.1.3 <= 1.4 <= 1.8 -# 2.5 <= 3.7.1 <= 1.4.22 <= 1.3.1 <= 2.1.3 <= 2.8.7 <= 1.6.1 <= 1.9.1 +# 2.4 <= 2.3³ <= 3.7.1 <= 1.3.7 <= 1.1 <= 2.1.3 <= 1.4 <= 1.8 +# 2.5 <= 2.3³ <= 3.7.1 <= 1.4.22 <= 1.3.1 <= 2.1.3 <= 2.8.7 <= 1.6.1 <= 1.9.1 # 2.6 <= 2.6.20 <= 2.12 <= 4.5.4 <= 1.6.11 <= 2.10.3 <= 9.0.3 <= 5.9.0 <= 3.2.5 <= 2.9.1 <= 15.2.0 # 2.7 <= 2.11 <= 2.16 <= 5.5 <= 1.11.29 <= 2.11.3 <= 20 <= 4.6.11 <= 3.28 <= 20.15² # 3.5 <= 2.11 <= 2.15 <= 5.5 <= 2.2.28 <= 2.11.3 <= 20 <= 5.9.5 <= 6.1.0 <= 3.28 <= 20.15² @@ -35,6 +35,8 @@ # Virtualenv <= 20.21.1 supports creating virtualenvs with any *target* Python. # Virtualenv >= 20.22 supports creating virtualenvs with target Python >= 3.7. # https://virtualenv.pypa.io/en/latest/#compatibility +# +# 3. https://docs.ansible.com/ansible/2.7/dev_guide/developing_python_3.html#minimum-version-of-python-3-x-and-python-2-x # Ansible Dependency # ================== ======================