From 0b99169f4208d85f592362d2466df89a2ece08b6 Mon Sep 17 00:00:00 2001 From: Alex Willmer Date: Mon, 4 Nov 2024 22:43:48 +0000 Subject: [PATCH] Support Ansible 11 (ansible-core 2.18) --- .github/workflows/tests.yml | 16 ++++++----- ansible_mitogen/loaders.py | 2 +- docs/ansible_detailed.rst | 2 ++ docs/changelog.rst | 1 + tests/ansible/hosts/group_vars/all.yml | 27 +++++++++++++++++++ .../integration/action/make_tmp_path.yml | 2 ++ .../integration/become/su_password.yml | 24 +++-------------- .../integration/become/sudo_nonexistent.yml | 10 ++----- .../integration/become/sudo_password.yml | 25 ++++------------- .../integration/become/sudo_requiretty.yml | 8 ++++++ .../integration/become/templated_by_inv.yml | 5 +--- .../become/templated_by_play_keywords.yml | 5 +--- .../become/templated_by_play_vars.yml | 5 +--- .../become/templated_by_task_keywords.yml | 5 +--- .../playbook_semantics/with_items.yml | 5 +--- tox.ini | 10 ++++--- 16 files changed, 74 insertions(+), 78 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 15dda0398..24b70c64b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -63,9 +63,13 @@ jobs: - name: Ans_313_10 python_version: '3.13' tox_env: py313-mode_ansible-ansible10 - - name: Van_313_10 + - name: Ans_313_11 python_version: '3.13' - tox_env: py313-mode_ansible-ansible10-strategy_linear + tox_env: py313-mode_ansible-ansible11 + + - name: Van_313_11 + python_version: '3.13' + tox_env: py313-mode_ansible-ansible11-strategy_linear - name: Mito_27 tox_env: py27-mode_mitogen @@ -167,11 +171,11 @@ jobs: - name: Mito_313 tox_env: py313-mode_mitogen - - name: Loc_313_10 - tox_env: py313-mode_localhost-ansible10 + - name: Loc_313_11 + tox_env: py313-mode_localhost-ansible11 - - name: Van_313_10 - tox_env: py313-mode_localhost-ansible10-strategy_linear + - name: Van_313_11 + tox_env: py313-mode_localhost-ansible11-strategy_linear steps: - uses: actions/checkout@v4 diff --git a/ansible_mitogen/loaders.py b/ansible_mitogen/loaders.py index 9d9876ac6..632b11b14 100644 --- a/ansible_mitogen/loaders.py +++ b/ansible_mitogen/loaders.py @@ -49,7 +49,7 @@ ANSIBLE_VERSION_MIN = (2, 10) -ANSIBLE_VERSION_MAX = (2, 17) +ANSIBLE_VERSION_MAX = (2, 18) NEW_VERSION_MSG = ( "Your Ansible version (%s) is too recent. The most recent version\n" diff --git a/docs/ansible_detailed.rst b/docs/ansible_detailed.rst index 73ebba4dd..3d80a290a 100644 --- a/docs/ansible_detailed.rst +++ b/docs/ansible_detailed.rst @@ -141,6 +141,8 @@ Noteworthy Differences +-----------------+ 3.10 - 3.13 | | 10 | | +-----------------+-----------------+ + | 11 | 3.11 - 3.13 | + +-----------------+-----------------+ Verify your installation is running one of these versions by checking ``ansible --version`` output. diff --git a/docs/changelog.rst b/docs/changelog.rst index 571cce289..934f3a119 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -21,6 +21,7 @@ To avail of fixes in an unreleased version, please download a ZIP file In progress (unreleased) ------------------------ +* :gh:issue:`1129` :mod:`ansible_mitogen`: Ansible 11 support v0.3.18 (2024-11-07) diff --git a/tests/ansible/hosts/group_vars/all.yml b/tests/ansible/hosts/group_vars/all.yml index ad4adabb6..44e660fc1 100644 --- a/tests/ansible/hosts/group_vars/all.yml +++ b/tests/ansible/hosts/group_vars/all.yml @@ -1,3 +1,30 @@ --- +become_unpriv_available: >- + {# + Vanilla Ansible >= 4 (ansible-core >= 2.11) can use `setfacl` for + unpriv -> unpriv, but Mitogen test containers lack setfacl + https://github.com/mitogen-hq/mitogen/issues/1118 + + Mitogen + Ansible can do unpriv -> unpriv without temporary files, + but Ansible >= 11 (ansible-core >= 2.18) detection tries to use Python + 3.13 which hits https://github.com/python/cpython/issues/115911 on macOS. + #} + {{- + ( + not is_mitogen + and ansible_facts.distribution in ["MacOSX"] + and ansible_version.full is version("2.11", ">=", strict=True) + ) + or ( + is_mitogen + and not ansible_facts.distribution in ["MacOSX"] + ) + or ( + is_mitogen + and ansible_python_interpreter is not defined + and ansible_version.full is version("2.18", "<", strict=True) + ) + -}} + pkg_mgr_python_interpreter: python pkg_repos_overrides: [] diff --git a/tests/ansible/integration/action/make_tmp_path.yml b/tests/ansible/integration/action/make_tmp_path.yml index c0200691c..4e706ed5a 100644 --- a/tests/ansible/integration/action/make_tmp_path.yml +++ b/tests/ansible/integration/action/make_tmp_path.yml @@ -152,6 +152,8 @@ result['path'] = path open(path, 'w').write("bar") register: tmp_path + when: + - become_unpriv_available # # modules get the same base dir diff --git a/tests/ansible/integration/become/su_password.yml b/tests/ansible/integration/become/su_password.yml index e1dfd5727..19a15c7e4 100644 --- a/tests/ansible/integration/become/su_password.yml +++ b/tests/ansible/integration/become/su_password.yml @@ -55,11 +55,7 @@ vars: ansible_become_pass: user1_password when: - # CI containers lack `setfacl` for unpriv -> unpriv - # https://github.com/mitogen-hq/mitogen/issues/1118 - - is_mitogen - or (ansible_facts.distribution in ["MacOSX"] - and ansible_version.full is version("2.11", ">=", strict=True)) + - become_unpriv_available - assert: that: @@ -67,11 +63,7 @@ fail_msg: | out={{ out }} when: - # CI containers lack `setfacl` for unpriv -> unpriv - # https://github.com/mitogen-hq/mitogen/issues/1118 - - is_mitogen - or (ansible_facts.distribution in ["MacOSX"] - and ansible_version.full is version("2.11", ">=", strict=True)) + - become_unpriv_available - name: Ensure password su without chdir succeeds shell: whoami @@ -81,11 +73,7 @@ vars: ansible_become_pass: user1_password when: - # CI containers lack `setfacl` for unpriv -> unpriv - # https://github.com/mitogen-hq/mitogen/issues/1118 - - is_mitogen - or (ansible_facts.distribution in ["MacOSX"] - and ansible_version.full is version("2.11", ">=", strict=True)) + - become_unpriv_available - assert: that: @@ -93,11 +81,7 @@ fail_msg: | out={{ out }} when: - # CI containers lack `setfacl` for unpriv -> unpriv - # https://github.com/mitogen-hq/mitogen/issues/1118 - - is_mitogen - or (ansible_facts.distribution in ["MacOSX"] - and ansible_version.full is version("2.11", ">=", strict=True)) + - become_unpriv_available tags: - su diff --git a/tests/ansible/integration/become/sudo_nonexistent.yml b/tests/ansible/integration/become/sudo_nonexistent.yml index 27090f74a..208f0c9b8 100644 --- a/tests/ansible/integration/become/sudo_nonexistent.yml +++ b/tests/ansible/integration/become/sudo_nonexistent.yml @@ -9,10 +9,7 @@ ignore_errors: true register: out when: - # https://github.com/ansible/ansible/pull/70785 - - ansible_facts.distribution not in ["MacOSX"] - or ansible_version.full is version("2.11", ">=", strict=True) - or is_mitogen + - become_unpriv_available - name: Verify raw module output. assert: @@ -26,10 +23,7 @@ fail_msg: | out={{ out }} when: - # https://github.com/ansible/ansible/pull/70785 - - ansible_facts.distribution not in ["MacOSX"] - or ansible_version.full is version("2.11", ">=", strict=True) - or is_mitogen + - become_unpriv_available tags: - sudo - sudo_nonexistent diff --git a/tests/ansible/integration/become/sudo_password.yml b/tests/ansible/integration/become/sudo_password.yml index 8f99bf6f5..150cb1f0f 100644 --- a/tests/ansible/integration/become/sudo_password.yml +++ b/tests/ansible/integration/become/sudo_password.yml @@ -13,10 +13,7 @@ changed_when: false ignore_errors: true when: - # https://github.com/ansible/ansible/pull/70785 - - ansible_facts.distribution not in ["MacOSX"] - or ansible_version.full is version("2.11", ">=", strict=True) - or is_mitogen + - become_unpriv_available - assert: that: | @@ -28,10 +25,7 @@ fail_msg: | out={{ out }} when: - # https://github.com/ansible/ansible/pull/70785 - - ansible_facts.distribution not in ["MacOSX"] - or ansible_version.full is version("2.11", ">=", strict=True) - or is_mitogen + - become_unpriv_available - name: Ensure password sudo incorrect. become: true @@ -44,10 +38,7 @@ ansible_become_pass: nopes ignore_errors: true when: - # https://github.com/ansible/ansible/pull/70785 - - ansible_facts.distribution not in ["MacOSX"] - or ansible_version.full is version("2.11", ">=", strict=True) - or is_mitogen + - become_unpriv_available - assert: that: | @@ -58,10 +49,7 @@ fail_msg: | out={{ out }} when: - # https://github.com/ansible/ansible/pull/70785 - - ansible_facts.distribution not in ["MacOSX"] - or ansible_version.full is version("2.11", ">=", strict=True) - or is_mitogen + - become_unpriv_available - block: - name: Ensure password sudo succeeds @@ -80,10 +68,7 @@ fail_msg: | sudo_password_success_whoami={{ sudo_password_success_whoami }} when: - # https://github.com/ansible/ansible/pull/70785 - - ansible_facts.distribution not in ["MacOSX"] - or ansible_version.full is version("2.11", ">=", strict=True) - or is_mitogen + - become_unpriv_available tags: - sudo - sudo_password diff --git a/tests/ansible/integration/become/sudo_requiretty.yml b/tests/ansible/integration/become/sudo_requiretty.yml index 08b478a28..7849035b9 100644 --- a/tests/ansible/integration/become/sudo_requiretty.yml +++ b/tests/ansible/integration/become/sudo_requiretty.yml @@ -13,12 +13,16 @@ cmd: whoami changed_when: false register: sudo_require_tty_whoami + when: + - become_unpriv_available - assert: that: - sudo_require_tty_whoami.stdout == 'mitogen__require_tty' fail_msg: | sudo_require_tty_whoami={{ sudo_require_tty_whoami }} + when: + - become_unpriv_available - name: Verify we can login to a passworded requiretty account become: true @@ -29,12 +33,16 @@ cmd: whoami changed_when: false register: sudo_require_tty_password_whoami + when: + - become_unpriv_available - assert: that: - sudo_require_tty_password_whoami.stdout == 'mitogen__require_tty_pw_required' fail_msg: | sudo_require_tty_password_whoami={{ sudo_require_tty_password_whoami }} + when: + - become_unpriv_available tags: - mitogen_only - sudo diff --git a/tests/ansible/integration/become/templated_by_inv.yml b/tests/ansible/integration/become/templated_by_inv.yml index 0829fc084..a2e9c457a 100644 --- a/tests/ansible/integration/become/templated_by_inv.yml +++ b/tests/ansible/integration/become/templated_by_inv.yml @@ -27,8 +27,5 @@ - become_templated_by_inv_whoami is failed or become_templated_by_inv_whoami.stdout != expected_become_users[inventory_hostname] when: - # https://github.com/ansible/ansible/pull/70785 - ansible_become_user in ['root'] - or ansible_facts.distribution not in ["MacOSX"] - or ansible_version.full is version("2.11", ">=", strict=True) - or is_mitogen + or become_unpriv_available diff --git a/tests/ansible/integration/become/templated_by_play_keywords.yml b/tests/ansible/integration/become/templated_by_play_keywords.yml index 146a37352..6f6ea2495 100644 --- a/tests/ansible/integration/become/templated_by_play_keywords.yml +++ b/tests/ansible/integration/become/templated_by_play_keywords.yml @@ -47,7 +47,4 @@ - become_templated_by_play_keywords_password_whoami is failed or become_templated_by_play_keywords_password_whoami.stdout != 'mitogen__pw_required' when: - # https://github.com/ansible/ansible/pull/70785 - - ansible_facts.distribution not in ["MacOSX"] - or ansible_version.full is version("2.11", ">=", strict=True) - or is_mitogen + - become_unpriv_available diff --git a/tests/ansible/integration/become/templated_by_play_vars.yml b/tests/ansible/integration/become/templated_by_play_vars.yml index df6684a50..ba7c143ea 100644 --- a/tests/ansible/integration/become/templated_by_play_vars.yml +++ b/tests/ansible/integration/become/templated_by_play_vars.yml @@ -46,7 +46,4 @@ - become_templated_by_play_vars_password_whoami is failed or become_templated_by_play_vars_password_whoami.stdout != 'mitogen__pw_required' when: - # https://github.com/ansible/ansible/pull/70785 - - ansible_facts.distribution not in ["MacOSX"] - or ansible_version.full is version("2.11", ">=", strict=True) - or is_mitogen + - become_unpriv_available diff --git a/tests/ansible/integration/become/templated_by_task_keywords.yml b/tests/ansible/integration/become/templated_by_task_keywords.yml index c42df1b1e..ca61e3891 100644 --- a/tests/ansible/integration/become/templated_by_task_keywords.yml +++ b/tests/ansible/integration/become/templated_by_task_keywords.yml @@ -77,7 +77,4 @@ - become_templated_by_task_with_delegate_to_password_whoami is failed or become_templated_by_task_with_delegate_to_password_whoami.stdout != 'mitogen__pw_required' when: - # https://github.com/ansible/ansible/pull/70785 - - ansible_facts.distribution not in ["MacOSX"] - or ansible_version.full is version("2.11", ">=", strict=True) - or is_mitogen + - become_unpriv_available diff --git a/tests/ansible/integration/playbook_semantics/with_items.yml b/tests/ansible/integration/playbook_semantics/with_items.yml index 891469814..a2ef015cc 100644 --- a/tests/ansible/integration/playbook_semantics/with_items.yml +++ b/tests/ansible/integration/playbook_semantics/with_items.yml @@ -35,7 +35,4 @@ - second_run.results[item | int].stdout == user_expected with_sequence: start=0 end=2 when: - # https://github.com/ansible/ansible/pull/70785 - - ansible_facts.distribution not in ["MacOSX"] - or ansible_version.full is version("2.11", ">=", strict=True) - or is_mitogen + - become_unpriv_available diff --git a/tox.ini b/tox.ini index 5afa7eb1c..ea988aa0c 100644 --- a/tox.ini +++ b/tox.ini @@ -12,10 +12,10 @@ # 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² # 3.6 <= 2.11 <= 2.16 <= 6.2 <= 3.2.20 <= 3.0.3 <= 21 <= 7.0.1 <= 3.28 <= 20.17² -# 3.7 <= 2.12 <= 7.2.7 <= 3.2.20 <= 7.4.4 <= 4.8.0 +# 3.7 <= 2.12 <= 2.17 <= 7.2.7 <= 3.2.20 <= 7.4.4 <= 4.8.0 # 3.8 <= 2.12 # 3.9 <= 2.15 -# 3.10 +# 3.10 <= 2.17 # 3.11 # 3.12 >= 2.13¹ # @@ -46,6 +46,7 @@ # ansible == 8.x ansible-core ~= 2.15.0 # ansible == 9.x ansible-core ~= 2.16.0 # ansible == 10.x ansible-core ~= 2.17.0 +# ansible == 11.x ansible-core ~= 2.18.0 # See also # - https://docs.ansible.com/ansible/latest/reference_appendices/release_and_maintenance.html#ansible-core-support-matrix @@ -55,7 +56,7 @@ envlist = init, py{27,36}-mode_ansible-ansible{2.10,3,4}, py{311}-mode_ansible-ansible{2.10,3,4,5}, - py{313}-mode_ansible-ansible{6,7,8,9,10}, + py{313}-mode_ansible-ansible{6,7,8,9,10,11}, py{27,36,313}-mode_mitogen, report, @@ -84,6 +85,7 @@ deps = ansible8: ansible~=8.0 ansible9: ansible~=9.0 ansible10: ansible~=10.0 + ansible11: ansible>=11.0 install_command = python -m pip --no-python-version-warning --disable-pip-version-check install {opts} {packages} commands_pre = @@ -111,6 +113,8 @@ setenv = ansible9: MITOGEN_TEST_DISTRO_SPECS=centos7 centos8 debian9 debian10 debian11 ubuntu1804 ubuntu2004 # Ansible 10 (ansible-core 2.17) requires Python >= 3.7 on targets ansible10: MITOGEN_TEST_DISTRO_SPECS=debian10-py3 debian11-py3 ubuntu2004-py3 + # Ansible 11 (ansible-core 2.18) requires Python >= 3.8 on targets + ansible11: MITOGEN_TEST_DISTRO_SPECS=debian11-py3 ubuntu2004-py3 distros_centos: MITOGEN_TEST_DISTRO_SPECS=centos6 centos7 centos8 distros_centos5: MITOGEN_TEST_DISTRO_SPECS=centos5 distros_centos6: MITOGEN_TEST_DISTRO_SPECS=centos6