Skip to content

Commit

Permalink
Support Ansible 11 (ansible-core 2.18)
Browse files Browse the repository at this point in the history
  • Loading branch information
moreati committed Dec 2, 2024
1 parent b36806a commit 0b99169
Show file tree
Hide file tree
Showing 16 changed files with 74 additions and 78 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ansible_mitogen/loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions docs/ansible_detailed.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
27 changes: 27 additions & 0 deletions tests/ansible/hosts/group_vars/all.yml
Original file line number Diff line number Diff line change
@@ -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: []
2 changes: 2 additions & 0 deletions tests/ansible/integration/action/make_tmp_path.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 4 additions & 20 deletions tests/ansible/integration/become/su_password.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,15 @@
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:
- out.stdout == 'mitogen__user1'
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
Expand All @@ -81,23 +73,15 @@
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:
- out.stdout == 'mitogen__user1'
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
Expand Down
10 changes: 2 additions & 8 deletions tests/ansible/integration/become/sudo_nonexistent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
25 changes: 5 additions & 20 deletions tests/ansible/integration/become/sudo_password.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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
Expand All @@ -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: |
Expand All @@ -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
Expand All @@ -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
8 changes: 8 additions & 0 deletions tests/ansible/integration/become/sudo_requiretty.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 1 addition & 4 deletions tests/ansible/integration/become/templated_by_inv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 1 addition & 4 deletions tests/ansible/integration/become/templated_by_play_vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 1 addition & 4 deletions tests/ansible/integration/playbook_semantics/with_items.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 7 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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¹
#
Expand Down Expand Up @@ -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
Expand All @@ -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,

Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0b99169

Please sign in to comment.