Integrating Ansible and Docker For Deploying the web server

Vanshita Mittal
3 min readNov 27, 2020

--

Ansible :

Ansible is an open source automation tool meant for these purposes. Ansible does this all things for us using the code i.e Ansible-playbook.

Task Description📄

🔰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 docker container and expose it to the public

🔹 Copy the html code in /var/www/html directory and start the web server

STEPS :

  1. Before the task , firstly controller node should be configured with ansible setup and Managed node should be configured with yum.

To check ansible setup ->

To check ansible config file->

2. To check all hosts use below command.

There should be connectivity with controller and managed node->

3. Now , write the code in ansible playbook :

To create docker repository and docker installation

after docker installation , install python and then start docker services.

then copy webpage , pull httpd image from docker hub

then launch container using httpd image

4. Now, to check syntax of playbook , use below command.

5. Now, run this playbook.

6. Now, go to managed node and here docker repository is created.

7. httpd image is pulled and container is launched .

8. Now to check our webpage .

✨Task is successfully completed !!✨

Thank You !!

--

--

No responses yet