When you talk about your infrastructure, you need to categorize it into layers.

Categories

At the highest level, hosts are grouped by the

  • Environment
  • Location

Environment

An environment is a collection of hosts that provide a service for either internal customers or external customers—for example, development, staging, and production.

Location

Location is where the hosts are running physically. Location breaks down into region and region into datacenters.

Your infrastructure dictates how these layers are defined. Environment and location can be used interchangeably.

For example, the environment might be referred to as DC-Prod. You might also leverage all the layers and describe your infrastructure as:

  • US-East-1 (region)
  • US-East-1-DC-1 (datacenter)
  • US-East-1-DC-1-Dev (environment)

Function

Hosts are further categorized by function. The function also has multiple layers. At the top, it describes the general purpose of the host—for example:

  • Web server
  • Database server
  • Cache server

As your infrastructure grows, function further breaks down into specific functions. Refer to a specific web server group as the onboarding web servers or the login portal web servers.

Creating groups and group variables in an inventory

Even within the simple inventory, it is necessary group hosts. After adding the Windows and Linux hosts to the hosts file, you can no longer run the ping playbooks without targeting a specific host.

Grouping the hosts into Linux and Windows solves this problem. Groups are defined within an INI inventory by placing square brackets around the group name and listing the hosts underneath.

Get hands-on with 1000+ tech skills courses.