Last active
August 3, 2026 09:24
-
-
Save moreati/22e03116741e959b947aed92f4a1807c to your computer and use it in GitHub Desktop.
Explode and Inspect Ansible ansiballz archive across Ansible versions using ANSIBLE_KEEP_REMOTE_FILES
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .tox | |
| tmp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import os | |
| import pathlib | |
| import subprocess | |
| ANSIBLE_MODULE = 'ping' | |
| ANSIBLE_REMOTE_TEMP = os.environ['ANSIBLE_REMOTE_TEMP'] | |
| task_paths = list(pathlib.Path(ANSIBLE_REMOTE_TEMP).glob('ansible-tmp-*')) | |
| assert len(task_paths) == 1 | |
| ansiballz_path = task_paths[0] / f'AnsiballZ_{ANSIBLE_MODULE}.py' | |
| subprocess.run([ansiballz_path, 'explode'], check=True) | |
| debug_dir_path = task_paths[0] / 'debug_dir' | |
| print(sorted(p.name for p in debug_dir_path.iterdir())) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [tox] | |
| envlist = | |
| py{311}-ans{2.10,3-5} | |
| py{313}-ans{6-9} | |
| py{314}-ans{10-14} | |
| [testenv] | |
| deps = | |
| ans2.10: ansible~=2.10.0 | |
| ans3: ansible~=3.0 | |
| ans4: ansible~=4.0 | |
| ans5: ansible~=5.0 | |
| # From Ansible 6 PyPI distributions include a wheel | |
| ans6: ansible~=6.0 | |
| ans7: ansible~=7.0 | |
| ans8: ansible~=8.0 | |
| ans9: ansible~=9.0 | |
| ans10: ansible~=10.0 | |
| ans11: ansible~=11.0 | |
| ans12: ansible~=12.0 | |
| ans13: ansible~=13.0 | |
| ans14: ansible~=14.0 | |
| allowlist_externals = | |
| ./ansiballz_explode.py | |
| find | |
| ls | |
| setenv = | |
| ANSIBLE_KEEP_REMOTE_FILES=1 | |
| ANSIBLE_LOCAL_TEMP={toxinidir}/tmp | |
| ANSIBLE_REMOTE_TEMP={toxinidir}/tmp | |
| ANSIBLE_REMOTE_TMP={toxinidir}/tmp | |
| commands = | |
| find {toxinidir}/tmp -mindepth 1 -delete | |
| ansible localhost -m ansible.legacy.ping | |
| ./ansiballz_explode.py |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment