The ansible-inventory command

Using the ansible-inventory command provides you with details of your host inventory files. It can be useful if you want to get an idea of how your hosts are grouped. For example, run the following:

$ ansible-inventory -i hosts --graph

This gives you a logical overview of your host groups. Here is the hosts inventory file we first used with the ansible command at the start of the chapter:

As you can see, it displays the groups, starting with all, then the main host group, followed by the child groups, and then finally the hosts themselves.

If you want to view the configuration for a single host, you can use:

Get Learn Ansible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.