issue #321: 2.4+ compatibility fixes, disable test on Vanilla.

pull/350/head
David Wilson 6 years ago
parent 4afe2fdc55
commit ac9b84d237

@ -315,7 +315,8 @@ class ActionModuleMixin(ansible.plugins.action.ActionBase):
# module_common and ensures no second temporary directory or atexit
# handler is installed.
self._connection._connect()
if not module_args.get('_ansible_tmpdir', object()):
if ansible.__version__ > '2.5':
module_args['_ansible_tmpdir'] = self._connection.get_temp_dir()
return ansible_mitogen.planner.invoke(

@ -66,6 +66,9 @@ except ImportError:
# Prevent accidental import of an Ansible module from hanging on stdin read.
import ansible.module_utils.basic
ansible.module_utils.basic._ANSIBLE_ARGS = '{}'
ansible.module_utils.basic.get_module_path = lambda: (
ansible_mitogen.target.temp_dir
)
# For tasks that modify /etc/resolv.conf, non-Debian derivative glibcs cache
# resolv.conf at startup and never implicitly reload it. Cope with that via an

@ -443,30 +443,30 @@ In summary, for each task Ansible may create one or more of:
* ``$TMPDIR/ansible_<modname>_payload_.../`` owned by the become user,
* ``$TMPDIR/ansible-module-tmp-.../`` owned by the become user.
A directory must be created in order to maintain compatibility with Ansible,
as many modules introspect :data:`sys.argv` in order to find a directory where
they may write files, however for only one such directory exists for the
lifetime of each interpreter, its location is consistent for each target
account, and it is always privately owned by that account.
The following candidate paths are tried until one is found that is writeable
and appears live on a filesystem that does not have ``noexec`` enabled:
1. The ``$variable`` and tilde-expanded ``remote_tmp`` setting from
``ansible.cfg``.
2. The ``$variable`` and tilde-expanded ``system_tmpdirs`` setting from
``ansible.cfg``.
3. The ``TMPDIR`` environment variable.
4. The ``TEMP`` environment variable.
5. The ``TMP`` environment variable.
A directory must exist to maintain compatibility with Ansible, as many modules
introspect :data:`sys.argv` to find a directory where they may write files,
however only one directory exists for the lifetime of each interpreter, its
location is consistent for each target account, and it is always privately
owned by that account.
The paths below are tried until one is found that is writeable and appears live
on a filesystem with ``noexec`` disabled:
1. ``$variable`` and tilde-expanded ``remote_tmp`` setting from
``ansible.cfg``
2. ``$variable`` and tilde-expanded ``system_tmpdirs`` setting from
``ansible.cfg``
3. ``TMPDIR`` environment variable
4. ``TEMP`` environment variable
5. ``TMP`` environment variable
6. ``/tmp``
7. ``/var/tmp``
8. ``/usr/tmp``
9. The current working directory.
9. Current working directory
As the directory is created once at startup, and its content is managed by code
running remotely, no additional network roundtrips are required to create and
destroy it for each task requiring temporary storage.
running remotely, no additional network roundtrips are required to manage it
for each task requiring temporary storage.
.. _ansible_process_env:

@ -47,9 +47,8 @@ Mitogen for Ansible
* `#321 <https://github.com/dw/mitogen/issues/321>`_: temporary file handling
has been simplified and additional network roundtrips have been removed,
undoing earlier damage caused by compatibility bug fixes. A single directory
is created once at startup for each persistent interpreter, and the
``remote_tmp`` setting is always ignored. See :ref:`ansible_tempfiles` for a
complete description.
is created once at startup for each persistent interpreter. See
:ref:`ansible_tempfiles` for a complete description.
* `#324 <https://github.com/dw/mitogen/issues/324>`_: plays with a custom
``module_utils`` would fail due to fallout from the Python 3 port and related

@ -11,6 +11,9 @@
hosts: test-targets
any_errors_fatal: true
tasks:
- meta: end_play
when: not is_mitogen
#
# non-root
#
@ -109,7 +112,16 @@
register: out
# v2.6 related: https://github.com/ansible/ansible/pull/39833
- name: "Verify modules get the same tmpdir as the action plugin"
- name: "Verify modules get the same tmpdir as the action plugin (<2.5)"
when: ansible_version.full < '2.5'
assert:
that:
- out.module_path == tmp_path.result
- out.module_tmpdir == None
- name: "Verify modules get the same tmpdir as the action plugin (>2.5)"
when: ansible_version.full > '2.5'
assert:
that:
- out.module_path == tmp_path.result
- out.module_tmpdir == tmp_path.result

Loading…
Cancel
Save