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:

$ ansible-inventory -i hosts --host=ansible01

The following screenshot shows the output for the preceding command:

You may have noticed that it displays the configuration information that the host inherited from the configuration we set for all of the DigitalOcean hosts. You can view all the information on each of your hosts and groups by running:

$ ansible-inventory -i hosts --list

This command is useful if you have a large or complicated hosts inventory file and you want information on just a single host, or if you have taken on a host inventory and want to get a better idea of how the inventory is structured. We will be looking at a third-party tool later in this chapter that gives more display options.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.225.31.159