Integration of Docker with Ansible !!!

Integration of Docker with Ansible !!!

Integration of Docker with Ansible (Task 10)

Write an Ansible Playbook for Docker operations in the managed node

  1. Configure Docker
  2. Start and enable Docker services
  3. Pull the httpd server image from the Docker Hub
  4. Run the httpd container and expose it to the public
  5. Copy the html code in /var/www/html directory and start the web

What is Ansible ?

What is Docker ?

  • Docker is an open-source project for automating the deployment of applications as portable, self-sufficient containers that can run on the cloud or on-premises. Docker is also a company that promotes and evolves this technology, working in collaboration with cloud, Linux, and Windows vendors, including Microsoft.

Pre-requisites:

  • For the integratiom of Ansible with Docker we require two redhat8 os with yum configuration
  • * Controller Node
  • * Managed Node

So let's Start.......

So first we have to start both the os ..then go to the controller node and install the ansible . Ansible tool work on the python thus to install the ansible we have to use the pip3 command

command : pip3 install ansible

Then we have check wether the Ansible is install or not .For checking

command : ansible --version

No alt text provided for this image

Now we have to go at managed node ..and check the IP of the managed node

No alt text provided for this image

When we can get the IP of managed node then go to the controller node and create the inventory file

No alt text provided for this image

After that create the configuration file by using the command :

" cd /etc/ansible/"name_of_file".cfg "

No alt text provided for this image

Now check the connection between the controller node and managed node by using the command : ansible all -m ping

No alt text provided for this image

Then start the ansible-playbook

First we need the docker repository. For creating the repository we have download the docker package from the baseurl

No alt text provided for this image

Then we have install the docker_package

No alt text provided for this image

After installing the package we have to start the docker service

No alt text provided for this image

Then we have install the python software and python package for the docker

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

Then to run the container we need image ...so pull the image

No alt text provided for this image

And now we have create the docker container

No alt text provided for this image

Then the web page which we can copy in managed node copy to the apache webserver directory

No alt text provided for this image

 Now we have to start the docker service

No alt text provided for this image

Lets see the outputs :

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

And finally check the docker service at managed node started or not

No alt text provided for this image

Lets check the output of webpages :

No alt text provided for this image

And finally Task completed successfully...

Thank you Mr. Vimal Daga sir ..


Adarsh Kumar

Cloud Technical Solutions Engineer @ Google

4 年

Well done Anushka Visapure ??

Onkar Naik

DevOps @Forescout ?? | Google Developer Expert | AWS | DevOps | 3X GCP | 1X Azure | 1X Terraform | Ansible | Kubernetes | SRE | Platform | Jenkins | Tech Blogger ??

4 年

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

Anushka Visapure的更多文章

社区洞察

其他会员也浏览了