ANSIBLE+DOCKER..!!

Shrishti Kapoor
3 min readMar 30, 2021

TASK DESCRIPTION

Launching a docker container and further Configuring webserver inside that docker container using Ansible Playbook..!!

Before proceeding further just check out that the inventory file is empty or not.

Since It has no target nodes to be pinged so we can now proceed further.

After this create a directory for Eg- cd task-14 in this case. This consists of all the files as shown below.

Now checking the files testing.html and web.yml

PLAYBOOK- web.yml

Now running the playbook by ansible-playbook web.yml.

Here when We run the playbook it will ask for container name so I give container name a ‘shrishti’ this will help in testing.

Now checking the inventory file ip.txt.

Now checking that Does container named shrishti launched or not using docker ps command so here we can see that a container named shrishti launched successfully..!!

To check more about the container like to check IP use docker inspect | grep IPAddress command. This will give the IP of the container.

And finally by using the IP we can test that Configuration of webserver is done inside that container successfully..!!

Future Work:

This can further be done by dynamically retrieving the IP of the container into the inventory file and further doing same process for configuring the webserver.

--

--

Shrishti Kapoor

Spread Knowledge because it’s all about Right Education..!!