Create Ansible Inventory File

Let's learn about the importance of the repository folder structure and how to create the Ansible hosts file.

Build repository folder structure

The first step in building the automation ecosystem is setting up the first repository for the selected environment the organization has decided to automate. The repository is the foundation for the NDLC and the source of truth. Thus, it is very important to create a structure that scales and imposes rigid standards. RBAC should be configured limiting access to the code base as appropriate.

Distribute the link to the network developers once the security and workflows are in place. Create the first branch(the master branch)which includes the base folder structure and inventory hosts file. A recommended folder structure is covered later.

Lock the master branch once populated.

Ansible inventory file

Once ready to start populating the repository, begin with the foundational hosts file. A considerable amount of time should be spent creating a hierarchical model for the hosts file, building natural logical groups of devices where applicable. These groups are more than just a list of hosts. The group name itself becomes a key accessible to create a group_vars YAML file as a data model for all the hosts is listed under a group.

Organize the hosts file to reflect the logical network topology. Ansible can execute playbooks against different technologies at the same time.

For example:

Get hands-on with 1400+ tech skills courses.