DOCKER CONFIGURATION WITH ANSIBLE

DOCKER CONFIGURATION WITH ANSIBLE

Hey connections!!

TASK DESCRIPTION :

Write an Ansible PlayBook that does the following operations in the managed nodes:

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 server.

FOR ACHIEVING ABOVE TASK WE HAVE TO FOLLOW CERTAIN STEPS WHICH IS MENTIONED BELOW :

STEP 1 :

Ansible is an automation tool and for doing certain automation , 1st of all we have to give the proper information of our target node and this information is stored in some file and this file is known as "INVENTOTRY"

Here , I have created an inventory "ip.txt" and I had attached it on ANSIBLE CONFIGURATION FILE .

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

STEP 2 :

Now after adding our inventory to the ansible configuration file , then next step is the check the connectivity between Controller Node and Target Node .

For this we use a command

"ansible all -m ping"

After running the above command we get

No alt text provided for this image

which means We have successfully connected with our target node .

STEP 3 :

After connection now we have to write a playbook for ansible . for this first of all we have to make a workspace for it and here i made a folder "task1" and inside this folder i made a file with an extension of " .yml " and i named this file as "ansible_task.yml"

NOW , WE HAVE TO WRITE OUR PLAYBOOK FOR ANSIBLE

STEP 4 : YUM CONFIGURATION FOR DOCKER

No alt text provided for this image


STEP 5 : DOWNLOAD DOCKER


No alt text provided for this image

STEP 6 : START DOCKER SERVICE

No alt text provided for this image

STEP 7 : DOWNLOAD DOCKER SDK ON DOCKER HOST

No alt text provided for this image

STEP 8 : CREATING MOUNT PATH FOR DOCKER CONTAINER

No alt text provided for this image

STEP 9 : PULLING DOCKER IMAGE

No alt text provided for this image


STEP 10 : LAUNCHING DOCKER CONTAINER USING HTTPD IMAGE


No alt text provided for this image

STEP 11 :

After writing above playbook now it time to check the syntax and then run it .

FOR SYNTAX CHECKING :

"ansible-playbook --syntax-check ansible_task.yml "

FOR RUNNING :

"ansible-playbook ansible_task.yml "

STEP 12 :

After running above commands we get

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

Our playbook run successfully without any error .

Now lets check whether our desire work was done or not .....

  1. YUM IS CONFIGURE SUCCESSFULLY
No alt text provided for this image
No alt text provided for this image


2. DOCKER WAS SUCCESSFULY DOWNLOADED

No alt text provided for this image

3. OUR DOCKER SERVICE WAS STARTED

No alt text provided for this image

4. MOUNT PATH WAS CREATED SUCCESSFULLY

No alt text provided for this image

5. DOWNLOAD DOCKER SDK IN DOCKER HOST

No alt text provided for this image

6. PULLING DOCKER IMAGE AND LAUNCHING DOCKER HTTPD IMAGE

No alt text provided for this image


STEP 13 : COLLECT THE IP AND BROWSE IT ON BROSWER

No alt text provided for this image


Finally our task are successfully done .

Thank you for visiting !!

Have A Nice Day !!



To view or add a comment, sign in

More articles by Manish kumar Singh

  • DevSecOps With Kubernetes or In Kubernetes ?

    In today's rapidly evolving technological landscape, the need for robust security measures within Kubernetes clusters…

    3 Comments
  • HashiCorp Vault and Kibernetes Secrets

    So, without any further delay lets jump directly to the Introduction and Installtion part . Introduction : HashiCorp…

  • Full Automate Load balancer on AWS EC2 with the integration of Terraform and Ansible

    Hey folks !! Today I am going to discuss the real use cases of one of the most intelligent automation tool i.e…

    6 Comments
  • INDUSTRY USE CASES OF K8S

    KUBERNETES Kubernetes is an open-source container-orchestration system for automating computer application deployment…

  • Industry uses cases of Openshift

    OPENSHIFT OpenShift is a family of containerization software products developed by Red Hat. Its flagship product is the…

    2 Comments
  • Industries use cases of Jenkins

    What is Jenkins? Jenkins is an open source Continuous Integration server capable of orchestrating a chain of actions…

  • Industry uses cases of Neural etworks (NN)

    Today, neural networks (NN) are revolutionizing business and everyday life, bringing us to the next level in artificial…

  • Industries use cases of Openshift

    Hey Connection !! Yesterday I have attended a session of Industry Uses of OpenShift which is organized by Linux World .…

  • ANSIBLE with REDHAT EXPERTS

    On 28th December , 2020 I had attended a great session by Redhat Experts which is organized by LinuxWorld Informatics…

  • AUTOMATION VS ORCHESTRATION

    What is IT automation? Automation, generally speaking, means completing a single task or function without human…

Insights from the community

Others also viewed

Explore topics