Browse the project source code in my github repository:


Personal Ansible playground (based on Docker, Docker-composer, Centos8)

Contact: Robert Nowotniak

Tested on ArchLinux as the Docker host.

Quick start

Download the image from my Dockerhub account, and clone this from my github (which allows to rebuild the same image yourself from scratch):

docker pull rnowotniak/ansiblelab
git clone

Create ssh keys which will be used to communicate betwen the master and the nodes in your new Ansible lab:

cd ansiblelab
ssh-keygen -q -N "" -f keys/ansiblekey

Start the containers with docker-compose per the definitions in docker-compose.yml:

docker-compose up


Working with the lab environment

Having the master and the nodes up and running (docker-compose up), you can enter the master container and run Ansible commands on the nodes. A very basic configuration (ansible.cfg) and inventory (“inventory” file) is already copied there in the working directory.

There are 5 hosts in the default inventory (ansiblelab_node_1, …, ansible_node_5). To target hosts 1, 2 and 3 with Ansible ping module, run:


With just 3 nodes containers present, ping module will show error on 2 nodes if all 5 from the inventory are targetted:


To scale the number of hosts to 5 manually, you can use “docker-compose up -d –scale node=5” command as follows:


Run some shell command (Ansible “shell” module) on all 5 nodes from the inventory (query the host hostname, executive user ID, and uname):


To shutdown gracefully and cleanup everthing:


A few useful commands

Some Ansible modules:

Example playbook YAML file:

- name: My playbook
  hosts: ansiblelab_node_*
    - name: get /etc/hostname file
        src: /etc/hostname
        dest: /tmp/fetched