Inventories Done Right: From Static Hosts to Dynamic Cloud Discovery
What Inventories Actually Do
In this chapter, we'll learn how to create an inventory in AWX. An inventory is a collection of hosts against which jobs may be launched, the same as an Ansible inventory file.
As a reminder, we have four servers:
awx-1: The machine where AWX is installed (accessible atawx.example.comin the browser).awx-2: Another machine that we'll use to scale our AWX installation later.nebula: A managed node.solara: Another managed node.
All of these machines are running CentOS 9 Stream. They should also be on the same network and reachable from the AWX machine (awx-1).
On the AWX machine, create a pair of SSH keys to allow passwordless access to the managed nodes and to awx-2. You can start by executing the following commands from your local machine to export the IP addresses of the different machines:
# Run the following commands on your local machine
# Export the IP addresses of the machines
# Change the IP addresses to the actual IP addresses of your machines
export AWX1_PUBLIC_IP=
export AWX2_PUBLIC_IP=
export NEBULA_PUBLIC_IP=
export SOLARA_PUBLIC_IP=
# Backup your .bashrc file
cp ~/.bashrc ~/.bashrc.bak
# Add the IP addresses to your .bashrc file to avoid exporting them every time
cat << EOF >> ~/.bashrc
export AWX1_PUBLIC_IP=$AWX1_PUBLIC_IP
export AWX2_PUBLIC_IP=$AWX2_PUBLIC_IP
export NEBULA_PUBLIC_IP=$NEBULA_PUBLIC_IP
export SOLARA_PUBLIC_IP=$SOLARA_PUBLIC_IP
EOF
# Source the .bashrc file to apply the changes
source ~/.bashrc
To create an SSH key pair on the awx-1 machine and copy the public key to the other machines, run the following commands (always from your local machine, not the servers):
# Create the SSH key pair
ssh root@$AWX1_PUBLIC_IPAWX in Action
Ansible Orchestration at ScaleEnroll now to unlock all content and receive all future updates for free.
