mitogen/tests/ansible
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
2024-04-04 09:11:23 +01:00
..
bench tests: Name tasks 2022-09-12 19:27:40 +01:00
files tests: Enable su tests under vanilla Ansible >= 2.11 2024-03-04 16:02:18 +00:00
hosts tests: Clarify transport config tests optimisation & correct value 2024-03-04 16:09:48 +00:00
integration ansible_mitogen: Handle AnsibleUnsafeText et al in Ansible >= 7 2024-04-04 09:11:23 +01:00
lib tests: Skip "discovered python matches invoked" on macOS 11/Python 2.7/Vanilla 2024-03-17 14:58:01 +00:00
regression tests: Account for /tmp symlink in virtualenv test on macOS 2024-03-04 14:43:52 +00:00
setup tests: Report Ansible controller parameters before image prep & user creation 2024-03-04 14:02:12 +00:00
soak tests: Name tasks 2022-09-12 19:27:40 +01:00
tests ansible_mitogen: Handle AnsibleUnsafeText et al in Ansible >= 7 2024-04-04 09:11:23 +01:00
.gitignore Merge devel/290 @ 79b979ec8544ef5d8620c64068d4a42fabf50415 2019-11-02 16:46:59 +00:00
Makefile tests: import custom binaries for tests 2018-10-02 19:19:30 +01:00
README.md tests/ansible/README: Replace reference with actual link 2022-06-02 10:48:23 +01:00
all.yml Revert "Revert "fixed tests for ansible 2.12"" 2021-12-12 22:13:03 +01:00
ansible.cfg tests: Support Ubuntu 22.04 as test suite runner (controller) 2023-07-29 00:26:26 +01:00
ara_env.py tests: import ara_env helper script. 2018-10-26 10:16:46 +01:00
compare_output_test.py tests: prevent compare_output_test running on import. 2018-10-02 20:30:18 +01:00
mitogen_ansible_playbook.py tests: Remove unused imports 2022-04-20 13:44:42 +01:00
requirements.txt tests: Update test coverage to Python 3.9 2021-01-25 22:18:25 +00:00
run_ansible_playbook.py tests: Eliminate MITOGEN_INVENTORY_FILE 2022-09-12 19:27:40 +01:00

README.md

tests/ansible Directory

This is an an organically growing collection of integration and regression tests used for development and end-user bug reports.

It will be tidied up over time, meanwhile, the playbooks here are a useful demonstrator for what does and doesn't work.

Preparation

See ../image_prep/README.md.

run_ansible_playbook.py

This is necessary to set some environment variables used by future tests, as there appears to be no better way to inject them into the top-level process environment before the Mitogen connection process forks.

Running Everything

ANSIBLE_STRATEGY=mitogen_linear ./run_ansible_playbook.py all.yml

hosts/ and common-hosts

To support running the tests against a dev machine that has the requisite user accounts, the the default inventory is a directory containing a 'localhost' file that defines 'localhost' to be named 'target' in Ansible inventory, and a symlink to 'common-hosts', which defines additional targets that all derive from 'target'.

This allows ansible_tests.sh to reuse the common-hosts definitions while replacing localhost as the test target by creating a new directory that similarly symlinks in common-hosts.

There may be a better solution for this, but it works fine for now.