Tests
Molecule scenarios, ansible-test targets and role test playbooks, declared next to what they test.
role("common", tasks=[...],
tests=[{"name": "the timezone is set",
"assert": {"that": "timezone is defined"}}])
molecule("default", role="common",
verify=[{"assert": {"that": "localtime.stat.exists"}}])
integration_test("nginx", collection="acme.stack",
tasks=[{"include_role": {"name": "acme.stack.nginx"}}])
unit_test("test_thing.py", "def test_thing(): ...", collection="acme.stack")
test --list shows what was found; test picks molecule, ansible-test,
or the role test playbook, and --runner/--kind force a choice.
The generated tree is self-contained – its own roles/ and
collections/ are put on ansible’s search path ahead of the usual ones,
so a role’s tests/test.yml resolves without the symlink the galaxy
layout normally needs. --install fetches galaxy requirements first,
--dir/--keep keep the build around.
$ python site.py test --list
$ python site.py test common --runner playbook --install
$ python site.py test --runner ansible-test --kind sanity