Ansible PlayBook that configures an HTTPD web server inside Docker

Suman Sourav
3 min readApr 20, 2021

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. It includes its own declarative language to describe system configuration. Ansible was written by Michael DeHaan and acquired by Red Hat in 2015. Ansible is agentless, temporarily connecting remotely via SSH or Windows Remote Management (allowing remote PowerShell execution) to do its tasks.

What is Docker?

Docker is a set of the platform as a service (PaaS) 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. Because all of the containers share the services of a single operating system kernel, they use fewer resources than virtual machines.

What is Apache HTTPD?

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.

So, to configure the HTTPD server we first need

i) Ansible Configured Manager Node.

ii) Managed Node which will be working as a web server.

STEP 1: Create an Ansible Playbook as below

STEP 2: Update the Ansible inventory and add the IP address of the Managed Node

STEP 3: Update the ansible.cfg file. Here I am using AWS EC2 instance as a Managed node.

STEP 4: Try to ping the managed host to check the connection

ansible -m ping all

STEP 5: Run the Playbook

ansible-playbook <playbookname.yml>

STEP 6: Test your Webpage

Here I have exposed port 1234 therefore my webpage is available at <IP>:<ExposedPortNo>

GIT : https://github.com/SammyFidato/ansiblehadockerwebserver

--

--