CICD-257 · Molecule role testing
Encyclopedia · Ansible and configuration management · All snippets
Previous · CICD-256 · Next · CICD-258
1. Where it fits
- Placement CI run step.
- Prerequisites controller with reviewed inventory, pinned Ansible collections and a non-production target.
- Platforms local-linux, github-actions, gitea-actions.
2. Copy the snippet
bash
molecule test -s default3. How it works
Molecule runs the role scenario against a disposable fixture and checks outcomes across its lifecycle. The shell predicate makes the expected state explicit and returns a nonzero status when it is not satisfied.
4. Verify the result
Use a disposable scenario with driver, converge and verify configuration. Check that cleanup succeeds even when verification fails.
Validation syntax-validated (Bash parse). Status definitions.