Exchange SSH Keys and Run Ansible Playbooks

1 hour
  • 2 Learning Objectives

About this Hands-on Lab

Ansible allows you to manage the configuration of your hardware and software. Since Ansible is agentless, it can be run from any system that has account credentials on any other system using standard SSH credentials and commands. In this hands-on lab, we will practice running a small playbook on a remote host to install a web server and then test it on our primary server.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Create the SSH Keys for Exchanging between Master and Client Servers
  1. Create a new user called ansible and set the password.
    adduser ansible
    passwd ansible
  2. Add the ansible user to the sudoers file and make sure that it can use sudo without a password.
  3. While logged in as ansible user, create the necessary keys.
  4. Exchange the key with the remote client server.
  5. Add the client to the Ansible host file.
    vi /etc/ansible/hosts
Install the Elinks Package on the Remote Client Server
  1. Run the playbook on the master.
    ansible-playbook /home/cloud_user/playbook.yml
  2. Once the software is installed (it should show a success message), log in to the remote system and run the following:
  3. You should see an About screen on your console.

Additional Resources


Your development team is working on a new web application service and needs a basic cluster of web servers that they can throw load against in order to test performance.

As a result, you have been asked to provide a basic cluster that encompasses one management node and one client node. You will need to create the manager and join the client to the cluster and confirm they are all registered appropriately.


You have been asked to help your team work with Ansible to manage software packages. As a result, you have been provided credentials and connectivity information for two servers, one master and one client.

When you connect to the master server, you will see that Ansible has already been installed for you. You will find that there is a simple playbook in the /home/cloud_user directory that will install the elinks web browser on the remote client system as a test. However, they have been unable to get it to run.

On the master and client, create a new user called ansible. Give the user a password. You can use the same password you used for cloud_user. Make sure you have created SSH keys for the ansible user and exchanged that key with the remote system. Once you verify the keys, allow access without a password, and be sure that the ansible account on the local and remote systems does not require a password when running commands needing escalation privileges (e.g., sudo). Copy playbook.yml from /home/cloud_user to /home/ansible and make sure that the playbook has the correct owner permissions.

Finally, run the playbook called playbook.yml in the /home/ansible directory and then log in to the client system and verify that the package is installed. Your team can then use that playbook template and configuration to install any software they want thereafter.

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?