Configure Ansible Managed Nodes

30 minutes
  • 4 Learning Objectives

About this Hands-on Lab

The power of Ansible comes in being able to remotely manage a fleet of servers.

For that to happen though we need to first configure our managed nodes. In this lab we’ll practice configuring these nodes.

*This course is not approved or sponsored by Red Hat.*

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Set up the Ansible Inventory

We need to make sure Ansible has the new servers in its inventory.
Edit /etc/ansible/hosts and add lines similar to the following:



Set up Passwordless SSH Between Nodes

Note that we already have a SSH key in root’s .ssh directory. We don’t have to
create a new one though. Let’s just re-use what we have.

Copy that key to one of the new servers:

ssh-copy-id ansible@WebServer1

Put in the password and the key will be copied over. Repeat this with the other
two servers.

Configure Passwordless Privilege Escalation

Connect to WebServer1 as cloud_user. From there, use sudo to escalate and have root privileges.

As root, run visudo. Add ansible ALL=(ALL) NOPASSWD: ALL to the end of the file.

Repeat this on the other two servers.

Ensure Correct Configuration

Make sure that everything was done correctly by running ansible all -m ping --become to
have Ansible attempt to connect to all the other servers and escalate privileges.

Additional Resources

Notice: Ansible is installed as the root user, so please work on all tasks after elevating to the root user.

We're in the midst of a proof of concept project. We have gotten approval for the combination of inventories and facts, software management, modules, playbooks, and variables in a single-server environment. Now we can move on to configuring this in a multi-server setup. We've been given three servers, and some tasks to set up for each: WebServer1, DBServer1, and AdminServer1.

We've got to set the three servers up so that Ansible can connect and run commands as root without entering a password.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?