Create Ansible-Playbook to setup web Apache server on Docker.

Abhishek Sharma
Oct 23, 2020


What is Ansible?

Ansible is an open-source software provisioning, configuration management, and application-deployment tool enabling infrastructure as code. It runs on many Unix-like systems, and can configure both Unix-like systems as well as Microsoft Windows.

Ansible Docs —

What is Docker?

Docker is a set of the platform as service products that use OS-level virtualization to deliver software in packages called containers. Containers are isolated from one another and bundle their own software, libraries, and configuration files; they can communicate with each other through well-defined channels. Developing apps today requires so much more than writing code.

What is Apache HTTP Server?

The Apache HTTP Server, colloquially called Apache, is a free and open-source cross-platform web server software, released under the terms of Apache License 2.0. Apache is developed and maintained by an open community of developers under the auspices of the Apache Software Foundation.


Write an Ansible PlayBook that does the following operations in the managed nodes:

🔹 Configure Docker.

🔹 Start and enable Docker services.

🔹 Pull the httpd server image from the Docker Hub.

🔹 Run the httpd container and expose it to the public.

🔹 Copy the html code in /var/www/html directory and start the webserver.

Playbook file would look something like this..

Now run the playbook:

We have successfully run our playbook code, now let’s take a look at our managed node.

Docker is up & running.

Web Apache Server is successfully!!!!!

Thank You….