#. Create a new inventory file named ``inventory.yaml`` in any directory and open it for editing.
#. Add a new group for your hosts then specify the IP address or fully qualified domain name (FQDN) of each managed node with the ``ansible_host`` field.
The following example adds the IP addresses of three virtual machines in KVM:
Congratulations! You have successfully built an inventory.
Tips for building inventories
=============================
* Ensure that group names are meaningful and unique. Group names are also case sensitive.
* Avoid spaces, hyphens, and preceding numbers (use ``floor_19``, not ``19th_floor``) in group names.
* Group hosts in your inventory logically according to their **What**, **Where**, and **When**.
What
Group hosts according to the topology, for example: db, web, leaf, spine.
Where
Group hosts by geographic location, for example: datacenter, region, floor, building.
When
Group hosts by stage, for example: development, test, staging, production.
Use metagroups
--------------
Create a metagroup that organizes multiple groups in your inventory with the following syntax:
..code-block:: yaml
metagroupname:
children:
The following inventory illustrates a basic structure for a data center.
This example inventory contains a ``network`` metagroup that includes all network devices and a ``datacenter`` metagroup that includes the ``network`` group and all webservers.
Variables set values for managed nodes, such as the IP address, FQDN, operating system, and SSH user, so you do not need to pass them when running Ansible commands.