From fc24b3f25efa6969d9ba1c2dbfcf4eff1de9427e Mon Sep 17 00:00:00 2001 From: Alex Willmer Date: Sun, 17 Mar 2024 16:00:44 +0000 Subject: [PATCH 01/15] Start v0.3.6 development --- docs/changelog.rst | 4 ++++ mitogen/__init__.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index ead09d14..a9c96b4c 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -17,6 +17,10 @@ Release Notes To avail of fixes in an unreleased version, please download a ZIP file `directly from GitHub `_. +Unreleased +---------- + + v0.3.5 (2024-03-17) ------------------- diff --git a/mitogen/__init__.py b/mitogen/__init__.py index d030b966..9bd89669 100644 --- a/mitogen/__init__.py +++ b/mitogen/__init__.py @@ -35,7 +35,7 @@ be expected. On the slave, it is built dynamically during startup. #: Library version as a tuple. -__version__ = (0, 3, 5) +__version__ = (0, 3, 6, 'dev0') #: This is :data:`False` in slave contexts. Previously it was used to prevent From 50efa53f8fcb81ddd8f25c642efa0375e7538182 Mon Sep 17 00:00:00 2001 From: Alex Willmer Date: Wed, 27 Mar 2024 08:34:15 +0000 Subject: [PATCH 02/15] docs: Correct PEP 451 hyperlink --- docs/changelog.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index a9c96b4c..1087604e 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -27,7 +27,7 @@ v0.3.5 (2024-03-17) * :gh:issue:`987` Support Python 3.11 * :gh:issue:`885` Fix :py:exc:`PermissionError` in :py:mod:`importlib` when becoming an unprivileged user with Python 3.x -* :gh:issue:`1033` Support `PEP 451 , +* :gh:issue:`1033` Support `PEP 451 `_, required by Python 3.12 * :gh:issue:`1033` Support Python 3.12 From dfc3c7d5164355d1d873a86a1c601bd127fe7a09 Mon Sep 17 00:00:00 2001 From: Orion Poplawski Date: Tue, 13 Dec 2022 08:57:37 -0700 Subject: [PATCH 03/15] ansible_mitogen: Add Ansible 7 support Co-authored-by: Orion Poplawski --- .ci/azure-pipelines.yml | 11 +++++++---- ansible_mitogen/loaders.py | 2 +- docs/ansible_detailed.rst | 2 +- docs/changelog.rst | 2 ++ docs/contributors.rst | 1 + tox.ini | 6 ++++-- 6 files changed, 16 insertions(+), 8 deletions(-) diff --git a/.ci/azure-pipelines.yml b/.ci/azure-pipelines.yml index 3630f83e..468fd5bf 100644 --- a/.ci/azure-pipelines.yml +++ b/.ci/azure-pipelines.yml @@ -27,15 +27,15 @@ jobs: Loc_27_210: tox.env: py27-mode_localhost-ansible2.10 - Loc_312_6: + Loc_312_7: python.version: '3.12' - tox.env: py312-mode_localhost-ansible6 + tox.env: py312-mode_localhost-ansible7 Van_27_210: tox.env: py27-mode_localhost-ansible2.10-strategy_linear - Van_312_6: + Van_312_7: python.version: '3.12' - tox.env: py312-mode_localhost-ansible6-strategy_linear + tox.env: py312-mode_localhost-ansible7-strategy_linear - job: Linux pool: @@ -147,3 +147,6 @@ jobs: Ans_312_6: python.version: '3.12' tox.env: py312-mode_ansible-ansible6 + Ans_312_7: + python.version: '3.12' + tox.env: py312-mode_ansible-ansible7 diff --git a/ansible_mitogen/loaders.py b/ansible_mitogen/loaders.py index 1f4d8fc6..754ec6cb 100644 --- a/ansible_mitogen/loaders.py +++ b/ansible_mitogen/loaders.py @@ -49,7 +49,7 @@ __all__ = [ ANSIBLE_VERSION_MIN = (2, 10) -ANSIBLE_VERSION_MAX = (2, 13) +ANSIBLE_VERSION_MAX = (2, 14) 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 cb83aa71..09db3cd8 100644 --- a/docs/ansible_detailed.rst +++ b/docs/ansible_detailed.rst @@ -150,7 +150,7 @@ Noteworthy Differences - Ansible 2.10, 3, and 4; with Python 2.7, or 3.6-3.11 - Ansible 5; with Python 3.8-3.11 - - Ansible 6; with Python 3.8-3.12 + - Ansible 6 and 7; with Python 3.8-3.12 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 1087604e..f5fd7a4b 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -20,6 +20,8 @@ To avail of fixes in an unreleased version, please download a ZIP file Unreleased ---------- +* :gh:issue:`974` Support Ansible 7 + v0.3.5 (2024-03-17) ------------------- diff --git a/docs/contributors.rst b/docs/contributors.rst index 61a9eb1b..207e4d7b 100644 --- a/docs/contributors.rst +++ b/docs/contributors.rst @@ -130,6 +130,7 @@ sponsorship and outstanding future-thinking of its early adopters.
  • luto
  • Mayeu a.k.a Matthieu Maury
  • @nathanhruby
  • +
  • Orion Poplawski
  • Ramy
  • Scott Vokes
  • Tom Eichhorn
  • diff --git a/tox.ini b/tox.ini index 4a1772a0..f2b46413 100644 --- a/tox.ini +++ b/tox.ini @@ -57,7 +57,7 @@ envlist = init, py{27,36}-mode_ansible-ansible{2.10,3,4}, py{311}-mode_ansible-ansible{2.10,3,4,5}, - py{312}-mode_ansible-ansible{6}, + py{312}-mode_ansible-ansible{6,7}, py{27,36,312}-mode_mitogen-distro_centos{6,7,8}, py{27,36,312}-mode_mitogen-distro_debian{9,10,11}, py{27,36,312}-mode_mitogen-distro_ubuntu{1604,1804,2004}, @@ -83,6 +83,7 @@ deps = ansible4: ansible==4.10.0 ansible5: ansible~=5.0 ansible6: ansible~=6.0 + ansible7: ansible~=7.0 install_command = python -m pip --no-python-version-warning --disable-pip-version-check install {opts} {packages} commands_pre = @@ -118,8 +119,9 @@ setenv = distro_ubuntu1804: DISTRO=ubuntu1804 distro_ubuntu2004: DISTRO=ubuntu2004 # Note the plural, only applicable to MODE=ansible - # Ansible 6 (ansible-core 2.13) requires Python >= 2.7 or >= 3.5 on targets + # Ansible >= 6 (ansible-core >= 2.13) require Python 2.7 or >= 3.5 on targets ansible6: DISTROS=centos7 centos8 debian9 debian10 debian11 ubuntu1604 ubuntu1804 ubuntu2004 + ansible7: DISTROS=centos7 centos8 debian9 debian10 debian11 ubuntu1604 ubuntu1804 ubuntu2004 distros_centos: DISTROS=centos6 centos7 centos8 distros_centos5: DISTROS=centos5 distros_centos6: DISTROS=centos6 From d7979c35978e1d4300ec5b883e37959dd315e1ce Mon Sep 17 00:00:00 2001 From: Alex Willmer Date: Thu, 28 Mar 2024 11:25:13 +0000 Subject: [PATCH 04/15] mitogen: Raise TypeError on `mitogen.utils.cast(custom_str)` failures If casting a string fails then raise a TypeError. This is potentially an API breaking change; chosen as the lesser evil vs. allowing silent errors. `cast()` relies on `bytes(obj)` & `str(obj)` returning the respective supertype. That's no longer the case for `AnsibleUnsafeBytes` & `AnsibleUnsafeText`; since fixes/mitigations for CVE-2023-5764. fixes #1046, refs #977 See also - https://github.com/advisories/GHSA-7j69-qfc3-2fq9 - https://github.com/ansible/ansible/pull/82293 --- docs/changelog.rst | 3 +++ mitogen/utils.py | 22 +++++++++++++++++---- tests/utils_test.py | 47 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 4 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index f5fd7a4b..ac20653b 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -21,6 +21,9 @@ Unreleased ---------- * :gh:issue:`974` Support Ansible 7 +* :gh:issue:`1046` Raise :py:exc:`TypeError` in :func:`` + when casting a string subtype to `bytes()` or `str()` fails. This is + potentially an API breaking change. Failures previously passed silently. v0.3.5 (2024-03-17) diff --git a/mitogen/utils.py b/mitogen/utils.py index 71f7c35f..1fbf71fe 100644 --- a/mitogen/utils.py +++ b/mitogen/utils.py @@ -190,10 +190,13 @@ PASSTHROUGH = ( def cast(obj): """ + Return obj (or a copy) with subtypes of builtins cast to their supertype. + Subtypes of those in :data:`PASSTHROUGH` are not modified. + Many tools love to subclass built-in types in order to implement useful functionality, such as annotating the safety of a Unicode string, or adding - additional methods to a dict. However, cPickle loves to preserve those - subtypes during serialization, resulting in CallError during :meth:`call + additional methods to a dict. However :py:mod:`pickle` serializes these + exactly, leading to :exc:`mitogen.CallError` during :meth:`Context.call ` in the target when it tries to deserialize the data. @@ -201,6 +204,9 @@ def cast(obj): custom sub-types removed. The functionality is not default since the resulting walk may be computationally expensive given a large enough graph. + Raises :py:exc:`TypeError` if an unknown subtype is encountered, or + casting does not return the desired supertype. + See :ref:`serialization-rules` for a list of supported types. :param obj: @@ -215,8 +221,16 @@ def cast(obj): if isinstance(obj, PASSTHROUGH): return obj if isinstance(obj, mitogen.core.UnicodeType): - return mitogen.core.UnicodeType(obj) + return _cast(obj, mitogen.core.UnicodeType) if isinstance(obj, mitogen.core.BytesType): - return mitogen.core.BytesType(obj) + return _cast(obj, mitogen.core.BytesType) raise TypeError("Cannot serialize: %r: %r" % (type(obj), obj)) + + +def _cast(obj, desired_type): + result = desired_type(obj) + if type(result) is not desired_type: + raise TypeError("Cast of %r to %r failed, got %r" + % (type(obj), desired_type, type(result))) + return result diff --git a/tests/utils_test.py b/tests/utils_test.py index 6c71d33c..37246961 100644 --- a/tests/utils_test.py +++ b/tests/utils_test.py @@ -44,6 +44,44 @@ class Unicode(mitogen.core.UnicodeType): pass class Bytes(mitogen.core.BytesType): pass +class StubbornBytes(mitogen.core.BytesType): + """ + A binary string type that persists through `bytes(...)`. + + Stand-in for `AnsibleUnsafeBytes()` in Ansible 7-9 (core 2.14-2.16), after + fixes/mitigations for CVE-2023-5764. + """ + if mitogen.core.PY3: + def __bytes__(self): return self + def __str__(self): return self.decode() + else: + def __str__(self): return self + def __unicode__(self): return self.decode() + + def decode(self, encoding='utf-8', errors='strict'): + s = super(StubbornBytes).encode(encoding=encoding, errors=errors) + return StubbornText(s) + + +class StubbornText(mitogen.core.UnicodeType): + """ + A text string type that persists through `unicode(...)` or `str(...)`. + + Stand-in for `AnsibleUnsafeText()` in Ansible 7-9 (core 2.14-2.16), after + following fixes/mitigations for CVE-2023-5764. + """ + if mitogen.core.PY3: + def __bytes__(self): return self.encode() + def __str__(self): return self + else: + def __str__(self): return self.encode() + def __unicode__(self): return self + + def encode(self, encoding='utf-8', errors='strict'): + s = super(StubbornText).encode(encoding=encoding, errors=errors) + return StubbornBytes(s) + + class CastTest(testlib.TestCase): def test_dict(self): self.assertEqual(type(mitogen.utils.cast({})), dict) @@ -91,6 +129,15 @@ class CastTest(testlib.TestCase): self.assertEqual(type(mitogen.utils.cast(b(''))), mitogen.core.BytesType) self.assertEqual(type(mitogen.utils.cast(Bytes())), mitogen.core.BytesType) + def test_stubborn_types_raise(self): + stubborn_bytes = StubbornBytes(b('abc')) + self.assertIs(stubborn_bytes, mitogen.core.BytesType(stubborn_bytes)) + self.assertRaises(TypeError, mitogen.utils.cast, stubborn_bytes) + + stubborn_text = StubbornText(u'abc') + self.assertIs(stubborn_text, mitogen.core.UnicodeType(stubborn_text)) + self.assertRaises(TypeError, mitogen.utils.cast, stubborn_text) + def test_unknown(self): self.assertRaises(TypeError, mitogen.utils.cast, set()) self.assertRaises(TypeError, mitogen.utils.cast, 4j) From 813f253d6b62a9cf0bfc82bd746d9b67ca391d53 Mon Sep 17 00:00:00 2001 From: Alex Willmer Date: Thu, 28 Mar 2024 11:36:32 +0000 Subject: [PATCH 05/15] ansible_mitogen: Make ansible_mitogens.utils a package Prep work for ansible_mitogen.utils.unsafe --- ansible_mitogen/{utils.py => utils/__init__.py} | 0 tests/ansible/tests/utils_test.py | 11 +++++++++++ 2 files changed, 11 insertions(+) rename ansible_mitogen/{utils.py => utils/__init__.py} (100%) create mode 100644 tests/ansible/tests/utils_test.py diff --git a/ansible_mitogen/utils.py b/ansible_mitogen/utils/__init__.py similarity index 100% rename from ansible_mitogen/utils.py rename to ansible_mitogen/utils/__init__.py diff --git a/tests/ansible/tests/utils_test.py b/tests/ansible/tests/utils_test.py new file mode 100644 index 00000000..05ee8bf0 --- /dev/null +++ b/tests/ansible/tests/utils_test.py @@ -0,0 +1,11 @@ +import unittest + +import ansible_mitogen.utils + + +class AnsibleVersionTest(unittest.TestCase): + def test_ansible_version(self): + self.assertIsInstance(ansible_mitogen.utils.ansible_version, tuple) + self.assertIsInstance(ansible_mitogen.utils.ansible_version[0], int) + self.assertIsInstance(ansible_mitogen.utils.ansible_version[1], int) + self.assertEqual(2, ansible_mitogen.utils.ansible_version[0]) From b822f20007ebe94106b15275962ea4cbbd8a0331 Mon Sep 17 00:00:00 2001 From: Alex Willmer Date: Thu, 28 Mar 2024 13:59:10 +0000 Subject: [PATCH 06/15] ansible_mitogen: Handle AnsibleUnsafeText et al in Ansible >= 7 Follwing fixes in Ansible 7-9 for CVE-2023-5764 cating `AnsibleUnsafeBytes` & `AnsibleUnsafeText` to `bytes()` or `str()` requires special handling. The handling is Ansible specific, so it shouldn't go in the mitogen package but rather the ansible_mitogen package. `ansible_mitogen.utils.unsafe.cast()` is most like `mitogen.utils.cast()`. During development it began as `ansible_mitogen.utils.unsafe.unwrap_var()`, closer to an inverse of `ansible.utils.unsafe_procy.wrap_var()`. Future enhancements may move in this direction. refs #977, refs #1046 See also - https://github.com/advisories/GHSA-7j69-qfc3-2fq9 - https://github.com/ansible/ansible/pull/82293 - https://github.com/mitogen-hq/mitogen/wiki/AnsibleUnsafe-notes --- ansible_mitogen/connection.py | 18 ++-- ansible_mitogen/mixins.py | 12 +-- ansible_mitogen/services.py | 4 +- ansible_mitogen/utils/unsafe.py | 79 ++++++++++++++++ docs/changelog.rst | 2 + .../integration/action/remote_expand_user.yml | 8 +- .../async/result_shell_echo_hi.yml | 8 +- .../_end_play_if_not_sudo_linux.yml | 2 +- .../stub_connections/setns_lxc.yml | 2 +- .../stub_connections/setns_lxd.yml | 2 +- tests/ansible/tests/utils_unsafe_test.py | 92 +++++++++++++++++++ tests/image_prep/_container_setup.yml | 2 +- 12 files changed, 203 insertions(+), 28 deletions(-) create mode 100644 ansible_mitogen/utils/unsafe.py create mode 100644 tests/ansible/tests/utils_unsafe_test.py diff --git a/ansible_mitogen/connection.py b/ansible_mitogen/connection.py index 44caf9ac..dfc3aec4 100644 --- a/ansible_mitogen/connection.py +++ b/ansible_mitogen/connection.py @@ -43,7 +43,6 @@ import ansible.errors import ansible.plugins.connection import mitogen.core -import mitogen.utils import ansible_mitogen.mixins import ansible_mitogen.parsing @@ -51,6 +50,7 @@ import ansible_mitogen.process import ansible_mitogen.services import ansible_mitogen.target import ansible_mitogen.transport_config +import ansible_mitogen.utils.unsafe LOG = logging.getLogger(__name__) @@ -797,7 +797,7 @@ class Connection(ansible.plugins.connection.ConnectionBase): call_context=self.binding.get_service_context(), service_name='ansible_mitogen.services.ContextService', method_name='get', - stack=mitogen.utils.cast(list(stack)), + stack=ansible_mitogen.utils.unsafe.cast(list(stack)), ) except mitogen.core.CallError: LOG.warning('Connection failed; stack configuration was:\n%s', @@ -848,7 +848,7 @@ class Connection(ansible.plugins.connection.ConnectionBase): inventory_name, stack = self._build_stack() worker_model = ansible_mitogen.process.get_worker_model() self.binding = worker_model.get_binding( - mitogen.utils.cast(inventory_name) + ansible_mitogen.utils.unsafe.cast(inventory_name) ) self._connect_stack(stack) @@ -933,7 +933,7 @@ class Connection(ansible.plugins.connection.ConnectionBase): call_context=binding.get_service_context(), service_name='ansible_mitogen.services.ContextService', method_name='reset', - stack=mitogen.utils.cast(list(stack)), + stack=ansible_mitogen.utils.unsafe.cast(list(stack)), ) finally: binding.close() @@ -1011,8 +1011,8 @@ class Connection(ansible.plugins.connection.ConnectionBase): emulate_tty = (not in_data and sudoable) rc, stdout, stderr = self.get_chain().call( ansible_mitogen.target.exec_command, - cmd=mitogen.utils.cast(cmd), - in_data=mitogen.utils.cast(in_data), + cmd=ansible_mitogen.utils.unsafe.cast(cmd), + in_data=ansible_mitogen.utils.unsafe.cast(in_data), chdir=mitogen_chdir or self.get_default_cwd(), emulate_tty=emulate_tty, ) @@ -1039,7 +1039,7 @@ class Connection(ansible.plugins.connection.ConnectionBase): ansible_mitogen.target.transfer_file( context=self.context, # in_path may be AnsibleUnicode - in_path=mitogen.utils.cast(in_path), + in_path=ansible_mitogen.utils.unsafe.cast(in_path), out_path=out_path ) @@ -1057,7 +1057,7 @@ class Connection(ansible.plugins.connection.ConnectionBase): """ self.get_chain().call_no_reply( ansible_mitogen.target.write_path, - mitogen.utils.cast(out_path), + ansible_mitogen.utils.unsafe.cast(out_path), mitogen.core.Blob(data), mode=mode, utimes=utimes, @@ -1119,7 +1119,7 @@ class Connection(ansible.plugins.connection.ConnectionBase): call_context=self.binding.get_service_context(), service_name='mitogen.service.FileService', method_name='register', - path=mitogen.utils.cast(in_path) + path=ansible_mitogen.utils.unsafe.cast(in_path) ) # For now this must remain synchronous, as the action plug-in may have diff --git a/ansible_mitogen/mixins.py b/ansible_mitogen/mixins.py index 690998f1..9cc97a48 100644 --- a/ansible_mitogen/mixins.py +++ b/ansible_mitogen/mixins.py @@ -50,12 +50,12 @@ import ansible.plugins.action import mitogen.core import mitogen.select -import mitogen.utils import ansible_mitogen.connection import ansible_mitogen.planner import ansible_mitogen.target import ansible_mitogen.utils +import ansible_mitogen.utils.unsafe from ansible.module_utils._text import to_text @@ -187,7 +187,7 @@ class ActionModuleMixin(ansible.plugins.action.ActionBase): LOG.debug('_remote_file_exists(%r)', path) return self._connection.get_chain().call( ansible_mitogen.target.file_exists, - mitogen.utils.cast(path) + ansible_mitogen.utils.unsafe.cast(path) ) def _configure_module(self, module_name, module_args, task_vars=None): @@ -324,7 +324,7 @@ class ActionModuleMixin(ansible.plugins.action.ActionBase): # ~root/.ansible -> /root/.ansible return self._connection.get_chain(use_login=(not sudoable)).call( os.path.expanduser, - mitogen.utils.cast(path), + ansible_mitogen.utils.unsafe.cast(path), ) def get_task_timeout_secs(self): @@ -387,11 +387,11 @@ class ActionModuleMixin(ansible.plugins.action.ActionBase): ansible_mitogen.planner.Invocation( action=self, connection=self._connection, - module_name=mitogen.core.to_text(module_name), - module_args=mitogen.utils.cast(module_args), + module_name=ansible_mitogen.utils.unsafe.cast(mitogen.core.to_text(module_name)), + module_args=ansible_mitogen.utils.unsafe.cast(module_args), task_vars=task_vars, templar=self._templar, - env=mitogen.utils.cast(env), + env=ansible_mitogen.utils.unsafe.cast(env), wrap_async=wrap_async, timeout_secs=self.get_task_timeout_secs(), ) diff --git a/ansible_mitogen/services.py b/ansible_mitogen/services.py index b0f5c70e..3e9de652 100644 --- a/ansible_mitogen/services.py +++ b/ansible_mitogen/services.py @@ -52,10 +52,10 @@ import ansible.constants import mitogen.core import mitogen.service -import mitogen.utils import ansible_mitogen.loaders import ansible_mitogen.module_finder import ansible_mitogen.target +import ansible_mitogen.utils.unsafe LOG = logging.getLogger(__name__) @@ -91,7 +91,7 @@ def _get_candidate_temp_dirs(): remote_tmp = ansible.constants.DEFAULT_REMOTE_TMP system_tmpdirs = ('/var/tmp', '/tmp') - return mitogen.utils.cast([remote_tmp] + list(system_tmpdirs)) + return ansible_mitogen.utils.unsafe.cast([remote_tmp] + list(system_tmpdirs)) def key_from_dict(**kwargs): diff --git a/ansible_mitogen/utils/unsafe.py b/ansible_mitogen/utils/unsafe.py new file mode 100644 index 00000000..b2c3d533 --- /dev/null +++ b/ansible_mitogen/utils/unsafe.py @@ -0,0 +1,79 @@ +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +import ansible +import ansible.utils.unsafe_proxy + +import ansible_mitogen.utils + +import mitogen +import mitogen.core +import mitogen.utils + +__all__ = [ + 'cast', +] + +def _cast_to_dict(obj): return {cast(k): cast(v) for k, v in obj.items()} +def _cast_to_list(obj): return [cast(v) for v in obj] +def _cast_unsafe(obj): return obj._strip_unsafe() +def _passthrough(obj): return obj + + +# A dispatch table to cast objects based on their exact type. +# This is an optimisation, reliable fallbacks are required (e.g. isinstance()) +_CAST_DISPATCH = { + bytes: bytes, + dict: _cast_to_dict, + list: _cast_to_list, + tuple: _cast_to_list, + mitogen.core.UnicodeType: mitogen.core.UnicodeType, +} +_CAST_DISPATCH.update({t: _passthrough for t in mitogen.utils.PASSTHROUGH}) + +if hasattr(ansible.utils.unsafe_proxy.AnsibleUnsafeText, '_strip_unsafe'): + _CAST_DISPATCH.update({ + ansible.utils.unsafe_proxy.AnsibleUnsafeBytes: _cast_unsafe, + ansible.utils.unsafe_proxy.AnsibleUnsafeText: _cast_unsafe, + ansible.utils.unsafe_proxy.NativeJinjaUnsafeText: _cast_unsafe, + }) +elif ansible_mitogen.utils.ansible_version[:2] <= (2, 16): + _CAST_DISPATCH.update({ + ansible.utils.unsafe_proxy.AnsibleUnsafeBytes: bytes, + ansible.utils.unsafe_proxy.AnsibleUnsafeText: mitogen.core.UnicodeType, + }) +else: + mitogen_ver = '.'.join(str(v) for v in mitogen.__version__) + raise ImportError("Mitogen %s can't unwrap Ansible %s AnsibleUnsafe objects" + % (mitogen_ver, ansible.__version__)) + + +def cast(obj): + """ + Return obj (or a copy) with subtypes of builtins cast to their supertype. + + This is an enhanced version of :func:`mitogen.utils.cast`. In addition it + handles ``ansible.utils.unsafe_proxy.AnsibleUnsafeText`` and variants. + + There are types handled by :func:`ansible.utils.unsafe_proxy.wrap_var()` + that this function currently does not handle (e.g. `set()`), or preserve + preserve (e.g. `tuple()`). Future enhancements may change this. + + :param obj: + Object to undecorate. + :returns: + Undecorated object. + """ + # Fast path: obj is a known type, dispatch directly + try: + unwrapper = _CAST_DISPATCH[type(obj)] + except KeyError: + pass + else: + return unwrapper(obj) + + # Slow path: obj is some unknown subclass + if isinstance(obj, dict): return _cast_to_dict(obj) + if isinstance(obj, (list, tuple)): return _cast_to_list(obj) + + return mitogen.utils.cast(obj) diff --git a/docs/changelog.rst b/docs/changelog.rst index ac20653b..8a62b9fe 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -24,6 +24,8 @@ Unreleased * :gh:issue:`1046` Raise :py:exc:`TypeError` in :func:`` when casting a string subtype to `bytes()` or `str()` fails. This is potentially an API breaking change. Failures previously passed silently. +* :gh:issue:`1046` Add :func:``, to cast + :class:`ansible.utils.unsafe_proxy.AnsibleUnsafe` objects in Ansible 7+. v0.3.5 (2024-03-17) diff --git a/tests/ansible/integration/action/remote_expand_user.yml b/tests/ansible/integration/action/remote_expand_user.yml index 3a675635..97dd02f9 100644 --- a/tests/ansible/integration/action/remote_expand_user.yml +++ b/tests/ansible/integration/action/remote_expand_user.yml @@ -25,7 +25,7 @@ sudoable: false register: out - assert: - that: out.result == '{{user_facts.ansible_facts.ansible_user_dir}}/foo' + that: out.result == user_facts.ansible_facts.ansible_user_dir ~ '/foo' fail_msg: out={{out}} - name: "Expand ~/foo with become active. ~ is become_user's home." @@ -48,7 +48,7 @@ sudoable: false register: out - assert: - that: out.result == '{{user_facts.ansible_facts.ansible_user_dir}}/foo' + that: out.result == user_facts.ansible_facts.ansible_user_dir ~ '/foo' fail_msg: out={{out}} - name: "Expanding $HOME/foo has no effect." @@ -72,7 +72,7 @@ sudoable: true register: out - assert: - that: out.result == '{{user_facts.ansible_facts.ansible_user_dir}}/foo' + that: out.result == user_facts.ansible_facts.ansible_user_dir ~ '/foo' fail_msg: out={{out}} - name: "sudoable; Expand ~/foo with become active. ~ is become_user's home." @@ -96,7 +96,7 @@ sudoable: true register: out - assert: - that: out.result == '{{user_facts.ansible_facts.ansible_user_dir}}/foo' + that: out.result == user_facts.ansible_facts.ansible_user_dir ~ '/foo' fail_msg: out={{out}} - name: "sudoable; Expanding $HOME/foo has no effect." diff --git a/tests/ansible/integration/async/result_shell_echo_hi.yml b/tests/ansible/integration/async/result_shell_echo_hi.yml index f327a965..8cac07a8 100644 --- a/tests/ansible/integration/async/result_shell_echo_hi.yml +++ b/tests/ansible/integration/async/result_shell_echo_hi.yml @@ -32,10 +32,12 @@ - async_out.invocation.module_args.creates == None - async_out.invocation.module_args.executable == None - async_out.invocation.module_args.removes == None - # In Ansible 4 (ansible-core 2.11) the warn parameter is deprecated and defaults to false. - # It's scheduled for removal in ansible-core 2.13. - - (ansible_version.full is version("2.11", "<", strict=True) and async_out.invocation.module_args.warn == True) + # | Ansible <= 3 | ansible-core <= 2.10 | present | True | + # | Ansible 4 - 6 | ansible-core 2.11 - 2.13 | deprecated | False | + # | Ansible >= 7 | ansible-core >= 2.14 | absent | n/a | + - (ansible_version.full is version("2.14", ">=", strict=True) and async_out.invocation.module_args.warn is not defined) or (ansible_version.full is version("2.11", ">=", strict=True) and async_out.invocation.module_args.warn == False) + or (async_out.invocation.module_args.warn == True) - async_out.rc == 0 - async_out.start.startswith("20") - async_out.stderr == "there" diff --git a/tests/ansible/integration/stub_connections/_end_play_if_not_sudo_linux.yml b/tests/ansible/integration/stub_connections/_end_play_if_not_sudo_linux.yml index 55997a72..a53f75ed 100644 --- a/tests/ansible/integration/stub_connections/_end_play_if_not_sudo_linux.yml +++ b/tests/ansible/integration/stub_connections/_end_play_if_not_sudo_linux.yml @@ -9,7 +9,7 @@ - command: sudo -n whoami args: - warn: false + warn: "{{ False if ansible_version.full is version('2.10', '<=', strict=True) else omit }}" ignore_errors: true register: sudo_available diff --git a/tests/ansible/integration/stub_connections/setns_lxc.yml b/tests/ansible/integration/stub_connections/setns_lxc.yml index 75d4207b..489f9883 100644 --- a/tests/ansible/integration/stub_connections/setns_lxc.yml +++ b/tests/ansible/integration/stub_connections/setns_lxc.yml @@ -27,7 +27,7 @@ localhost args: chdir: ../.. - warn: false + warn: "{{ False if ansible_version.full is version('2.10', '<=', strict=True) else omit }}" register: result - assert: diff --git a/tests/ansible/integration/stub_connections/setns_lxd.yml b/tests/ansible/integration/stub_connections/setns_lxd.yml index 3f3bc291..d654b7bc 100644 --- a/tests/ansible/integration/stub_connections/setns_lxd.yml +++ b/tests/ansible/integration/stub_connections/setns_lxd.yml @@ -27,7 +27,7 @@ localhost args: chdir: ../.. - warn: false + warn: "{{ False if ansible_version.full is version('2.10', '<=', strict=True) else omit }}" register: result - assert: diff --git a/tests/ansible/tests/utils_unsafe_test.py b/tests/ansible/tests/utils_unsafe_test.py new file mode 100644 index 00000000..a020f55b --- /dev/null +++ b/tests/ansible/tests/utils_unsafe_test.py @@ -0,0 +1,92 @@ +import unittest + +from ansible.utils.unsafe_proxy import AnsibleUnsafeBytes +from ansible.utils.unsafe_proxy import AnsibleUnsafeText +from ansible.utils.unsafe_proxy import wrap_var + +import ansible_mitogen.utils.unsafe + +import mitogen.core + + +class Bytes(bytes): pass +class Dict(dict): pass +class List(list): pass +class Set(set): pass +class Text(mitogen.core.UnicodeType): pass +class Tuple(tuple): pass + + +class CastTest(unittest.TestCase): + def assertIsType(self, obj, cls, msg=None): + self.assertIs(type(obj), cls, msg) + + def assertUnchanged(self, obj): + self.assertIs(ansible_mitogen.utils.unsafe.cast(obj), obj) + + def assertCasts(self, obj, expected): + cast = ansible_mitogen.utils.unsafe.cast + self.assertEqual(cast(obj), expected) + self.assertIsType(cast(obj), type(expected)) + + def test_ansible_unsafe(self): + self.assertCasts(AnsibleUnsafeBytes(b'abc'), b'abc') + self.assertCasts(AnsibleUnsafeText(u'abc'), u'abc') + + def test_passthrough(self): + self.assertUnchanged(0) + self.assertUnchanged(0.0) + self.assertUnchanged(False) + self.assertUnchanged(True) + self.assertUnchanged(None) + self.assertUnchanged(b'') + self.assertUnchanged(u'') + + def test_builtins_roundtrip(self): + self.assertCasts(wrap_var(b''), b'') + self.assertCasts(wrap_var({}), {}) + self.assertCasts(wrap_var([]), []) + self.assertCasts(wrap_var(u''), u'') + self.assertCasts(wrap_var(()), []) + + def test_subtypes_roundtrip(self): + self.assertCasts(wrap_var(Bytes()), b'') + self.assertCasts(wrap_var(Dict()), {}) + self.assertCasts(wrap_var(List()), []) + self.assertCasts(wrap_var(Text()), u'') + self.assertCasts(wrap_var(Tuple()), []) + + def test_subtype_nested_dict(self): + obj = Dict(foo=Dict(bar=u'abc')) + wrapped = wrap_var(obj) + unwrapped = ansible_mitogen.utils.unsafe.cast(wrapped) + self.assertEqual(unwrapped, {'foo': {'bar': u'abc'}}) + self.assertIsType(unwrapped, dict) + self.assertIsType(unwrapped['foo'], dict) + self.assertIsType(unwrapped['foo']['bar'], mitogen.core.UnicodeType) + + def test_subtype_roundtrip_list(self): + # wrap_var() preserves sequence types, cast() does not (for now) + obj = List([List([u'abc'])]) + wrapped = wrap_var(obj) + unwrapped = ansible_mitogen.utils.unsafe.cast(wrapped) + self.assertEqual(unwrapped, [[u'abc']]) + self.assertIsType(unwrapped, list) + self.assertIsType(unwrapped[0], list) + self.assertIsType(unwrapped[0][0], mitogen.core.UnicodeType) + + def test_subtype_roundtrip_tuple(self): + # wrap_var() preserves sequence types, cast() does not (for now) + obj = Tuple([Tuple([u'abc'])]) + wrapped = wrap_var(obj) + unwrapped = ansible_mitogen.utils.unsafe.cast(wrapped) + self.assertEqual(unwrapped, [[u'abc']]) + self.assertIsType(unwrapped, list) + self.assertIsType(unwrapped[0], list) + self.assertIsType(unwrapped[0][0], mitogen.core.UnicodeType) + + def test_unknown_types_raise(self): + cast = ansible_mitogen.utils.unsafe.cast + self.assertRaises(TypeError, cast, set()) + self.assertRaises(TypeError, cast, Set()) + self.assertRaises(TypeError, cast, 4j) diff --git a/tests/image_prep/_container_setup.yml b/tests/image_prep/_container_setup.yml index 353a7d5b..d41d1326 100644 --- a/tests/image_prep/_container_setup.yml +++ b/tests/image_prep/_container_setup.yml @@ -57,7 +57,7 @@ dnf: dnf clean all command: "{{ clean_command[ansible_pkg_mgr] }}" args: - warn: false + warn: "{{ False if ansible_version.full is version('2.10', '<=', strict=True) else omit }}" - name: Clean up apt package lists shell: rm -rf {{item}}/* From 5d789faee5ed443ffddb76e2b35cacb896c5e88d Mon Sep 17 00:00:00 2001 From: Alex Willmer Date: Thu, 4 Apr 2024 09:40:30 +0100 Subject: [PATCH 07/15] Prepare 0.3.6 --- docs/changelog.rst | 4 ++-- docs/conf.py | 2 +- mitogen/__init__.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 8a62b9fe..b583dafd 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -17,8 +17,8 @@ Release Notes To avail of fixes in an unreleased version, please download a ZIP file `directly from GitHub `_. -Unreleased ----------- +v0.3.6 (2024-04-04) +------------------- * :gh:issue:`974` Support Ansible 7 * :gh:issue:`1046` Raise :py:exc:`TypeError` in :func:`` diff --git a/docs/conf.py b/docs/conf.py index fb9974cb..0e201d44 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -2,7 +2,7 @@ import sys sys.path.append('.') -VERSION = '0.3.5' +VERSION = '0.3.6' author = u'Network Genomics' copyright = u'2021, the Mitogen authors' diff --git a/mitogen/__init__.py b/mitogen/__init__.py index 9bd89669..dd85245c 100644 --- a/mitogen/__init__.py +++ b/mitogen/__init__.py @@ -35,7 +35,7 @@ be expected. On the slave, it is built dynamically during startup. #: Library version as a tuple. -__version__ = (0, 3, 6, 'dev0') +__version__ = (0, 3, 6) #: This is :data:`False` in slave contexts. Previously it was used to prevent From 933477fcbef4a48a5da71838fd9571cffb5dce3c Mon Sep 17 00:00:00 2001 From: Alex Willmer Date: Thu, 4 Apr 2024 09:44:10 +0100 Subject: [PATCH 08/15] Begin 0.3.7dev --- docs/changelog.rst | 5 +++++ mitogen/__init__.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index b583dafd..6767644d 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -17,6 +17,11 @@ Release Notes To avail of fixes in an unreleased version, please download a ZIP file `directly from GitHub `_. + +Unreleased +---------- + + v0.3.6 (2024-04-04) ------------------- diff --git a/mitogen/__init__.py b/mitogen/__init__.py index dd85245c..d08d9883 100644 --- a/mitogen/__init__.py +++ b/mitogen/__init__.py @@ -35,7 +35,7 @@ be expected. On the slave, it is built dynamically during startup. #: Library version as a tuple. -__version__ = (0, 3, 6) +__version__ = (0, 3, 7, 'dev') #: This is :data:`False` in slave contexts. Previously it was used to prevent From 58235e3675579a06d55e328d8d00045705c0cae0 Mon Sep 17 00:00:00 2001 From: Alexandre Detiste Date: Tue, 26 Mar 2024 09:15:41 +0100 Subject: [PATCH 09/15] add Python3 compatibility --- scripts/pogrep.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/pogrep.py b/scripts/pogrep.py index b837bcfd..80094c74 100644 --- a/scripts/pogrep.py +++ b/scripts/pogrep.py @@ -6,6 +6,7 @@ # - apt-get source libpam0g # - cd */po/ # - python ~/pogrep.py "Password: " +from __future__ import print_function import sys import shlex @@ -31,7 +32,7 @@ for path in glob.glob('*.po'): if last_word == 'msgid' and word == 'msgstr': if last_rest == sys.argv[1]: thing = rest.rstrip(': ').decode('utf-8').lower().encode('utf-8').encode('base64').rstrip() - print ' %-60s # %s' % (repr(thing)+',', path) + print(' %-60s # %s' % (repr(thing)+',', path)) last_word = word last_rest = rest From fe54b0ac3fcd47af2a4242f6949b7de4d2674df6 Mon Sep 17 00:00:00 2001 From: Alexandre Detiste Date: Tue, 26 Mar 2024 09:16:11 +0100 Subject: [PATCH 10/15] prefer newer unittest.mock from the standad library --- tests/ansible/tests/connection_test.py | 6 +++++- tests/ansible/tests/target_test.py | 5 ++++- tests/broker_test.py | 5 ++++- tests/importer_test.py | 5 ++++- tests/io_op_test.py | 5 ++++- tests/log_handler_test.py | 6 +++++- tests/message_test.py | 5 ++++- tests/mitogen_protocol_test.py | 5 ++++- tests/parent_test.py | 5 ++++- tests/policy_function_test.py | 5 ++++- tests/reaper_test.py | 5 ++++- tests/responder_test.py | 6 +++++- tests/timer_test.py | 5 ++++- 13 files changed, 55 insertions(+), 13 deletions(-) diff --git a/tests/ansible/tests/connection_test.py b/tests/ansible/tests/connection_test.py index 0ade6994..649f8b65 100644 --- a/tests/ansible/tests/connection_test.py +++ b/tests/ansible/tests/connection_test.py @@ -2,7 +2,11 @@ from __future__ import absolute_import import os import tempfile -import mock +try: + from unittest import mock +except ImportError: + import mock + import ansible.errors import ansible.playbook.play_context diff --git a/tests/ansible/tests/target_test.py b/tests/ansible/tests/target_test.py index 0e588baa..806175ed 100644 --- a/tests/ansible/tests/target_test.py +++ b/tests/ansible/tests/target_test.py @@ -4,7 +4,10 @@ import subprocess import tempfile import unittest -import mock +try: + from unittest import mock +except ImportError: + import mock import ansible_mitogen.target import testlib diff --git a/tests/broker_test.py b/tests/broker_test.py index d58d9480..41b95387 100644 --- a/tests/broker_test.py +++ b/tests/broker_test.py @@ -1,4 +1,7 @@ -import mock +try: + from unittest import mock +except ImportError: + import mock import testlib diff --git a/tests/importer_test.py b/tests/importer_test.py index e86af8af..33aafe93 100644 --- a/tests/importer_test.py +++ b/tests/importer_test.py @@ -4,7 +4,10 @@ import types import zlib import unittest -import mock +try: + from unittest import mock +except ImportError: + import mock import mitogen.core import mitogen.utils diff --git a/tests/io_op_test.py b/tests/io_op_test.py index 55adfa11..e0ad65f1 100644 --- a/tests/io_op_test.py +++ b/tests/io_op_test.py @@ -1,7 +1,10 @@ import errno import select -import mock +try: + from unittest import mock +except ImportError: + import mock import testlib import mitogen.core diff --git a/tests/log_handler_test.py b/tests/log_handler_test.py index 43b986cb..da929426 100644 --- a/tests/log_handler_test.py +++ b/tests/log_handler_test.py @@ -1,8 +1,12 @@ import logging -import mock import sys import unittest +try: + from unittest import mock +except ImportError: + import mock + import testlib import mitogen.core import mitogen.master diff --git a/tests/message_test.py b/tests/message_test.py index 2d2299d1..fc50a327 100644 --- a/tests/message_test.py +++ b/tests/message_test.py @@ -2,7 +2,10 @@ import sys import struct import unittest -import mock +try: + from unittest import mock +except ImportError: + import mock import mitogen.core import mitogen.master diff --git a/tests/mitogen_protocol_test.py b/tests/mitogen_protocol_test.py index d6e3cc95..46a0cd65 100644 --- a/tests/mitogen_protocol_test.py +++ b/tests/mitogen_protocol_test.py @@ -1,4 +1,7 @@ -import mock +try: + from unittest import mock +except ImportError: + import mock import mitogen.core diff --git a/tests/parent_test.py b/tests/parent_test.py index fa7e4fb7..558a89b6 100644 --- a/tests/parent_test.py +++ b/tests/parent_test.py @@ -6,7 +6,10 @@ import sys import time import unittest -import mock +try: + from unittest import mock +except ImportError: + import mock import testlib import mitogen.core diff --git a/tests/policy_function_test.py b/tests/policy_function_test.py index 843f8b7c..77bd17d1 100644 --- a/tests/policy_function_test.py +++ b/tests/policy_function_test.py @@ -1,4 +1,7 @@ -import mock +try: + from unittest import mock +except ImportError: + import mock import mitogen.core import mitogen.parent diff --git a/tests/reaper_test.py b/tests/reaper_test.py index b60b13a4..8588a1bc 100644 --- a/tests/reaper_test.py +++ b/tests/reaper_test.py @@ -1,7 +1,10 @@ import signal import testlib -import mock +try: + from unittest import mock +except ImportError: + import mock import mitogen.parent diff --git a/tests/responder_test.py b/tests/responder_test.py index 1131b421..d1e65816 100644 --- a/tests/responder_test.py +++ b/tests/responder_test.py @@ -1,9 +1,13 @@ -import mock import textwrap import subprocess import sys import unittest +try: + from unittest import mock +except ImportError: + import mock + import mitogen.master import testlib diff --git a/tests/timer_test.py b/tests/timer_test.py index dac4d7df..f8f203a9 100644 --- a/tests/timer_test.py +++ b/tests/timer_test.py @@ -1,4 +1,7 @@ -import mock +try: + from unittest import mock +except ImportError: + import mock import mitogen.core import mitogen.parent From 2333b9aced6c2567ac2fa65f6e38b6ecfb227043 Mon Sep 17 00:00:00 2001 From: Alex Willmer Date: Thu, 4 Apr 2024 15:46:29 +0100 Subject: [PATCH 11/15] ci: Exclude docs-master branch --- .ci/azure-pipelines.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.ci/azure-pipelines.yml b/.ci/azure-pipelines.yml index 468fd5bf..b7d528bb 100644 --- a/.ci/azure-pipelines.yml +++ b/.ci/azure-pipelines.yml @@ -8,6 +8,13 @@ #variables: #ANSIBLE_VERBOSITY: 3 +trigger: + branches: + include: + - "*" + exclude: + - docs-master + jobs: - job: mac11 # vanilla Ansible is really slow From fa1d21747fbc06e4043d9af78c376f7ceaa3eecd Mon Sep 17 00:00:00 2001 From: Alex Willmer Date: Thu, 4 Apr 2024 15:47:51 +0100 Subject: [PATCH 12/15] ansible_mitogen: Declare Ansible 8 (ansible-core 2.15) support refs #1021 --- .ci/azure-pipelines.yml | 11 +++++++---- ansible_mitogen/loaders.py | 2 +- docs/ansible_detailed.rst | 20 +++++++++++++++++--- docs/changelog.rst | 2 ++ tox.ini | 4 +++- 5 files changed, 30 insertions(+), 9 deletions(-) diff --git a/.ci/azure-pipelines.yml b/.ci/azure-pipelines.yml index b7d528bb..7e84e779 100644 --- a/.ci/azure-pipelines.yml +++ b/.ci/azure-pipelines.yml @@ -34,15 +34,15 @@ jobs: Loc_27_210: tox.env: py27-mode_localhost-ansible2.10 - Loc_312_7: + Loc_312_8: python.version: '3.12' - tox.env: py312-mode_localhost-ansible7 + tox.env: py312-mode_localhost-ansible8 Van_27_210: tox.env: py27-mode_localhost-ansible2.10-strategy_linear - Van_312_7: + Van_312_8: python.version: '3.12' - tox.env: py312-mode_localhost-ansible7-strategy_linear + tox.env: py312-mode_localhost-ansible8-strategy_linear - job: Linux pool: @@ -157,3 +157,6 @@ jobs: Ans_312_7: python.version: '3.12' tox.env: py312-mode_ansible-ansible7 + Ans_312_8: + python.version: '3.12' + tox.env: py312-mode_ansible-ansible8 diff --git a/ansible_mitogen/loaders.py b/ansible_mitogen/loaders.py index 754ec6cb..11015430 100644 --- a/ansible_mitogen/loaders.py +++ b/ansible_mitogen/loaders.py @@ -49,7 +49,7 @@ __all__ = [ ANSIBLE_VERSION_MIN = (2, 10) -ANSIBLE_VERSION_MAX = (2, 14) +ANSIBLE_VERSION_MAX = (2, 15) 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 09db3cd8..1f6ac9a6 100644 --- a/docs/ansible_detailed.rst +++ b/docs/ansible_detailed.rst @@ -148,9 +148,23 @@ Noteworthy Differences * Mitogen 0.2.x supports Ansible 2.3-2.9; with Python 2.6, 2.7, or 3.6. Mitogen 0.3.1+ supports - - Ansible 2.10, 3, and 4; with Python 2.7, or 3.6-3.11 - - Ansible 5; with Python 3.8-3.11 - - Ansible 6 and 7; with Python 3.8-3.12 + +-----------------+-----------------+ + | Ansible version | Python versions | + +=================+=================+ + | 2.10 | | + +-----------------+ | + | 3 | 2.7, 3.6 - 3.11 | + +-----------------+ | + | 4 | | + +-----------------+-----------------+ + | 5 | 3.8 - 3.11 | + +-----------------+-----------------+ + | 6 | | + +-----------------+ 3.8 - 3.12 | + | 7 | | + +-----------------+-----------------+ + | 8 | 3.9 - 3.12 | + +-----------------+-----------------+ 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 6767644d..51b359a9 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -21,6 +21,8 @@ To avail of fixes in an unreleased version, please download a ZIP file Unreleased ---------- +* :gh:issue:`1021` Support for Ansible 8 (ansible-core 2.15) + v0.3.6 (2024-04-04) ------------------- diff --git a/tox.ini b/tox.ini index f2b46413..435d5e65 100644 --- a/tox.ini +++ b/tox.ini @@ -57,7 +57,7 @@ envlist = init, py{27,36}-mode_ansible-ansible{2.10,3,4}, py{311}-mode_ansible-ansible{2.10,3,4,5}, - py{312}-mode_ansible-ansible{6,7}, + py{312}-mode_ansible-ansible{6,7,8}, py{27,36,312}-mode_mitogen-distro_centos{6,7,8}, py{27,36,312}-mode_mitogen-distro_debian{9,10,11}, py{27,36,312}-mode_mitogen-distro_ubuntu{1604,1804,2004}, @@ -84,6 +84,7 @@ deps = ansible5: ansible~=5.0 ansible6: ansible~=6.0 ansible7: ansible~=7.0 + ansible8: ansible~=8.0 install_command = python -m pip --no-python-version-warning --disable-pip-version-check install {opts} {packages} commands_pre = @@ -122,6 +123,7 @@ setenv = # Ansible >= 6 (ansible-core >= 2.13) require Python 2.7 or >= 3.5 on targets ansible6: DISTROS=centos7 centos8 debian9 debian10 debian11 ubuntu1604 ubuntu1804 ubuntu2004 ansible7: DISTROS=centos7 centos8 debian9 debian10 debian11 ubuntu1604 ubuntu1804 ubuntu2004 + ansible8: DISTROS=centos7 centos8 debian9 debian10 debian11 ubuntu1604 ubuntu1804 ubuntu2004 distros_centos: DISTROS=centos6 centos7 centos8 distros_centos5: DISTROS=centos5 distros_centos6: DISTROS=centos6 From 45c42d386ac8b96ec2ecca5179a2c4108fd0aac9 Mon Sep 17 00:00:00 2001 From: Alex Willmer Date: Fri, 5 Apr 2024 17:41:55 +0100 Subject: [PATCH 13/15] tests: Replace uses of ``include:``, unify skipping of mitogen only tests The tag mitogen_only is only informational for now. It may be possible to use it with ANSIBLE_SKIP_TAGS in the future. --- docs/changelog.rst | 1 + .../integration/action/make_tmp_path.yml | 4 +- .../async/runner_timeout_then_polling.yml | 5 +- .../integration/become/sudo_requiretty.yml | 6 +-- .../connection/become_same_user.yml | 6 +-- .../connection/disconnect_during_module.yml | 4 +- .../disconnect_resets_connection.yml | 4 +- .../integration/connection/home_dir.yml | 7 ++- .../integration/connection/put_large_file.yml | 2 +- .../integration/connection/put_small_file.yml | 2 +- .../ansible/integration/connection/reset.yml | 4 +- .../delegate_to_template.yml | 4 +- .../connection_delegation/local_action.yml | 4 +- .../osa_container_standalone.yml | 4 +- .../osa_delegate_to_self.yml | 4 +- .../stack_construction.yml | 48 +++++++------------ .../context_service/disconnect_cleanup.yml | 4 +- .../context_service/remote_name.yml | 4 +- ...m_python_new_style_missing_interpreter.yml | 4 +- .../runner/custom_python_new_style_module.yml | 4 +- .../custom_python_prehistoric_module.yml | 5 +- .../integration/runner/etc_environment.yml | 2 +- .../integration/runner/forking_active.yml | 5 +- .../runner/forking_correct_parent.yml | 12 ++--- .../integration/runner/forking_inactive.yml | 5 +- tests/ansible/integration/ssh/config.yml | 4 +- tests/ansible/integration/ssh/timeouts.yml | 5 +- tests/ansible/integration/ssh/variables.yml | 16 ++----- .../integration/stub_connections/kubectl.yml | 4 +- .../integration/stub_connections/lxc.yml | 4 +- .../integration/stub_connections/lxd.yml | 4 +- .../stub_connections/mitogen_doas.yml | 4 +- .../stub_connections/mitogen_sudo.yml | 4 +- .../stub_connections/setns_lxc.yml | 7 ++- .../stub_connections/setns_lxd.yml | 7 ++- tests/ansible/integration/transport/all.yml | 2 +- .../integration/transport_config/become.yml | 16 +++++-- .../transport_config/become_method.yml | 20 ++++++-- .../transport_config/become_pass.yml | 36 ++++++++++---- .../transport_config/become_user.yml | 24 +++++++--- .../integration/transport_config/password.yml | 32 +++++++++---- .../integration/transport_config/port.yml | 32 +++++++++---- .../transport_config/python_path.yml | 40 ++++++++++++---- .../transport_config/remote_addr.yml | 32 +++++++++---- .../transport_config/remote_user.yml | 30 ++++++++---- .../transport_config/transport.yml | 16 +++++-- .../transport_config/transport__smart.yml | 16 +++++-- tests/ansible/regression/_mitogen_only.yml | 1 + .../issue_591__setuptools_cwd_crash.yml | 4 +- .../issue_615__streaming_transfer.yml | 4 +- tests/ansible/soak/file_service.yml | 2 +- tests/image_prep/setup.yml | 8 ++-- 52 files changed, 324 insertions(+), 204 deletions(-) create mode 120000 tests/ansible/regression/_mitogen_only.yml diff --git a/docs/changelog.rst b/docs/changelog.rst index 51b359a9..8e979a1a 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -22,6 +22,7 @@ Unreleased ---------- * :gh:issue:`1021` Support for Ansible 8 (ansible-core 2.15) +* tests: Replace uses of ``include:`` & ``import:``, unsupported in Ansible 9 v0.3.6 (2024-04-04) diff --git a/tests/ansible/integration/action/make_tmp_path.yml b/tests/ansible/integration/action/make_tmp_path.yml index 8e981250..1f710c5a 100644 --- a/tests/ansible/integration/action/make_tmp_path.yml +++ b/tests/ansible/integration/action/make_tmp_path.yml @@ -10,8 +10,7 @@ - name: integration/action/make_tmp_path.yml hosts: test-targets tasks: - - meta: end_play - when: not is_mitogen + - include_tasks: ../_mitogen_only.yml # # non-root @@ -161,3 +160,4 @@ fail_msg: out={{out}} tags: - make_tmp_path + - mitogen_only diff --git a/tests/ansible/integration/async/runner_timeout_then_polling.yml b/tests/ansible/integration/async/runner_timeout_then_polling.yml index 2f71ebe4..e3aa5d37 100644 --- a/tests/ansible/integration/async/runner_timeout_then_polling.yml +++ b/tests/ansible/integration/async/runner_timeout_then_polling.yml @@ -3,6 +3,7 @@ - name: integration/async/runner_timeout_then_polling.yml hosts: test-targets tasks: + - include_tasks: ../_mitogen_only.yml # Verify async-with-timeout-then-poll behaviour. # This is semi-broken in upstream Ansible, it does not bother to update the @@ -13,7 +14,6 @@ async: 1 poll: 0 register: job - when: is_mitogen - name: busy-poll up to 500 times async_status: @@ -22,7 +22,6 @@ until: result.finished retries: 500 delay: 0 - when: is_mitogen ignore_errors: true - assert: @@ -31,6 +30,6 @@ - result.finished == 1 - result.msg == "Job reached maximum time limit of 1 seconds." fail_msg: result={{result}} - when: is_mitogen tags: + - mitogen_only - runner_timeout_then_polling diff --git a/tests/ansible/integration/become/sudo_requiretty.yml b/tests/ansible/integration/become/sudo_requiretty.yml index 19b49b28..20f106fc 100644 --- a/tests/ansible/integration/become/sudo_requiretty.yml +++ b/tests/ansible/integration/become/sudo_requiretty.yml @@ -3,6 +3,7 @@ - name: integration/become/sudo_requiretty.yml hosts: test-targets tasks: + # - include_tasks: ../_mitogen_only.yml # TODO: https://github.com/dw/mitogen/issues/692 # - name: Verify we can login to a non-passworded requiretty account @@ -10,12 +11,10 @@ # become: true # become_user: mitogen__require_tty # register: out - # when: is_mitogen # - assert: # that: # - out.stdout == 'mitogen__require_tty' - # when: is_mitogen # --------------- @@ -28,12 +27,11 @@ # vars: # ansible_become_pass: require_tty_pw_required_password # register: out - # when: is_mitogen # - assert: # that: # - out.stdout == 'mitogen__require_tty_pw_required' - # when: is_mitogen tags: + - mitogen_only - sudo - sudo_requiretty diff --git a/tests/ansible/integration/connection/become_same_user.yml b/tests/ansible/integration/connection/become_same_user.yml index 5ff4f95b..f1b7a0fc 100644 --- a/tests/ansible/integration/connection/become_same_user.yml +++ b/tests/ansible/integration/connection/become_same_user.yml @@ -5,13 +5,13 @@ hosts: bsu-joe gather_facts: no tasks: + - include_tasks: ../_mitogen_only.yml # bsu-joe's login user is joe, so become should be ignored. - mitogen_get_stack: become: true become_user: joe register: out - when: is_mitogen - assert: that: @@ -19,7 +19,6 @@ - out.result[0].kwargs.username == "joe" - out.result|length == 1 # no sudo fail_msg: out={{out}} - when: is_mitogen # Now try with a different account. @@ -27,7 +26,6 @@ become: true become_user: james register: out - when: is_mitogen - assert: that: @@ -37,6 +35,6 @@ - out.result[1].kwargs.username == "james" - out.result|length == 2 # no sudo fail_msg: out={{out}} - when: is_mitogen tags: - become_same_user + - mitogen_only diff --git a/tests/ansible/integration/connection/disconnect_during_module.yml b/tests/ansible/integration/connection/disconnect_during_module.yml index 5c74b0ed..926291df 100644 --- a/tests/ansible/integration/connection/disconnect_during_module.yml +++ b/tests/ansible/integration/connection/disconnect_during_module.yml @@ -6,8 +6,7 @@ gather_facts: no any_errors_fatal: false tasks: - - meta: end_play - when: not is_mitogen + - include_tasks: ../_mitogen_only.yml - name: Run _disconnect_during_module.yml delegate_to: localhost @@ -32,3 +31,4 @@ tags: - disconnect - disconnect_during_module + - mitogen_only diff --git a/tests/ansible/integration/connection/disconnect_resets_connection.yml b/tests/ansible/integration/connection/disconnect_resets_connection.yml index 95f96910..d9879a71 100644 --- a/tests/ansible/integration/connection/disconnect_resets_connection.yml +++ b/tests/ansible/integration/connection/disconnect_resets_connection.yml @@ -13,8 +13,7 @@ hosts: test-targets gather_facts: no tasks: - - meta: end_play - when: not is_mitogen + - include_tasks: ../_mitogen_only.yml - mitogen_action_script: script: | @@ -47,3 +46,4 @@ tags: - disconnect - disconnect_resets_connection + - mitogen_only diff --git a/tests/ansible/integration/connection/home_dir.yml b/tests/ansible/integration/connection/home_dir.yml index d41657bc..07ce9dd1 100644 --- a/tests/ansible/integration/connection/home_dir.yml +++ b/tests/ansible/integration/connection/home_dir.yml @@ -3,18 +3,18 @@ - name: integration/connection/home_dir.yml hosts: test-targets tasks: + - include_tasks: ../_mitogen_only.yml + - name: "Find out root's homedir." # Runs first because it blats regular Ansible facts with junk, so # non-become run fixes that up. setup: become: true register: root_facts - when: is_mitogen - name: "Find regular homedir" setup: register: user_facts - when: is_mitogen - name: "Verify Connection.homedir correct when become:false" mitogen_action_script: @@ -24,7 +24,6 @@ "connection homedir": self._connection.homedir, "homedir from facts": "{{user_facts.ansible_facts.ansible_user_dir}}" } - when: is_mitogen - name: "Verify Connection.homedir correct when become:true" become: true @@ -35,6 +34,6 @@ "connection homedir": self._connection.homedir, "homedir from facts": "{{root_facts.ansible_facts.ansible_user_dir}}" } - when: is_mitogen tags: - home_dir + - mitogen_only diff --git a/tests/ansible/integration/connection/put_large_file.yml b/tests/ansible/integration/connection/put_large_file.yml index ce8f8fe0..c70e033d 100644 --- a/tests/ansible/integration/connection/put_large_file.yml +++ b/tests/ansible/integration/connection/put_large_file.yml @@ -8,7 +8,7 @@ file_name: large-file file_size: 512 tasks: - - include: _put_file.yml + - include_tasks: _put_file.yml tags: - put_file - put_large_file diff --git a/tests/ansible/integration/connection/put_small_file.yml b/tests/ansible/integration/connection/put_small_file.yml index 3e0eaaa9..2dc100a1 100644 --- a/tests/ansible/integration/connection/put_small_file.yml +++ b/tests/ansible/integration/connection/put_small_file.yml @@ -8,7 +8,7 @@ file_name: small-file file_size: 123 tasks: - - include: _put_file.yml + - include_tasks: _put_file.yml tags: - put_file - put_small_file diff --git a/tests/ansible/integration/connection/reset.yml b/tests/ansible/integration/connection/reset.yml index 1ee38817..f3ddb2c4 100644 --- a/tests/ansible/integration/connection/reset.yml +++ b/tests/ansible/integration/connection/reset.yml @@ -6,8 +6,7 @@ - name: integration/connection/reset.yml hosts: test-targets tasks: - - meta: end_play - when: not is_mitogen + - include_tasks: ../_mitogen_only.yml - debug: msg="reset.yml skipped on Ansible<2.5.6" when: @@ -47,4 +46,5 @@ - out_become.ppid != out_become2.ppid fail_msg: out={{out}} out2={{out2}} out_become={{out_become}} out_become2={{out_become2}} tags: + - mitogen_only - reset diff --git a/tests/ansible/integration/connection_delegation/delegate_to_template.yml b/tests/ansible/integration/connection_delegation/delegate_to_template.yml index 7d33a161..0c3f35c2 100644 --- a/tests/ansible/integration/connection_delegation/delegate_to_template.yml +++ b/tests/ansible/integration/connection_delegation/delegate_to_template.yml @@ -15,8 +15,7 @@ hosts: test-targets gather_facts: no tasks: - - meta: end_play - when: not is_mitogen + - include_tasks: ../_mitogen_only.yml - meta: end_play when: @@ -88,3 +87,4 @@ ] tags: - delegate_to_template + - mitogen_only diff --git a/tests/ansible/integration/connection_delegation/local_action.yml b/tests/ansible/integration/connection_delegation/local_action.yml index 6176d770..1f5cd767 100644 --- a/tests/ansible/integration/connection_delegation/local_action.yml +++ b/tests/ansible/integration/connection_delegation/local_action.yml @@ -3,8 +3,7 @@ - name: integration/connection_delegation/local_action.yml hosts: cd-newuser-normal-normal tasks: - - meta: end_play - when: not is_mitogen + - include_tasks: ../_mitogen_only.yml - local_action: mitogen_get_stack become: true @@ -35,3 +34,4 @@ ] tags: - local_action + - mitogen_only diff --git a/tests/ansible/integration/connection_delegation/osa_container_standalone.yml b/tests/ansible/integration/connection_delegation/osa_container_standalone.yml index 249ab31a..98788d39 100644 --- a/tests/ansible/integration/connection_delegation/osa_container_standalone.yml +++ b/tests/ansible/integration/connection_delegation/osa_container_standalone.yml @@ -4,8 +4,7 @@ hosts: dtc-container-1 gather_facts: false tasks: - - meta: end_play - when: not is_mitogen + - include_tasks: ../_mitogen_only.yml - mitogen_get_stack: register: out @@ -28,5 +27,6 @@ }, ] tags: + - mitogen_only - osa - osa_container_standalone diff --git a/tests/ansible/integration/connection_delegation/osa_delegate_to_self.yml b/tests/ansible/integration/connection_delegation/osa_delegate_to_self.yml index 4598e989..f97d1c01 100644 --- a/tests/ansible/integration/connection_delegation/osa_delegate_to_self.yml +++ b/tests/ansible/integration/connection_delegation/osa_delegate_to_self.yml @@ -6,8 +6,7 @@ target: osa-container-1 gather_facts: false tasks: - - meta: end_play - when: not is_mitogen + - include_tasks: ../_mitogen_only.yml - mitogen_get_stack: delegate_to: "{{target}}" @@ -31,5 +30,6 @@ }, ] tags: + - mitogen_only - osa - osa_delegate_to_self diff --git a/tests/ansible/integration/connection_delegation/stack_construction.yml b/tests/ansible/integration/connection_delegation/stack_construction.yml index 279a7b2b..784d2af2 100644 --- a/tests/ansible/integration/connection_delegation/stack_construction.yml +++ b/tests/ansible/integration/connection_delegation/stack_construction.yml @@ -19,9 +19,7 @@ - name: integration/connection_delegation/stack_construction.yml hosts: cd-normal tasks: - - meta: end_play - when: not is_mitogen - + - include_tasks: ../_mitogen_only.yml # used later for local_action test. - local_action: custom_python_detect_environment register: local_env @@ -31,9 +29,7 @@ - hosts: cd-normal tasks: - - meta: end_play - when: not is_mitogen - + - include_tasks: ../_mitogen_only.yml - mitogen_get_stack: register: out - assert_equal: @@ -52,14 +48,13 @@ } ] tags: + - mitogen_only - stack_construction - hosts: cd-normal tasks: - - meta: end_play - when: not is_mitogen - + - include_tasks: ../_mitogen_only.yml - mitogen_get_stack: delegate_to: cd-alias register: out @@ -96,14 +91,13 @@ }, ] tags: + - mitogen_only - stack_construction - hosts: cd-alias tasks: - - meta: end_play - when: not is_mitogen - + - include_tasks: ../_mitogen_only.yml - mitogen_get_stack: register: out - assert_equal: @@ -139,14 +133,13 @@ }, ] tags: + - mitogen_only - stack_construction - hosts: cd-normal-normal tasks: - - meta: end_play - when: not is_mitogen - + - include_tasks: ../_mitogen_only.yml - mitogen_get_stack: register: out - assert_equal: @@ -193,14 +186,13 @@ }, ] tags: + - mitogen_only - stack_construction - hosts: cd-normal-alias tasks: - - meta: end_play - when: not is_mitogen - + - include_tasks: ../_mitogen_only.yml - mitogen_get_stack: register: out - assert_equal: @@ -269,9 +261,7 @@ - hosts: cd-newuser-normal-normal tasks: - - meta: end_play - when: not is_mitogen - + - include_tasks: ../_mitogen_only.yml - mitogen_get_stack: register: out - assert_equal: @@ -318,14 +308,13 @@ }, ] tags: + - mitogen_only - stack_construction - hosts: cd-newuser-normal-normal tasks: - - meta: end_play - when: not is_mitogen - + - include_tasks: ../_mitogen_only.yml - mitogen_get_stack: delegate_to: cd-alias register: out @@ -362,14 +351,13 @@ }, ] tags: + - mitogen_only - stack_construction - hosts: cd-newuser-normal-normal tasks: - - meta: end_play - when: not is_mitogen - + - include_tasks: ../_mitogen_only.yml - local_action: mitogen_get_stack register: out - assert_equal: @@ -383,14 +371,13 @@ }, ] tags: + - mitogen_only - stack_construction - hosts: cd-newuser-doas-normal tasks: - - meta: end_play - when: not is_mitogen - + - include_tasks: ../_mitogen_only.yml - mitogen_get_stack: register: out - assert_equal: @@ -420,4 +407,5 @@ }, ] tags: + - mitogen_only - stack_construction diff --git a/tests/ansible/integration/context_service/disconnect_cleanup.yml b/tests/ansible/integration/context_service/disconnect_cleanup.yml index 2dd10b2c..22ba12eb 100644 --- a/tests/ansible/integration/context_service/disconnect_cleanup.yml +++ b/tests/ansible/integration/context_service/disconnect_cleanup.yml @@ -4,8 +4,7 @@ - name: integration/context_service/disconnect_cleanup.yml hosts: test-targets[0] tasks: - - meta: end_play - when: not is_mitogen + - include_tasks: ../_mitogen_only.yml - meta: end_play when: @@ -50,3 +49,4 @@ # that: out.dump|length == play_hosts|length # just the ssh account tags: - disconnect_cleanup + - mitogen_only diff --git a/tests/ansible/integration/context_service/remote_name.yml b/tests/ansible/integration/context_service/remote_name.yml index 79fb8dea..545d64b3 100644 --- a/tests/ansible/integration/context_service/remote_name.yml +++ b/tests/ansible/integration/context_service/remote_name.yml @@ -3,8 +3,7 @@ - name: integration/context_service/remote_name.yml hosts: test-targets[0] tasks: - - meta: end_play - when: not is_mitogen + - include_tasks: ../_mitogen_only.yml # Too much hassle to make this work for OSX - meta: end_play @@ -32,4 +31,5 @@ - out.stdout is match('.*python([0-9.]+)?\(mitogen:ansible\)') fail_msg: out={{out}} tags: + - mitogen_only - remote_name diff --git a/tests/ansible/integration/runner/custom_python_new_style_missing_interpreter.yml b/tests/ansible/integration/runner/custom_python_new_style_missing_interpreter.yml index 0d7cf1b6..279735c9 100644 --- a/tests/ansible/integration/runner/custom_python_new_style_missing_interpreter.yml +++ b/tests/ansible/integration/runner/custom_python_new_style_missing_interpreter.yml @@ -4,8 +4,7 @@ tasks: # FIXME Without Mitogen Ansible often reads stdin before the module. # Either don't read directly from stdin, or figure out the cause. - - meta: end_play - when: not is_mitogen + - include_tasks: ../_mitogen_only.yml - custom_python_new_style_missing_interpreter: foo: true @@ -22,3 +21,4 @@ fail_msg: out={{out}} tags: - custom_python_new_style_module + - mitogen_only diff --git a/tests/ansible/integration/runner/custom_python_new_style_module.yml b/tests/ansible/integration/runner/custom_python_new_style_module.yml index 8435b158..33207282 100644 --- a/tests/ansible/integration/runner/custom_python_new_style_module.yml +++ b/tests/ansible/integration/runner/custom_python_new_style_module.yml @@ -3,8 +3,7 @@ tasks: # FIXME Without Mitogen Ansible often reads stdin before the module. # Either don't read directly from stdin, or figure out the cause. - - meta: end_play - when: not is_mitogen + - include_tasks: ../_mitogen_only.yml - custom_python_new_style_module: foo: true @@ -30,3 +29,4 @@ fail_msg: out={{out}} tags: - custom_python_new_style_module + - mitogen_only diff --git a/tests/ansible/integration/runner/custom_python_prehistoric_module.yml b/tests/ansible/integration/runner/custom_python_prehistoric_module.yml index ebe34cc8..4ccdc9d5 100644 --- a/tests/ansible/integration/runner/custom_python_prehistoric_module.yml +++ b/tests/ansible/integration/runner/custom_python_prehistoric_module.yml @@ -7,13 +7,14 @@ - name: integration/runner/custom_python_prehistoric_module.yml hosts: test-targets tasks: + - include_tasks: ../_mitogen_only.yml + - custom_python_prehistoric_module: register: out - when: is_mitogen - assert: that: out.ok fail_msg: out={{out}} - when: is_mitogen tags: - custom_python_prehistoric_module + - mitogen_only diff --git a/tests/ansible/integration/runner/etc_environment.yml b/tests/ansible/integration/runner/etc_environment.yml index 6ed3e9c2..79e5bfa6 100644 --- a/tests/ansible/integration/runner/etc_environment.yml +++ b/tests/ansible/integration/runner/etc_environment.yml @@ -6,7 +6,7 @@ hosts: test-targets[0] gather_facts: true tasks: - - include: _etc_environment_user.yml + - include_tasks: _etc_environment_user.yml when: ansible_system == "Linux" and is_mitogen - include_tasks: _etc_environment_global.yml diff --git a/tests/ansible/integration/runner/forking_active.yml b/tests/ansible/integration/runner/forking_active.yml index 5198ee1c..97ffcc69 100644 --- a/tests/ansible/integration/runner/forking_active.yml +++ b/tests/ansible/integration/runner/forking_active.yml @@ -1,6 +1,7 @@ - name: integration/runner/forking_active.yml hosts: test-targets tasks: + - include_tasks: ../_mitogen_only.yml # Verify mitogen_task_isolation=fork triggers forking. @@ -13,21 +14,19 @@ register: fork_proc1 vars: mitogen_task_isolation: fork - when: is_mitogen - name: get force-forked process ID again. custom_python_detect_environment: register: fork_proc2 vars: mitogen_task_isolation: fork - when: is_mitogen - assert: that: - fork_proc1.pid != sync_proc1.pid - fork_proc1.pid != fork_proc2.pid fail_msg: fork_proc1={{fork_proc1}} sync_proc1={{sync_proc1}} fork_proc2={{fork_proc2}} - when: is_mitogen tags: - forking_active + - mitogen_only diff --git a/tests/ansible/integration/runner/forking_correct_parent.yml b/tests/ansible/integration/runner/forking_correct_parent.yml index 8f360bb7..8732627a 100644 --- a/tests/ansible/integration/runner/forking_correct_parent.yml +++ b/tests/ansible/integration/runner/forking_correct_parent.yml @@ -2,6 +2,7 @@ - name: integration/runner/forking_correct_parent.yml hosts: test-targets tasks: + - include_tasks: ../_mitogen_only.yml # Verify mitogen_task_isolation=fork forks from "virginal fork parent", not # shared interpreter, but only if forking is enabled (e.g. that's never true @@ -14,35 +15,34 @@ self._connection.init_child_result['fork_context'] is not None ) register: forkmode - when: is_mitogen - name: get regular process ID. custom_python_detect_environment: register: regular_proc - when: is_mitogen - name: get force-forked process ID again. custom_python_detect_environment: register: fork_proc vars: mitogen_task_isolation: fork - when: is_mitogen - assert: that: - fork_proc.pid != regular_proc.pid fail_msg: fork_proc={{fork_proc}} regular_proc={{regular_proc}} - when: is_mitogen - assert: that: fork_proc.ppid != regular_proc.pid fail_msg: fork_proc={{fork_proc}} regular_proc={{regular_proc}} - when: is_mitogen and forkmode.uses_fork + when: + - forkmode.uses_fork - assert: that: fork_proc.ppid == regular_proc.pid fail_msg: fork_proc={{fork_proc}} regular_proc={{regular_proc}} - when: is_mitogen and not forkmode.uses_fork + when: + - not forkmode.uses_fork tags: - forking_correct_parent + - mitogen_only diff --git a/tests/ansible/integration/runner/forking_inactive.yml b/tests/ansible/integration/runner/forking_inactive.yml index 91355489..b781aa74 100644 --- a/tests/ansible/integration/runner/forking_inactive.yml +++ b/tests/ansible/integration/runner/forking_inactive.yml @@ -3,22 +3,21 @@ - name: integration/runner/forking_inactive.yml hosts: test-targets tasks: + - include_tasks: ../_mitogen_only.yml - name: get process ID. custom_python_detect_environment: register: sync_proc1 - when: is_mitogen - name: get process ID again. custom_python_detect_environment: register: sync_proc2 - when: is_mitogen - assert: that: - sync_proc1.pid == sync_proc2.pid fail_msg: sync_proc1={{sync_proc1}} sync_proc2={{sync_proc2}} - when: is_mitogen tags: - forking_inactive + - mitogen_only diff --git a/tests/ansible/integration/ssh/config.yml b/tests/ansible/integration/ssh/config.yml index 4e6748b1..c4fedc33 100644 --- a/tests/ansible/integration/ssh/config.yml +++ b/tests/ansible/integration/ssh/config.yml @@ -6,8 +6,7 @@ vars: ansible_private_key_file: ~/fakekey tasks: - - meta: end_play - when: not is_mitogen + - include_tasks: ../_mitogen_only.yml - mitogen_get_stack: register: out @@ -20,3 +19,4 @@ fail_msg: out={{out}} tags: - config + - mitogen_only diff --git a/tests/ansible/integration/ssh/timeouts.yml b/tests/ansible/integration/ssh/timeouts.yml index d4aba5d2..a7691bc3 100644 --- a/tests/ansible/integration/ssh/timeouts.yml +++ b/tests/ansible/integration/ssh/timeouts.yml @@ -3,6 +3,8 @@ - name: integration/ssh/timeouts.yml hosts: test-targets tasks: + - include_tasks: ../_mitogen_only.yml + - name: Cause Ansible connection timeout connection: local environment: @@ -19,7 +21,6 @@ chdir: ../.. register: out ignore_errors: true - when: is_mitogen - name: Verify connection timeout occurred assert: @@ -31,6 +32,6 @@ - | '"msg": "Connection timed out."' in out.stdout fail_msg: out={{out}} - when: is_mitogen tags: + - mitogen_only - timeouts diff --git a/tests/ansible/integration/ssh/variables.yml b/tests/ansible/integration/ssh/variables.yml index 6041d304..f51509db 100644 --- a/tests/ansible/integration/ssh/variables.yml +++ b/tests/ansible/integration/ssh/variables.yml @@ -13,6 +13,8 @@ -o "ControlPath /tmp/mitogen-ansible-test-{{18446744073709551615|random}}" tasks: + - include_tasks: ../_mitogen_only.yml + - name: ansible_ssh_user, ansible_ssh_pass shell: > ANSIBLE_ANY_ERRORS_FATAL=false @@ -28,7 +30,6 @@ args: chdir: ../.. register: out - when: is_mitogen - name: ansible_ssh_user, wrong ansible_ssh_pass shell: > @@ -46,13 +47,11 @@ chdir: ../.. register: out ignore_errors: true - when: is_mitogen - assert: that: - out.rc == 4 # ansible.executor.task_queue_manager.TaskQueueManager.RUN_UNREACHABLE_HOSTS fail_msg: out={{out}} - when: is_mitogen - name: ansible_user, ansible_ssh_pass @@ -70,7 +69,6 @@ args: chdir: ../.. register: out - when: is_mitogen - name: ansible_user, wrong ansible_ssh_pass shell: > @@ -88,13 +86,11 @@ chdir: ../.. register: out ignore_errors: true - when: is_mitogen - assert: that: - out.rc == 4 # ansible.executor.task_queue_manager.TaskQueueManager.RUN_UNREACHABLE_HOSTS fail_msg: out={{out}} - when: is_mitogen - name: ansible_user, ansible_password @@ -112,7 +108,6 @@ args: chdir: ../.. register: out - when: is_mitogen - name: ansible_user, wrong ansible_password shell: > @@ -130,13 +125,11 @@ chdir: ../.. register: out ignore_errors: true - when: is_mitogen - assert: that: - out.rc == 4 # ansible.executor.task_queue_manager.TaskQueueManager.RUN_UNREACHABLE_HOSTS fail_msg: out={{out}} - when: is_mitogen - name: setup ansible_ssh_private_key_file @@ -159,7 +152,6 @@ args: chdir: ../.. register: out - when: is_mitogen - name: ansible_user, wrong ansible_ssh_private_key_file shell: > @@ -177,10 +169,10 @@ chdir: ../.. register: out ignore_errors: true - when: is_mitogen - assert: that: - out.rc == 4 # ansible.executor.task_queue_manager.TaskQueueManager.RUN_UNREACHABLE_HOSTS fail_msg: out={{out}} - when: is_mitogen + tags: + - mitogen_only diff --git a/tests/ansible/integration/stub_connections/kubectl.yml b/tests/ansible/integration/stub_connections/kubectl.yml index 47777ba8..e3e927c0 100644 --- a/tests/ansible/integration/stub_connections/kubectl.yml +++ b/tests/ansible/integration/stub_connections/kubectl.yml @@ -3,8 +3,7 @@ hosts: test-targets gather_facts: false tasks: - - meta: end_play - when: not is_mitogen + - include_tasks: ../_mitogen_only.yml - meta: end_play when: @@ -23,3 +22,4 @@ fail_msg: out={{out}} tags: - kubectl + - mitogen_only diff --git a/tests/ansible/integration/stub_connections/lxc.yml b/tests/ansible/integration/stub_connections/lxc.yml index abe354b6..ae71a603 100644 --- a/tests/ansible/integration/stub_connections/lxc.yml +++ b/tests/ansible/integration/stub_connections/lxc.yml @@ -3,8 +3,7 @@ hosts: test-targets gather_facts: false tasks: - - meta: end_play - when: not is_mitogen + - include_tasks: ../_mitogen_only.yml - custom_python_detect_environment: vars: @@ -19,3 +18,4 @@ fail_msg: out={{out}} tags: - lxc + - mitogen_only diff --git a/tests/ansible/integration/stub_connections/lxd.yml b/tests/ansible/integration/stub_connections/lxd.yml index 5314f82c..a2f8f80a 100644 --- a/tests/ansible/integration/stub_connections/lxd.yml +++ b/tests/ansible/integration/stub_connections/lxd.yml @@ -3,8 +3,7 @@ hosts: test-targets gather_facts: false tasks: - - meta: end_play - when: not is_mitogen + - include_tasks: ../_mitogen_only.yml - custom_python_detect_environment: vars: @@ -19,3 +18,4 @@ fail_msg: out={{out}} tags: - lxd + - mitogen_only diff --git a/tests/ansible/integration/stub_connections/mitogen_doas.yml b/tests/ansible/integration/stub_connections/mitogen_doas.yml index 87764d12..338bc09b 100644 --- a/tests/ansible/integration/stub_connections/mitogen_doas.yml +++ b/tests/ansible/integration/stub_connections/mitogen_doas.yml @@ -3,8 +3,7 @@ hosts: test-targets gather_facts: false tasks: - - meta: end_play - when: not is_mitogen + - include_tasks: ../_mitogen_only.yml - custom_python_detect_environment: vars: @@ -22,3 +21,4 @@ fail_msg: out={{out}} tags: - mitogen_doas + - mitogen_only diff --git a/tests/ansible/integration/stub_connections/mitogen_sudo.yml b/tests/ansible/integration/stub_connections/mitogen_sudo.yml index 6da0e5d6..0ab18f3b 100644 --- a/tests/ansible/integration/stub_connections/mitogen_sudo.yml +++ b/tests/ansible/integration/stub_connections/mitogen_sudo.yml @@ -3,8 +3,7 @@ hosts: test-targets gather_facts: false tasks: - - meta: end_play - when: not is_mitogen + - include_tasks: ../_mitogen_only.yml - custom_python_detect_environment: vars: @@ -23,4 +22,5 @@ left: (out.env.ORIGINAL_ARGV|from_json)[1:9] right: ['-u', 'root', '-H', '-r', 'somerole', '-t', 'sometype', '--'] tags: + - mitogen_only - mitogen_sudo diff --git a/tests/ansible/integration/stub_connections/setns_lxc.yml b/tests/ansible/integration/stub_connections/setns_lxc.yml index 489f9883..889a15e9 100644 --- a/tests/ansible/integration/stub_connections/setns_lxc.yml +++ b/tests/ansible/integration/stub_connections/setns_lxc.yml @@ -8,10 +8,8 @@ any_errors_fatal: false connection: local tasks: - - meta: end_play - when: not is_mitogen - - - include: _end_play_if_not_sudo_linux.yml + - include_tasks: ../_mitogen_only.yml + - include_tasks: _end_play_if_not_sudo_linux.yml - name: Run stub-lxc-info.py command: | @@ -35,3 +33,4 @@ fail_msg: result={{result}} tags: - stns_lxc + - mitogen_only diff --git a/tests/ansible/integration/stub_connections/setns_lxd.yml b/tests/ansible/integration/stub_connections/setns_lxd.yml index d654b7bc..81a52dbb 100644 --- a/tests/ansible/integration/stub_connections/setns_lxd.yml +++ b/tests/ansible/integration/stub_connections/setns_lxd.yml @@ -8,10 +8,8 @@ any_errors_fatal: false connection: local tasks: - - meta: end_play - when: not is_mitogen - - - include: _end_play_if_not_sudo_linux.yml + - include_tasks: ../_mitogen_only.yml + - include_tasks: _end_play_if_not_sudo_linux.yml - name: Run ansible stub-lxc.py command: | @@ -34,4 +32,5 @@ that: result.rc == 0 fail_msg: result={{result}} tags: + - mitogen_only - sens_lxd diff --git a/tests/ansible/integration/transport/all.yml b/tests/ansible/integration/transport/all.yml index 623ee00c..c0cb2fc7 100644 --- a/tests/ansible/integration/transport/all.yml +++ b/tests/ansible/integration/transport/all.yml @@ -1,4 +1,4 @@ -- include: kubectl.yml +- include_playbook: kubectl.yml tags: - kubectl diff --git a/tests/ansible/integration/transport_config/become.yml b/tests/ansible/integration/transport_config/become.yml index 51b698eb..4d9f54f0 100644 --- a/tests/ansible/integration/transport_config/become.yml +++ b/tests/ansible/integration/transport_config/become.yml @@ -5,7 +5,7 @@ - name: integration/transport_config/become.yml hosts: tc-become-unset tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert: that: @@ -13,11 +13,13 @@ - out.result[0].method == "ssh" - out.result[0].kwargs.username == "ansible-cfg-remote-user" fail_msg: out={{out}} + tags: + - mitogen_only - hosts: tc-become-unset vars: {mitogen_via: becomeuser@tc-become-set} tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert: that: @@ -31,6 +33,8 @@ - out.result[2].method == "ssh" - out.result[2].kwargs.hostname == "tc-become-unset" fail_msg: out={{out}} + tags: + - mitogen_only # Become set. @@ -39,7 +43,7 @@ become: true become_user: becomeuser tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert: that: @@ -49,13 +53,15 @@ - out.result[1].method == "sudo" - out.result[1].kwargs.username == "becomeuser" fail_msg: out={{out}} + tags: + - mitogen_only - hosts: tc-become-set vars: {mitogen_via: tc-become-unset} become: true become_user: becomeuser tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert: that: @@ -70,3 +76,5 @@ - out.result[2].method == "sudo" - out.result[2].kwargs.username == "becomeuser" fail_msg: out={{out}} + tags: + - mitogen_only diff --git a/tests/ansible/integration/transport_config/become_method.yml b/tests/ansible/integration/transport_config/become_method.yml index e4efbabd..ffe5a54d 100644 --- a/tests/ansible/integration/transport_config/become_method.yml +++ b/tests/ansible/integration/transport_config/become_method.yml @@ -6,7 +6,7 @@ hosts: tc-become-method-unset become: true tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert: that: @@ -14,11 +14,13 @@ - out.result[0].method == "ssh" - out.result[1].method == "sudo" fail_msg: out={{out}} + tags: + - mitogen_only - hosts: tc-become-method-unset vars: {mitogen_via: becomeuser@tc-become-method-su} tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert: that: @@ -29,6 +31,8 @@ - out.result[2].method == "ssh" - out.result[2].kwargs.hostname == "tc-become-method-unset" fail_msg: out={{out}} + tags: + - mitogen_only # ansible_become_method=su @@ -36,7 +40,7 @@ become: true become_user: becomeuser tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert: that: @@ -45,13 +49,15 @@ - out.result[1].method == "su" - out.result[1].kwargs.username == "becomeuser" fail_msg: out={{out}} + tags: + - mitogen_only - hosts: tc-become-method-su vars: {mitogen_via: tc-become-method-unset} become: true become_user: becomeuser tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert: that: @@ -65,6 +71,8 @@ - out.result[2].method == "su" - out.result[2].kwargs.username == "becomeuser" fail_msg: out={{out}} + tags: + - mitogen_only @@ -72,7 +80,7 @@ - hosts: tc-become-method-unset vars: {mitogen_via: "doas:doasuser@tc-become-method-su"} tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert: that: @@ -86,3 +94,5 @@ - out.result[2].method == "ssh" - out.result[2].kwargs.hostname == "tc-become-method-unset" fail_msg: out={{out}} + tags: + - mitogen_only diff --git a/tests/ansible/integration/transport_config/become_pass.yml b/tests/ansible/integration/transport_config/become_pass.yml index 317e0522..8fbe7251 100644 --- a/tests/ansible/integration/transport_config/become_pass.yml +++ b/tests/ansible/integration/transport_config/become_pass.yml @@ -6,7 +6,7 @@ hosts: tc-become-pass-unset become: true tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert: that: @@ -15,13 +15,15 @@ - out.result[1].method == "sudo" - out.result[1].kwargs.password == None fail_msg: out={{out}} + tags: + - mitogen_only # Not set, unbecoming mitogen_via= - hosts: tc-become-pass-unset become: true vars: {mitogen_via: tc-become-pass-password} tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert: that: @@ -31,13 +33,15 @@ - out.result[2].method == "sudo" - out.result[2].kwargs.password == None fail_msg: out={{out}} + tags: + - mitogen_only # Not set, becoming mitogen_via= - hosts: tc-become-pass-unset become: true vars: {mitogen_via: viapass@tc-become-pass-password} tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert: that: @@ -49,13 +53,15 @@ - out.result[3].method == "sudo" - out.result[3].kwargs.password == None fail_msg: out={{out}} + tags: + - mitogen_only # ansible_become_password= set. - hosts: tc-become-pass-password become: true tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert: that: @@ -64,6 +70,8 @@ - out.result[1].method == "sudo" - out.result[1].kwargs.password == "apassword" fail_msg: out={{out}} + tags: + - mitogen_only # ansible_become_password=, via= @@ -71,7 +79,7 @@ vars: {mitogen_via: root@tc-become-pass-pass} become: true tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert: that: @@ -83,13 +91,15 @@ - out.result[3].method == "sudo" - out.result[3].kwargs.password == "apassword" fail_msg: out={{out}} + tags: + - mitogen_only # ansible_become_pass= - hosts: tc-become-pass-pass become: true tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert: that: @@ -98,6 +108,8 @@ - out.result[1].method == "sudo" - out.result[1].kwargs.password == "apass" fail_msg: out={{out}} + tags: + - mitogen_only # ansible_become_pass=, via= @@ -105,7 +117,7 @@ vars: {mitogen_via: root@tc-become-pass-password} become: true tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert: that: @@ -117,12 +129,14 @@ - out.result[3].method == "sudo" - out.result[3].kwargs.password == "apass" fail_msg: out={{out}} + tags: + - mitogen_only - hosts: tc-become-pass-both become: true tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert: that: @@ -133,13 +147,15 @@ # to ansible_become_pass over ansible_become_password. - out.result[1].kwargs.password == "bpass" fail_msg: out={{out}} + tags: + - mitogen_only # both, mitogen_via - hosts: tc-become-pass-unset vars: {mitogen_via: root@tc-become-pass-both} tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert: that: @@ -149,3 +165,5 @@ - out.result[1].kwargs.password == "bpass" - out.result[2].method == "ssh" fail_msg: out={{out}} + tags: + - mitogen_only diff --git a/tests/ansible/integration/transport_config/become_user.yml b/tests/ansible/integration/transport_config/become_user.yml index 1a8b9fc9..0e30dfe2 100644 --- a/tests/ansible/integration/transport_config/become_user.yml +++ b/tests/ansible/integration/transport_config/become_user.yml @@ -6,7 +6,7 @@ hosts: tc-become-user-unset become: true tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert: that: @@ -15,13 +15,15 @@ - out.result[1].method == "sudo" - out.result[1].kwargs.username == "root" fail_msg: out={{out}} + tags: + - mitogen_only # Not set, unbecoming mitogen_via= - hosts: tc-become-user-unset become: true vars: {mitogen_via: tc-become-user-set} tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert: that: @@ -31,13 +33,15 @@ - out.result[2].method == "sudo" - out.result[2].kwargs.username == "root" fail_msg: out={{out}} + tags: + - mitogen_only # Not set, becoming mitogen_via= - hosts: tc-become-user-unset become: true vars: {mitogen_via: viauser@tc-become-user-set} tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert: that: @@ -49,13 +53,15 @@ - out.result[3].method == "sudo" - out.result[3].kwargs.username == "root" fail_msg: out={{out}} + tags: + - mitogen_only # ansible_become_user= set. - hosts: tc-become-user-set become: true tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert: that: @@ -64,6 +70,8 @@ - out.result[1].method == "sudo" - out.result[1].kwargs.username == "ansi-become-user" fail_msg: out={{out}} + tags: + - mitogen_only # ansible_become_user=, unbecoming via= @@ -71,7 +79,7 @@ vars: {mitogen_via: tc-become-user-unset} become: true tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert: that: @@ -85,6 +93,8 @@ - out.result[2].method == "sudo" - out.result[2].kwargs.username == "ansi-become-user" fail_msg: out={{out}} + tags: + - mitogen_only # ansible_become_user=, becoming via= @@ -92,7 +102,7 @@ vars: {mitogen_via: "doas:doasuser@tc-become-user-unset"} become: true tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert: that: @@ -109,4 +119,6 @@ - out.result[3].method == "sudo" - out.result[3].kwargs.username == "ansi-become-user" fail_msg: out={{out}} + tags: + - mitogen_only diff --git a/tests/ansible/integration/transport_config/password.yml b/tests/ansible/integration/transport_config/password.yml index ac236d66..c55939f7 100644 --- a/tests/ansible/integration/transport_config/password.yml +++ b/tests/ansible/integration/transport_config/password.yml @@ -6,16 +6,18 @@ - name: integration/transport_config/password.yml hosts: tc-password-unset tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].kwargs.password right: "" # actually null, but assert_equal limitation + tags: + - mitogen_only - hosts: tc-password-unset vars: {mitogen_via: tc-password-explicit-ssh} tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].kwargs.password @@ -23,22 +25,26 @@ - assert_equal: left: out.result[1].kwargs.password right: "" + tags: + - mitogen_only # ansible_ssh_user= - hosts: tc-password-explicit-ssh tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].kwargs.password right: "ansi-ssh-pass" + tags: + - mitogen_only - hosts: tc-password-explicit-ssh vars: {mitogen_via: tc-password-unset} tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].kwargs.password @@ -46,22 +52,26 @@ - assert_equal: left: out.result[1].kwargs.password right: "ansi-ssh-pass" + tags: + - mitogen_only # ansible_user= - hosts: tc-password-explicit-pass tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].kwargs.password right: "ansi-pass" + tags: + - mitogen_only - hosts: tc-password-explicit-pass vars: {mitogen_via: tc-password-unset} tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].kwargs.password @@ -69,22 +79,26 @@ - assert_equal: left: out.result[1].kwargs.password right: "ansi-pass" + tags: + - mitogen_only # both; ansible_ssh_user= takes precedence according to play_context.py. - hosts: tc-password-explicit-both tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].kwargs.password right: "c.b.a" + tags: + - mitogen_only - hosts: tc-password-explicit-both vars: {mitogen_via: tc-password-unset} tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].kwargs.password @@ -92,3 +106,5 @@ - assert_equal: left: out.result[1].kwargs.password right: "c.b.a" + tags: + - mitogen_only diff --git a/tests/ansible/integration/transport_config/port.yml b/tests/ansible/integration/transport_config/port.yml index 340eae79..c8e6bdae 100644 --- a/tests/ansible/integration/transport_config/port.yml +++ b/tests/ansible/integration/transport_config/port.yml @@ -5,7 +5,7 @@ - name: integration/transport_config/port.yml hosts: tc-port-unset tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert: that: @@ -13,12 +13,14 @@ - out.result[0].method == "ssh" - out.result[0].kwargs.port == None fail_msg: out={{out}} + tags: + - mitogen_only # Not set, mitogen_via= - hosts: tc-port-explicit-ssh vars: {mitogen_via: tc-port-unset} tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert: that: @@ -28,11 +30,13 @@ - out.result[1].method == "ssh" - out.result[1].kwargs.port == 4321 fail_msg: out={{out}} + tags: + - mitogen_only # ansible_ssh_port= - hosts: tc-port-explicit-ssh tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert: that: @@ -40,11 +44,13 @@ - out.result[0].method == "ssh" - out.result[0].kwargs.port == 4321 fail_msg: out={{out}} + tags: + - mitogen_only - hosts: tc-port-unset vars: {mitogen_via: tc-port-explicit-ssh} tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert: that: @@ -54,11 +60,13 @@ - out.result[1].method == "ssh" - out.result[1].kwargs.port == None fail_msg: out={{out}} + tags: + - mitogen_only # ansible_port= - hosts: tc-port-explicit-port tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert: that: @@ -66,11 +74,13 @@ - out.result[0].method == "ssh" - out.result[0].kwargs.port == 1234 fail_msg: out={{out}} + tags: + - mitogen_only - hosts: tc-port-unset vars: {mitogen_via: tc-port-explicit-port} tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert: that: @@ -80,12 +90,14 @@ - out.result[1].method == "ssh" - out.result[1].kwargs.port == None fail_msg: out={{out}} + tags: + - mitogen_only # both, ssh takes precedence - hosts: tc-port-both tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert: that: @@ -93,11 +105,13 @@ - out.result[0].method == "ssh" - out.result[0].kwargs.port == 1532 fail_msg: out={{out}} + tags: + - mitogen_only - hosts: tc-port-unset vars: {mitogen_via: tc-port-both} tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert: that: @@ -107,3 +121,5 @@ - out.result[1].method == "ssh" - out.result[1].kwargs.port == None fail_msg: out={{out}} + tags: + - mitogen_only diff --git a/tests/ansible/integration/transport_config/python_path.yml b/tests/ansible/integration/transport_config/python_path.yml index 0c6069a0..0f04ed59 100644 --- a/tests/ansible/integration/transport_config/python_path.yml +++ b/tests/ansible/integration/transport_config/python_path.yml @@ -7,16 +7,18 @@ - name: integration/transport_config/python_path.yml hosts: tc-python-path-unset tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].kwargs.python_path right: ["{{out.discovered_interpreter}}"] + tags: + - mitogen_only - hosts: tc-python-path-hostvar vars: {mitogen_via: tc-python-path-unset} tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].kwargs.python_path @@ -24,21 +26,25 @@ - assert_equal: left: out.result[1].kwargs.python_path right: ["/hostvar/path/to/python"] + tags: + - mitogen_only # Non-localhost with explicit ansible_python_interpreter - hosts: tc-python-path-hostvar tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].kwargs.python_path right: [/hostvar/path/to/python] + tags: + - mitogen_only - hosts: tc-python-path-unset vars: {mitogen_via: tc-python-path-hostvar} tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].kwargs.python_path @@ -46,21 +52,25 @@ - assert_equal: left: out.result[1].kwargs.python_path right: ["{{out.discovered_interpreter}}"] + tags: + - mitogen_only # Implicit localhost gets ansible_python_interpreter=virtualenv interpreter - hosts: localhost tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].kwargs.python_path right: ["{{ansible_playbook_python}}"] + tags: + - mitogen_only - hosts: tc-python-path-unset vars: {mitogen_via: localhost} tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].kwargs.python_path @@ -68,22 +78,26 @@ - assert_equal: left: out.result[1].kwargs.python_path right: ["{{out.discovered_interpreter}}"] + tags: + - mitogen_only # explicit local connections get the same treatment as everything else. - hosts: tc-python-path-local-unset tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].kwargs.python_path right: ["{{out.discovered_interpreter}}"] + tags: + - mitogen_only - hosts: localhost vars: {mitogen_via: tc-python-path-local-unset} tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].kwargs.python_path @@ -91,21 +105,25 @@ - assert_equal: left: out.result[1].kwargs.python_path right: ["{{ansible_playbook_python}}"] + tags: + - mitogen_only # explicit local connection with explicit interpreter - hosts: tc-python-path-local-explicit tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].kwargs.python_path right: ["/a/b/c"] + tags: + - mitogen_only - hosts: localhost vars: {mitogen_via: tc-python-path-local-explicit} tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].kwargs.python_path @@ -113,3 +131,5 @@ - assert_equal: left: out.result[1].kwargs.python_path right: ["{{ansible_playbook_python}}"] + tags: + - mitogen_only diff --git a/tests/ansible/integration/transport_config/remote_addr.yml b/tests/ansible/integration/transport_config/remote_addr.yml index b9887202..b1a6c5a7 100644 --- a/tests/ansible/integration/transport_config/remote_addr.yml +++ b/tests/ansible/integration/transport_config/remote_addr.yml @@ -7,16 +7,18 @@ - name: integration/transport_config/remote_addr.yml hosts: tc-remote-addr-unset tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].kwargs.hostname right: "tc-remote-addr-unset" + tags: + - mitogen_only - hosts: tc-remote-addr-unset vars: {mitogen_via: tc-remote-addr-explicit-ssh} tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].kwargs.hostname @@ -24,22 +26,26 @@ - assert_equal: left: out.result[1].kwargs.hostname right: "tc-remote-addr-unset" + tags: + - mitogen_only # ansible_ssh_host= - hosts: tc-remote-addr-explicit-ssh tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].kwargs.hostname right: "ansi.ssh.host" + tags: + - mitogen_only - hosts: tc-remote-addr-explicit-ssh vars: {mitogen_via: tc-remote-addr-unset} tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].kwargs.hostname @@ -47,22 +53,26 @@ - assert_equal: left: out.result[1].kwargs.hostname right: "ansi.ssh.host" + tags: + - mitogen_only # ansible_host= - hosts: tc-remote-addr-explicit-host tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].kwargs.hostname right: "ansi.host" + tags: + - mitogen_only - hosts: tc-remote-addr-explicit-host vars: {mitogen_via: tc-remote-addr-unset} tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].kwargs.hostname @@ -70,22 +80,26 @@ - assert_equal: left: out.result[1].kwargs.hostname right: "ansi.host" + tags: + - mitogen_only # both; ansible_ssh_host= takes precedence according to play_context.py. - hosts: tc-remote-addr-explicit-both tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].kwargs.hostname right: "a.b.c" + tags: + - mitogen_only - hosts: tc-remote-addr-explicit-both vars: {mitogen_via: tc-remote-addr-unset} tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].kwargs.hostname @@ -93,3 +107,5 @@ - assert_equal: left: out.result[1].kwargs.hostname right: "a.b.c" + tags: + - mitogen_only diff --git a/tests/ansible/integration/transport_config/remote_user.yml b/tests/ansible/integration/transport_config/remote_user.yml index 5ddc5aa3..a5559edb 100644 --- a/tests/ansible/integration/transport_config/remote_user.yml +++ b/tests/ansible/integration/transport_config/remote_user.yml @@ -7,17 +7,19 @@ - name: integration/transport_config/remote_user.yml hosts: tc-remote-user-unset tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].kwargs.username # We set DEFAULT_REMOTE_USER in our ansible.cfg right: "ansible-cfg-remote-user" + tags: + - mitogen_only - hosts: tc-remote-user-unset vars: {mitogen_via: tc-remote-user-explicit-ssh} tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].kwargs.username @@ -25,22 +27,26 @@ - assert_equal: left: out.result[1].kwargs.username right: "ansible-cfg-remote-user" + tags: + - mitogen_only # ansible_ssh_user= - hosts: tc-remote-user-explicit-ssh tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].kwargs.username right: "ansi-ssh-user" + tags: + - mitogen_only - hosts: tc-remote-user-explicit-ssh vars: {mitogen_via: tc-remote-user-unset} tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].kwargs.username @@ -48,13 +54,15 @@ - assert_equal: left: out.result[1].kwargs.username right: "ansi-ssh-user" + tags: + - mitogen_only # ansible_user= - hosts: tc-remote-user-explicit-user tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].kwargs.username @@ -63,7 +71,7 @@ - hosts: tc-remote-user-explicit-user vars: {mitogen_via: tc-remote-user-unset} tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].kwargs.username @@ -71,22 +79,26 @@ - assert_equal: left: out.result[1].kwargs.username right: "ansi-user" + tags: + - mitogen_only # both; ansible_ssh_user= takes precedence according to play_context.py. - hosts: tc-remote-user-explicit-both tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].kwargs.username right: "c.b.a" + tags: + - mitogen_only - hosts: tc-remote-user-explicit-both vars: {mitogen_via: tc-remote-user-unset} tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].kwargs.username @@ -94,3 +106,5 @@ - assert_equal: left: out.result[1].kwargs.username right: "c.b.a" + tags: + - mitogen_only diff --git a/tests/ansible/integration/transport_config/transport.yml b/tests/ansible/integration/transport_config/transport.yml index efedc8d4..1bac788b 100644 --- a/tests/ansible/integration/transport_config/transport.yml +++ b/tests/ansible/integration/transport_config/transport.yml @@ -6,16 +6,18 @@ - name: integration/transport_config/transport.yml hosts: tc-transport-unset tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].method right: "ssh" + tags: + - mitogen_only - hosts: tc-transport-local vars: {mitogen_via: tc-transport-unset} tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].method @@ -23,22 +25,26 @@ - assert_equal: left: out.result[1].method right: "local" + tags: + - mitogen_only # ansible_connection=local - hosts: tc-transport-local tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].method right: "local" + tags: + - mitogen_only - hosts: tc-transport-unset vars: {mitogen_via: tc-transport-local} tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].method @@ -46,3 +52,5 @@ - assert_equal: left: out.result[1].method right: "ssh" + tags: + - mitogen_only diff --git a/tests/ansible/integration/transport_config/transport__smart.yml b/tests/ansible/integration/transport_config/transport__smart.yml index f263d67e..d2adca45 100644 --- a/tests/ansible/integration/transport_config/transport__smart.yml +++ b/tests/ansible/integration/transport_config/transport__smart.yml @@ -7,16 +7,18 @@ - name: integration/transport_config/transport__smart.yml hosts: tc-transport-smart tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].method right: "ssh" + tags: + - mitogen_only - hosts: tc-transport-local vars: {mitogen_via: tc-transport-smart} tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].method @@ -24,22 +26,26 @@ - assert_equal: left: out.result[1].method right: "local" + tags: + - mitogen_only # ansible_connection=local - hosts: tc-transport-local tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].method right: "local" + tags: + - mitogen_only - hosts: tc-transport-smart vars: {mitogen_via: tc-transport-local} tasks: - - include: ../_mitogen_only.yml + - include_tasks: ../_mitogen_only.yml - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].method @@ -47,3 +53,5 @@ - assert_equal: left: out.result[1].method right: "ssh" + tags: + - mitogen_only diff --git a/tests/ansible/regression/_mitogen_only.yml b/tests/ansible/regression/_mitogen_only.yml new file mode 120000 index 00000000..cf6c9cf7 --- /dev/null +++ b/tests/ansible/regression/_mitogen_only.yml @@ -0,0 +1 @@ +../integration/_mitogen_only.yml \ No newline at end of file diff --git a/tests/ansible/regression/issue_591__setuptools_cwd_crash.yml b/tests/ansible/regression/issue_591__setuptools_cwd_crash.yml index 80680063..d5f0815b 100644 --- a/tests/ansible/regression/issue_591__setuptools_cwd_crash.yml +++ b/tests/ansible/regression/issue_591__setuptools_cwd_crash.yml @@ -6,8 +6,7 @@ - name: regression/issue_591__setuptools_cwd_crash.yml hosts: test-targets tasks: - - meta: end_play - when: not is_mitogen + - include_tasks: _mitogen_only.yml - custom_python_run_script: script: | @@ -25,3 +24,4 @@ self._connection.get_chain().call(os.getcwd) tags: - issue_591 + - mitogen_only diff --git a/tests/ansible/regression/issue_615__streaming_transfer.yml b/tests/ansible/regression/issue_615__streaming_transfer.yml index 8ec28499..43aa1343 100644 --- a/tests/ansible/regression/issue_615__streaming_transfer.yml +++ b/tests/ansible/regression/issue_615__streaming_transfer.yml @@ -8,6 +8,7 @@ vars: mitogen_ssh_compression: false tasks: + - include_tasks: _mitogen_only.yml - block: - name: Create /tmp/512mb.zero shell: | @@ -31,7 +32,6 @@ become: false delegate_to: localhost run_once: true - when: - - is_mitogen tags: - issue_615 + - mitogen_only diff --git a/tests/ansible/soak/file_service.yml b/tests/ansible/soak/file_service.yml index 90462cbf..f08d6dcc 100644 --- a/tests/ansible/soak/file_service.yml +++ b/tests/ansible/soak/file_service.yml @@ -3,7 +3,7 @@ tasks: - set_fact: content: "{% for x in range(126977) %}x{% endfor %}" - - include: _file_service_loop.yml + - include_tasks: _file_service_loop.yml with_sequence: start=1 end=100 tags: - resource_intensive diff --git a/tests/image_prep/setup.yml b/tests/image_prep/setup.yml index 9aa3285c..b820e1bc 100755 --- a/tests/image_prep/setup.yml +++ b/tests/image_prep/setup.yml @@ -1,6 +1,6 @@ #!/usr/bin/env ansible-playbook -- include: _container_create.yml -- include: _container_setup.yml -- include: _user_accounts.yml -- include: _container_finalize.yml +- include_playbook: _container_create.yml +- include_playbook: _container_setup.yml +- include_playbook: _user_accounts.yml +- include_playbook: _container_finalize.yml From cca651da1ff2720a72a2bfea09a540bd17fcf3b1 Mon Sep 17 00:00:00 2001 From: Alex Willmer Date: Fri, 5 Apr 2024 19:23:29 +0100 Subject: [PATCH 14/15] ansible_mitogen: Ansible 9 (ansible-core 2.16) support --- .ci/azure-pipelines.yml | 11 +++++++---- ansible_mitogen/loaders.py | 2 +- docs/ansible_detailed.rst | 2 ++ docs/changelog.rst | 1 + tox.ini | 9 ++++++--- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/.ci/azure-pipelines.yml b/.ci/azure-pipelines.yml index 7e84e779..94919e35 100644 --- a/.ci/azure-pipelines.yml +++ b/.ci/azure-pipelines.yml @@ -34,15 +34,15 @@ jobs: Loc_27_210: tox.env: py27-mode_localhost-ansible2.10 - Loc_312_8: + Loc_312_9: python.version: '3.12' - tox.env: py312-mode_localhost-ansible8 + tox.env: py312-mode_localhost-ansible9 Van_27_210: tox.env: py27-mode_localhost-ansible2.10-strategy_linear - Van_312_8: + Van_312_9: python.version: '3.12' - tox.env: py312-mode_localhost-ansible8-strategy_linear + tox.env: py312-mode_localhost-ansible9-strategy_linear - job: Linux pool: @@ -160,3 +160,6 @@ jobs: Ans_312_8: python.version: '3.12' tox.env: py312-mode_ansible-ansible8 + Ans_312_9: + python.version: '3.12' + tox.env: py312-mode_ansible-ansible9 diff --git a/ansible_mitogen/loaders.py b/ansible_mitogen/loaders.py index 11015430..9729b8a1 100644 --- a/ansible_mitogen/loaders.py +++ b/ansible_mitogen/loaders.py @@ -49,7 +49,7 @@ __all__ = [ ANSIBLE_VERSION_MIN = (2, 10) -ANSIBLE_VERSION_MAX = (2, 15) +ANSIBLE_VERSION_MAX = (2, 16) 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 1f6ac9a6..b395bc25 100644 --- a/docs/ansible_detailed.rst +++ b/docs/ansible_detailed.rst @@ -165,6 +165,8 @@ Noteworthy Differences +-----------------+-----------------+ | 8 | 3.9 - 3.12 | +-----------------+-----------------+ + | 9 | 3.10 - 3.12 | + +-----------------+-----------------+ 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 8e979a1a..88d78f96 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -23,6 +23,7 @@ Unreleased * :gh:issue:`1021` Support for Ansible 8 (ansible-core 2.15) * tests: Replace uses of ``include:`` & ``import:``, unsupported in Ansible 9 +* :gh:issue:`1053` Support for Ansible 9 (ansible-core 2.16) v0.3.6 (2024-04-04) diff --git a/tox.ini b/tox.ini index 435d5e65..69639233 100644 --- a/tox.ini +++ b/tox.ini @@ -11,7 +11,7 @@ # 2.5 <= 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 <= 5.5 <= 1.11.29 <= 2.11.3 <= 20 <= 4.6.11 <= 3.28 <= 20.15² -# 3.5 <= 2.11 <= 2.13 <= 5.5 <= 2.2.28 <= 2.11.3 <= 20 <= 5.9.5 <= 6.1.0 <= 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 <= 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.8 <= 2.12 @@ -57,7 +57,7 @@ envlist = init, py{27,36}-mode_ansible-ansible{2.10,3,4}, py{311}-mode_ansible-ansible{2.10,3,4,5}, - py{312}-mode_ansible-ansible{6,7,8}, + py{312}-mode_ansible-ansible{6,7,8,9}, py{27,36,312}-mode_mitogen-distro_centos{6,7,8}, py{27,36,312}-mode_mitogen-distro_debian{9,10,11}, py{27,36,312}-mode_mitogen-distro_ubuntu{1604,1804,2004}, @@ -85,6 +85,7 @@ deps = ansible6: ansible~=6.0 ansible7: ansible~=7.0 ansible8: ansible~=8.0 + ansible9: ansible~=9.0 install_command = python -m pip --no-python-version-warning --disable-pip-version-check install {opts} {packages} commands_pre = @@ -120,10 +121,12 @@ setenv = distro_ubuntu1804: DISTRO=ubuntu1804 distro_ubuntu2004: DISTRO=ubuntu2004 # Note the plural, only applicable to MODE=ansible - # Ansible >= 6 (ansible-core >= 2.13) require Python 2.7 or >= 3.5 on targets + # Ansible 6 - 8 (ansible-core 2.13 - 2.15) require Python 2.7 or >= 3.5 on targets ansible6: DISTROS=centos7 centos8 debian9 debian10 debian11 ubuntu1604 ubuntu1804 ubuntu2004 ansible7: DISTROS=centos7 centos8 debian9 debian10 debian11 ubuntu1604 ubuntu1804 ubuntu2004 ansible8: DISTROS=centos7 centos8 debian9 debian10 debian11 ubuntu1604 ubuntu1804 ubuntu2004 + # Ansible >= 9 (ansible-core >= 2.16) require Python 2.7 or >= 3.6 on targets + ansible9: DISTROS=centos7 centos8 debian9 debian10 debian11 ubuntu1804 ubuntu2004 distros_centos: DISTROS=centos6 centos7 centos8 distros_centos5: DISTROS=centos5 distros_centos6: DISTROS=centos6 From a3644963c40f117b2bef819cc8617bbd395c7f95 Mon Sep 17 00:00:00 2001 From: Alex Willmer Date: Mon, 8 Apr 2024 18:27:21 +0100 Subject: [PATCH 15/15] Prepare v0.3.7 --- docs/changelog.rst | 4 ++-- docs/conf.py | 2 +- mitogen/__init__.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 88d78f96..2f8db62e 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -18,8 +18,8 @@ To avail of fixes in an unreleased version, please download a ZIP file `directly from GitHub `_. -Unreleased ----------- +v0.3.7 (2024-04-08) +------------------- * :gh:issue:`1021` Support for Ansible 8 (ansible-core 2.15) * tests: Replace uses of ``include:`` & ``import:``, unsupported in Ansible 9 diff --git a/docs/conf.py b/docs/conf.py index 0e201d44..ad9771b4 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -2,7 +2,7 @@ import sys sys.path.append('.') -VERSION = '0.3.6' +VERSION = '0.3.7' author = u'Network Genomics' copyright = u'2021, the Mitogen authors' diff --git a/mitogen/__init__.py b/mitogen/__init__.py index d08d9883..d72df040 100644 --- a/mitogen/__init__.py +++ b/mitogen/__init__.py @@ -35,7 +35,7 @@ be expected. On the slave, it is built dynamically during startup. #: Library version as a tuple. -__version__ = (0, 3, 7, 'dev') +__version__ = (0, 3, 7) #: This is :data:`False` in slave contexts. Previously it was used to prevent