CICD-247 · Inventory validation
Encyclopedia · Ansible and configuration management · All snippets
Previous · CICD-246 · Next · CICD-248
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
ansible-inventory -i inventory/staging.yml --graph
ansible-inventory -i inventory/staging.yml --list | jq -e '.web.hosts | length > 0'3. How it works
The inventory command resolves configured host sources and groups before a playbook operates on them. The expression filters or transforms the input JSON. Where jq -e is used, a false or empty result can fail the gate.
4. Verify the result
Fail on an empty web group. Review the graph before writes.
Validation syntax-validated (Bash parse). Status definitions.