Forrest logo
back to the ansbile-inventory tool

ansible-inventory:tldr:9fe9a

ansible-inventory: Display a custom inventory.
$ ansbile-inventory --list --inventory ${filename_or_script_or_directory}
try on your machine

The ansible-inventory command is used to display the inventory information of an Ansible setup. The command you provided has the following components and options:

  • --list: This option tells Ansible to collect and display the inventory information in a JSON format.

  • --inventory: This option specifies the inventory source to be used. It can take different types of inputs depending on the specific Ansible configuration.

    • ${filename_or_script_or_directory}: This placeholder represents the input argument that should be replaced with the actual inventory source. It can be one of the following:

    • A filename: You can provide the path to a static inventory file (e.g., hosts.ini), which lists the hosts and groups in your infrastructure.

    • A script: Instead of a static file, you can pass the path to a custom script that dynamically generates the inventory. The script could be written in any language and should output the inventory in JSON format.

    • A directory: You can provide the path to a directory, and Ansible will automatically parse and combine all the inventory files found within that directory.

By executing the command with the appropriate arguments, Ansible will gather the inventory information and output it in JSON format, allowing you to see the hosts, groups, variables, and their values defined in your inventory source.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the ansbile-inventory tool