Example Documentation: Ansible Assertions Preflight
1. Goal
preflight checks with assertions.
2. What Is Done
The example is inspected through inventory review, playbook review, syntax check, check mode, diff mode, real run, and a second run. It uses safe dummy values.
3. Why It Is Done
Ansible automates changes through target scope and modules. Every change therefore needs clear targeting, a reviewable module, and validation after execution.
4. Typical Commands
ansible-inventory --graph
ansible-playbook playbooks/site.yml --list-hosts
ansible-playbook playbooks/site.yml --syntax-check
ansible-playbook playbooks/site.yml --check --diff
5. Verify Success
- Inventory shows the expected hosts.
- Syntax check succeeds.
- Check mode and diff mode are plausible.
- Play recap contains no unexpected failures.
- Second run reports no unnecessary changes.
6. Common Mistakes
- wrong working directory.
ansible.cfgis not loaded.- role path or template path is wrong.
- variable is overridden from the wrong source.
- check mode is only partially supported by a module.
7. Security Aspects
Use no real secrets. Use no production hosts. Use become only where explicitly justified. Dummy keys and tokens stay visibly dummy values.
8. Realistic Use
The example can be transferred into runbooks, review checklists, CI jobs, operations documentation, and assessment tasks.