Interview Prep/Ansible/Testing, CI/CD and Quality

What is `ansible-test` and when do you need it?

AdvancedProductionTesting, CI/CD and Quality
Answer

ansible-test ships with ansible-core and is the test runner for collections. It expects the collection to sit at ansible_collections/<namespace>/<name>/.

ansible-test sanity --docker default       # docs, imports, argument specs, Python compatibility
ansible-test units --docker default        # pytest unit tests
ansible-test integration --docker default  # targets under tests/integration/targets

Sanity tests catch things like module documentation not matching argument_spec, missing __future__ imports and code that breaks on a supported Python version. If you only write roles and playbooks you do not need it; Molecule and ansible-lint cover you. Once you publish a collection with custom modules or plugins, run ansible-test sanity in CI for every supported ansible-core version.

All Ansible questions Roadmap: Ansible

More on Testing, CI/CD and Quality