Commit Graph

104 Commits (e120cd2caeb41fccd2502b427628ff9ff6b66ac3)

Author SHA1 Message Date
Alex Willmer bf6607e27e ansible_mitogen: Support templated become_user
This reads the become username from the `become_user` attribute of the play
context, to the `"become_user"` option of the loaded become plugin. This has
been supported by vanilla Ansible since Ansible 2.10 (ansible-base 2.10).

To support this I've also switched from using the `play_context.become` (a
bool), to `connection.become` (an instance of the appropriate) become plugin.

New tests have been added, modelled on those for templated connection
parameters (see #1147, #1153, #1159).

See
- 480b106d65

refs #1083

Co-authored-by: mordek <m.pirog@bonasoft.pl>
2 months ago
Alex Willmer 90ba0a74eb ansible_mitogen: Remove unused imports 2 months ago
Alex Willmer 34088a8b7f ansible_mitogen: Consolidate Python 2 & 3 compatibility
Rough guidelines, in decending preference:
- Use mitogen.core if possible
- Use ansible.module_utils.six if possible
- Embed a getattr() or try/except

viewkeys() et al can't be brought into mitogen.core because that package still
targets Python 2.4. dict.viewkeys() were introduced in Python 2.7.
2 months ago
Alex Willmer 0a908d76da ansible_mitogen: Remove fallback imports for Ansible < 2.10 2 months ago
Jonathan Rosser 06617f8231 ansible_mitogen: Handle unsafe paths in _remote_chmod
This is missing from b822f20007
3 months ago
Alex Willmer 357fe38766 Ansible 10 (ansible-core 2.17) support
Notably
- Python 2.7 and 3.6 are no longer supported by Ansible on targets
- The yum module has been removed, and redirected to dnf
- _INTERPRETER_PYTHON_DISTRO_MAP has been neutered. Interpreter discovery
  always favours specific `python3.<x>` interpreters in decending version
  order, then generic `python3` or `python`.
- Add the ability for an action plugin to call self._execute_module(*,
  ignore_unknown_opts=True) to execute a module with options that may not be
  supported for the version being called.

https://docs.ansible.com/ansible/devel/porting_guides/porting_guide_10.html
https://github.com/ansible-community/ansible-build-data/blob/main/10/CHANGELOG-v10.md
https://github.com/ansible/ansible/blob/stable-2.17/changelogs/CHANGELOG-v2.17.rst

fixes #1074, refs #1082

Co-authored-by: Claude Becker <becker@phys.ethz.ch>
4 months ago
Alex Willmer b822f20007 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
8 months ago
Alex Willmer 31b3a4eb4a ansible_mitogen: Standardise __future__ imports to match Ansible
Some modules additionally enable unicode_literals (which Ansible doesn't do).
I've chosen not to change that, for now.
3 years ago
Alex Willmer d9b8d50d4e Fix ansible.__version__ comparisons with multi-digit components
Ansible 2.8 is older than Ansible 2.10, but `'2.8' < '2.10' == False`
3 years ago
Steven Robertson e30e84334e remove synchronize fail test for azure 4 years ago
Steven Robertson 139b9560bc print didn't work because verbosity, throw valueerror to see 4 years ago
Steven Robertson 9bd35adcfb more debugging, synchronize is being weird on azure 4 years ago
Steven Robertson ff8a276186 turn off failing Ansible-only tests for now, also raising errors to see what Azure is gonna do with collections 4 years ago
Steven Robertson 41a13ebce2 hopefully this also fails the same way 4 years ago
Steven Robertson 5aedb5f157 add missing collections 🤦 4 years ago
Steven Robertson 9857dfea5c verify collection is working as expected 4 years ago
Steven Robertson a40c28d93f can't replicate but think it's because synchronize is now a collection 4 years ago
Steven Robertson 49dd8eee1a figure out what synchronize is now 4 years ago
Steven Robertson c6d42212dd add some debugging info, was able to run the failed synchronize test locally just fine using test framework, not sure what's going on 4 years ago
Steven Robertson f91cbf4d00 test cleanup and trying to replicate synchronize fails 4 years ago
Steven Robertson f994807d74 ansible 2.10 renamed ping module to reflect legacy builtin collection 4 years ago
Steven Robertson 03438271bb able to remove the hack on ActionBase after all 4 years ago
Steven Robertson 583f540889 added comments 4 years ago
Steven Robertson ddc1eebec8 able to load collection but the mitogen master proc was unable to serve it 5 years ago
Steven Robertson e99d63f4fc able to load collections but they don't do anything because no actionmodulemixin, need to tweak how this works 5 years ago
Steven Robertson acde13f9d6 handles a 'wait_for_connection' call right after a task caused a shutdown 5 years ago
Steven Robertson 5bf327649f add missing / to python paths 5 years ago
Steven Robertson 7411057ba8 adding in python3 as a possible_pythons option for rhel8 5 years ago
Steven Robertson 89d87445c8 able to pass tests running interpreter detection in rhel8 container 5 years ago
Steven Robertson 7d6d76e444 trying to get docker rhel8 working on a Mac host 5 years ago
Steven Robertson ee310c1a68 remove_internal_keys returns None, so need different way to check fallback 5 years ago
Steven Robertson 722cf0ea8d handle ansible 2.3.3 remove_internal_keys 5 years ago
Steven Robertson ba350aa6cf assigned interpreter vars to the wrong class 5 years ago
Steven Robertson d74da84f62 the clean module was added later 5 years ago
Steven Robertson ff2fa60184 fixed typo 5 years ago
Steven Robertson 0b57332d75 all test cases for ansible_python_interpreter on OSX pass now 5 years ago
Steven Robertson af1e22d4e1 able to propagate ansible_python_interpreter fact but still doesn't save between task runs 5 years ago
Steven Robertson a6d2b2cd90 doesn't error when declaring 'ansible_python_interpreter: auto' but fact isn't being cached 5 years ago
Steven Robertson d64adb15d7 reverted autolinted code 5 years ago
Steven Robertson e8f3154cab Merge branch 'master' into complexAnsiblePythonInterpreterArg 5 years ago
David Wilson d6329f3446 Merge devel/290 @ 79b979ec8544ef5d8620c64068d4a42fabf50415 5 years ago
Steven Robertson 4669c8774f handles templating ansible_python_interpreter values 5 years ago
David Wilson 8dfb3966df issue #558, #582: preserve remote tmpdir if caller did not supply one
The undocumented 'tmp' parameter controls whether _execute_module()
would delete anything on 2.3, so mimic that. This means
_execute_remove_stat() calls will not blow away the temp directory,
which broke the unarchive plugin.
5 years ago
David Wilson c80fddd487 [linear2]: merge fallout flaggged by LGTM 5 years ago
David Wilson 6309774be2 issue #554: fix Ansible 2.4 compatibility 6 years ago
David Wilson 7743e57ff3 issue #554: track and remove multiple make_tmp_path() calls. 6 years ago
David Wilson 1f77d24bec Update copyright year everywhere. 6 years ago
David Wilson 97f3cfe4f4 issue #477: target.file_exists() wrapper.
os.path.exists physical module name varies across major Python versions.
6 years ago
David Wilson bcc7bb7128 issue #61: unused import (reported by LGTM) 6 years ago
David Wilson 9401c34f64 issue #461: Ansible 2.3 did not have _load_name. 6 years ago