How Ansible works with Containerization Technology?

How Ansible works with Containerization Technology?

Ansible playbook can execute multiple tasks in one go!

Docker configuration, starting and enabling docker services, pulling docker image from docker hub, copying web pages and starting web server can be done at once with the help of Ansible.

Requirements: Ansible Controller Node (CN) where Ansible is present and you have to run the ansible playbook in it, Managed Node (MN) where you want tasks to be executed.

ansible.cfg file in Controller Node:

No alt text provided for this image


ip.txt is an Inventory file which contains Managed Node information such as IP Address Username and Password of Managed Node.

Ansible Playbook docker.yml and html file in Controller Node:

No alt text provided for this image

Before running the Ansible Playbook, check if required packages in Managed Node are already present or not.

No alt text provided for this image

Packages are not present in Managed Node, So here comes the role of Ansible!!!!

Ansible Playbook docker.yml :

No alt text provided for this image

Running docker.yml Ansible Playbook in Controller Node:

No alt text provided for this image

Now Lets check in the Managed Node whether the tasks are done or not!!!

No alt text provided for this image

As you can see, Docker and httpd web server is configured, Docker service is started and httpd docker image is downloaded and docker container is launched successfully!!!

--> Lets move onto the next part!

Starting httpd container and exposing it to the public:

--> Inspect docker container:

No alt text provided for this image

---> Now curl the docker container to print the code of web page index.html which is copied into the docker container from Controller Node.

No alt text provided for this image
No alt text provided for this image

Finally we can conclude that Ansible has done its job very perfectly!!!

Aniket Khadye

Site Reliability Engineer at Crest data systems

4y

Great work

Like
Reply

To view or add a comment, sign in

More articles by Rutuja Sadaphule

Insights from the community

Others also viewed

Explore topics