0% found this document useful (0 votes)
25 views5 pages

Cheat Sheet - SSH Into Remote Machines Using Ansible

Uploaded by

ITTeam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views5 pages

Cheat Sheet - SSH Into Remote Machines Using Ansible

Uploaded by

ITTeam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

developers.redhat.

com redhat-developer @rhdevelopers

Cheat sheet

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:
1. Log in to the Ansible Automation Platform console.
2. Select Inventories from the left menu (Figure 1).
3. Click Add.
4. Select Add inventory.

Figure 1: Adding a new inventory from the Ansible Automation Platform Inventory page.
developers.redhat.com redhat-developer @rhdevelopers

5. Give the inventory a name and save it (Figure 2).

Figure 2: Creating a new inventory page

6. Select the groups from inventories and click Add group.


7. Give the group a name and save it.
8. Next, click Hosts → Add a new host.
9. Give the targeted remote machine IP a name and save it.
10. 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>
developers.redhat.com redhat-developer @rhdevelopers

Figure 3: Adding the host variables in Ansible Automation Platform.

11. Run the job templates by defining the inventory, as shown in Figure 4.

Figure 4: Creating a new job template.


developers.redhat.com redhat-developer @rhdevelopers

Set up private key credentials


Create the credentials to SSH into the remote machine:
1. Log in to the Ansible Automation Platform console.
2. Navigate to the Credentials tab; under Add Button, select Machine.
3. Add your username, password, and SSH private key in the corresponding fields and click Save (Figure 5).

Figure 5: The Credential details page.

Set up the inventory:


1. Select the inventory from the left menu.
2. Click Add.
3. Select Add inventory.
4. Give a name to the inventory and save it.
5. Select the groups from inventories and click Add group.
6. Give a name to the group and save it.
7. Next, click Hosts and click Add a new host.
8. Give the targeted remote machine IP and save it.
9. While configuring the job template, select the machine credentials and run your job template (Figure 6).
developers.redhat.com redhat-developer @rhdevelopers

Figure 6: Select the machine credentials to run the job template.

You might also like