Configuring Web Server 0n Docker Container Using Ansible .

Configuring Web Server 0n Docker Container 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

Tools Required for the task-

controller node configured with ansible

Managed node .

Lets start the process.

Now I am in my controller node in which I already configured Ansible and here I write code for Ansible.

No alt text provided for this image

/etc/ansible/ansible.cfg- is path of configuration file of ansible.

This config file contains the location of Inventory.

No alt text provided for this image

In inventory the IP, user name and password of managed node is written whom we want to configure.

No alt text provided for this image

Here I have my playbook for ansible and webpage that I have to copy in docker web container.

Web page -

No alt text provided for this image

Ansible Playbook -

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

Let me show you that I don’t have docker installed and configured in managed node.

No alt text provided for this image

Now Atlast we have to run one single command from which our managed node will be configure for the ansible task that is listed above.

“ansible-playbook confweb.yml”

when you run this command . you will see this kind of output.

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

Docker has been installed. & Docker services has been started.

No alt text provided for this image

Image is pulled from docker hub .

No alt text provided for this image

Docker container has launched .

No alt text provided for this image

Yum has been configured for docker, Docker repo has been created.

No alt text provided for this image

Webpage has been copied in this directory .

No alt text provided for this image

This is the website that is running on docker container that has been launched by docker (in a managed node that has been configured by Ansible).

No alt text provided for this image



TASK COMPLETED !!!!!

Adarsh Kumar

Cloud Technical Solutions Engineer @ Google

4 年

Great work ??

回复

要查看或添加评论,请登录

Nikhil Suryawanshi的更多文章

社区洞察

其他会员也浏览了