About
Inventories in Red Hat Ansible Automation Platform are a fundamental component for organizing and managing hosts or groups of hosts. They provide a structured way to define and categorize the systems Ansible interacts with during automation tasks.
Ansible inventories let you group hosts based on shared characteristics, such as environment, role, or location, allowing for targeted and efficient configuration management. Defining inventories gives administrators more control over their infrastructure and enables seamless orchestration and deployment of Ansible playbooks across the desired hosts.
Ansible uses SSH protocol to connect to servers and run tasks, providing flexible and secure options for remote connectivity. This cheat sheet outlines two different methods to manage and configure remote hosts:
- Using machine credentials as variables
- Setting up private and public key credentials
With Red Hat Developer cheat sheets, you get essential information right at your fingertips so you can work faster and smarter. Easily learn new technologies and coding concepts and quickly find the answers you need.
Excerpt
Set up private key credentials
Create the credentials to SSH into the remote machine:
- Log in to the Ansible Automation Platform console.
- Navigate to the Credentials tab; under Add Button, select Machine.
Add your username, password, and SSH private key in the corresponding fields and click Save.
SSH into remote machines using Ansible
Inventories in Red Hat Ansible Automation Platform serve as a fundamental component for organizing and managing hosts or groups of hosts. They provide a structured way to define and categorize the systems Ansible interacts with during automation tasks.
Ansible inventories let you group hosts based on shared characteristics, such as environment, role, or location, allowing for targeted and efficient configuration management. Defining inventories gives administrators more control over their infrastructure and enables seamless orchestration and deployment of Ansible playbooks across the desired hosts. Ansible uses SSH protocol to connect to servers and run tasks, providing flexible and secure options for remote connectivity.
In this cheat sheet, you’ll learn how to manage and configure remote hosts. This cheat sheet covers two different approaches:
- Using machine credentials as variables
- Setting up private and public key credentials
Use machine credentials as variables
To specify the host variables:
- Log in to the Ansible Automation Platform console.
- Select Inventories from the left menu (Figure 1).
- Click Add.
- Select Add inventory.
- Give the inventory a name and save it (Figure 2).
- Select the groups from inventories and click Add group.
- Give the group a name and save it.
- Next, click Hosts → Add a new host.
- Give the targeted remote machine IP a name and save it.
- In the Variables section, add the given fields, as shown in Figure 3.
—ansible_user : <username to ssh into> ansible_ssh_pass : <password for the username> ansible_become_pass: <password for becoming the root>
- Run the job templates by defining the inventory, as shown in Figure 4.
Set up private key credentials
Create the credentials to SSH into the remote machine:
- Log in to the Ansible Automation Platform console.
- Navigate to the Credentials tab; under Add Button, select Machine.
- Add your username, password, and SSH private key in the corresponding fields and click Save (Figure 5).
Set up the inventory:
- Select the inventory from the left menu.
- Click Add.
- Select Add inventory.
- Give a name to the inventory and save it.
- Select the groups from inventories and click Add group.
- Give a name to the group and save it.
- Next, click Hosts and click Add a new host.
- Give the targeted remote machine IP and save it.
- While configuring the job template, select the machine credentials and run your job template (Figure 6).