Difficulty: Beginner
Estimated Time: 10 minutes

In this tutorial, we will learn, how to prepare a target system, so an Ansible system can connect to it.


Let us summarize, what we have achieved so far:

We have prepared the successful connection from an Ansible system to a target system by

  1. installing an ssh server on the target
  2. creating an SSH key pair on the Ansible system
  3. copying the public key of the Ansible host to the target system

We have tested the connection by using an Ansible "ping", which is an SSH connection from the Ansible host to the target, actually.

Ansible Bootstrapping (Cannot remove Steps 3-6)

Step 1 of 10

1. Prepare Environment for easier Toggling between Ansible and Target System

To make our lives easier later, let us define the commands "a" and "t" for quickly connecting from the base system to the ansible and target container:

Connect to the Ansible container:

a() { docker exec -it ansible bash -c "echo 'PS1='\''ansible# '\' >> /root/.bashrc; bash"; }

Connect to the Target container:

t() { docker exec -it target bash -c "echo 'PS1='\''target# '\' >> /root/.bashrc; bash"; }

In this tutorial, we already have started an ansible and a target container in the background. However, they have been started in the background, and they need some time to become available. Repeat using a docker ps command to check, whether Docker containers named 'ansible' and 'target' have been started already:

docker ps

Repeat sending the command until it looks similar to

CONTAINER ID      IMAGE                                   COMMAND                 CREATED         STATUS
            PORTS NAMES
c96e3a45e164      ubuntu:14.04                            "/bin/bash -c 'whi..."  11 seconds ago  Up 9 seconds target
caf61a258abb      williamyeh/ansible:ubuntu14.04-onbuild  "/bin/bash -c 'whi..."  13 seconds ago  Up 11 seconds ansible

This should take no longer than 30 sec.

Creating Katacoda Scenarios

Thanks for creating Katacoda scenarios. This tab is designed to help you as an author have quick access the information you need when creating scenarios.

This tab will not be visible to users.

Here are some useful links to get you started.

Running Katacoda Workshops

If you are planning to use Katacoda for workshops, please contact [email protected] to arrange capacity.

Debugging Scenarios

Below is the response from any background scripts run or files uploaded. This stream can aid debugging scenarios.

If you still need assistance, please contact [email protected]