Molecule "verify" step failed (testinfra / ansible verifier) in CI
After idempotence, Molecule runs the verifier to assert the instance reached the expected state. With the testinfra verifier this runs pytest tests; with the ansible verifier it runs verify.yml. A failed assertion, or a missing verifier dependency, fails the step.
What this error means
Molecule fails at verify with pytest assertion output ("assert False") or "pytest: command not found" / "No module named pytest_testinfra", or a failed assert in verify.yml.
def test_nginx_running(host):
> assert host.service("nginx").is_running
E assert False
CRITICAL Verifier failed with return code 1Common causes
The asserted state does not match reality
A testinfra assertion (a service running, a file present, a port listening) does not hold, because the role did not achieve it or the test expects the wrong thing.
The verifier dependency is not installed
The testinfra verifier needs pytest-testinfra. Without it, verify fails with a missing-module or command-not-found error rather than an assertion.
How to fix it
Install the verifier dependency
Install pytest-testinfra so the testinfra verifier can run.
pip install pytest-testinfraAlign the assertion with the converged state
- Read which assertion failed in the verify output.
- Fix the role so the state holds, or correct an over-strict test.
- Re-run
molecule verifyafter a converge to iterate.
# molecule/default/tests/test_default.py
def test_nginx_running(host):
svc = host.service("nginx")
assert svc.is_running
assert svc.is_enabledHow to prevent it
- Pin
pytest-testinfrain test requirements when using the testinfra verifier. - Keep assertions in step with what the role guarantees.
- Run
molecule verifyafter converge during development.