CONFIGUREING APACHE WEBSERVER IN CONTAINER (DOCKER) USING ANSIBLE PLAYBOOK

Anil Yadav
3 min readFeb 15, 2021

--

Frist Task on RH-294(Linux Automation Using Ansible)

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

In this Task, We have a Controller node and one Target Node is configured. In the Controller Node use “pip3 install ansible “ command to install Ansible

Now, let’s create an inventory file use : “vim ip.text” command And write Information about Target Node like, IP Address, user name , passwd.

We need to specify the path of inventory file in the /etc/ansible/ansible.cfg file.

Now, list the hosts using following command:

I write a YAML file with the name “web.yml”, known as a PLAYBOOK.

Now, let’s run the above Playbook using following command :

Above is the output of the ansible playbook , Every step running successfully, and below is the output of the Target node:

yum is Successfully configure for docker

Docker installed Successfully

Httpd container Running Successfully

Check the IP address of the container

Successfully done, The CONFIGUREING APACHE WEBSERVER IN CONTAINER (DOCKER) USING ANSIBLE PLAYBOOK.

THANK YOU !!!

Hope you like it! A like or comment gives me motivation .

Keep Learning___Keep sharing!!!!

--

--