Ansible Inventory File Builder

Generate an Ansible inventory INI or YAML file with host groups

Build an Ansible inventory in INI or YAML format with host groups, per-host connection variables, group variables, and children group relationships — ready for ansible-playbook -i.

What is an Ansible inventory?

An inventory is the list of managed hosts Ansible operates on, organized into groups. It can hold connection details and variables per host or group. Playbooks target groups or hosts from the inventory using the hosts directive.

Build a correct Ansible inventory, INI or YAML

The inventory tells Ansible which hosts to manage and how to reach them. Getting the group, variable, and children syntax right by hand is fiddly — especially across the INI and YAML formats. This builder lets you model groups, hosts, variables, and hierarchy once and emit either format cleanly.

How it works

In INI format, hosts are listed under a [group] header, group variables go in a [group:vars] section, and nested groups are declared in [group:children]. Per-host variables follow the host name on the same line as key=value pairs. This is the layout Ansible’s ini inventory plugin parses.

In YAML format, everything nests under the implicit all group: all → children → <group> → hosts/vars/children. Each host becomes a mapping whose values are its connection variables. The builder quotes any YAML scalar that could be misread as a number or boolean, so a value like ansible_port: "2222" stays a string when intended.

Tips and notes

  • Use ansible_host to keep readable inventory aliases while connecting to real IPs.
  • Define shared settings such as ansible_user once as a group var rather than repeating them per host.
  • Build hierarchy with children groups (e.g. a production group whose children are webservers and databases) to target broad or narrow sets in playbooks.
  • Validate the result with ansible-inventory -i <file> --list to confirm Ansible parses it as you expect.