Sobes.tech
Junior — Middle

What is the function of the 'ansible inventory' command and what does it output?

sobes.tech AI

Answer from AI

The ansible-inventory command is used to view and debug Ansible inventory data. It displays information about hosts, groups, and variables that Ansible uses to manage infrastructure.

Main functions:

  • Displaying the current inventory in a human-readable format (JSON, YAML, etc.)
  • Checking the correctness of the inventory file or script
  • Diagnosing the structure of groups and hosts

Example usage:

ansible-inventory --list

Outputs a complete list of all hosts and groups with their variables in JSON format.

This helps ensure that Ansible sees the infrastructure as expected and facilitates debugging of playbooks.