Sanity tests are made up of scripts and tools used to perform static code analysis. The primary purpose of these tests is to enforce Ansible coding standards and requirements.
Tests are run with
All available tests are run unless the
--test option is used.
To run sanity tests using docker, always use the default docker image
by passing the
--docker default argument.
When using docker and the
also use the
--keep-git argument to avoid git related errors.
source hacking/env-setup # Run all sanity tests ansible-test sanity # Run all sanity tests including disabled ones ansible-test sanity --allow-disabled # Run all sanity tests against certain file(s) ansible-test sanity lib/ansible/modules/files/template.py # Run all sanity tests against certain folder(s) ansible-test sanity lib/ansible/modules/files/ # Run all tests inside docker (good if you don't have dependencies installed) ansible-test sanity --docker default # Run validate-modules against a specific file ansible-test sanity --test validate-modules lib/ansible/modules/files/template.py
Tests can be listed with
ansible-test sanity --list-tests.
See the full list of sanity tests, which details the various tests and details how to fix identified issues.