ansible-inventory - Show Ansible inventory information, by default it uses the inventory script JSON format
ansible-inventory [-i INVENTORY] (--list | --host HOST | --graph [GROUP]) [--vars] [-y]
Options you will use
--list- Output all hosts info, works as inventory script (JSON; -y for YAML).
--host HOST- Output the variables of one host.
--graph [GROUP]- Create an inventory graph (groups, children, hosts).
--vars- Add vars to the graph display.
-y, --yaml- Use YAML format instead of the default JSON.
--export- When doing --list, represent in a way that is optimized for export.
--output FILE- When doing --list, send the inventory to a file.
-i, --inventory INVENTORY- Specify inventory host path or comma separated host list.
--vault-password-file FILE- Vault password file (for vaulted group_vars).
Examples
$ ansible-inventory --graphthe group tree
$ ansible-inventory --host web-1the variables web-1 ends up with from the inventory
$ ansible-inventory --list -yeverything, as YAML
Gotchas
- Shows inventory variables only: play vars, facts and extra vars are not part of the inventory.
Taught in
Try ansible-inventory in a real terminal Free, in your browser - a real Ubuntu terminal to try it in, with missions that check your work.