Ansible playbook that will retrieve new Container IP and update the inventory so that further Configuration of Webserver could be done inside that.
Source : Google

Ansible playbook that will retrieve new Container IP and update the inventory so that further Configuration of Webserver could be done inside that.

?? Task Description ??

?? 14.2 Further in ARTH — Task 10 has to create an Ansible playbook that will retrieve the new Container IP and update the inventory. So that further Configuration of the Web server could be done inside that Container.

This is an important article on the ansible-playbook and configuration of the Web server inside that Container. This article also explains how to automate the task given.

No alt text provided for this image

Task 10: https://cutt.ly/QQTzoX6

Before moving to the task let us see some important concepts:

What is ansible???

In simple words, Ansible is an?open-source IT automation engine, which can remove drudgery from your work life, and will also dramatically?improve the scalability, consistency, and reliability of your IT environment.?It is primarily intended for IT professionals, who use it for application deployment, updates on workstations and servers, cloud provisioning, configuration management, intra-service orchestration, and nearly anything a systems administrator does on a weekly or daily basis. Ansible doesn't depend on agent software and has no additional security infrastructure, so it's easy to deploy.

What is an ansible-playbook?

An?Ansible?playbook?is a blueprint of automation tasks—which are complex IT actions executed with limited or no human involvement.?Ansible playbooks?are executed on a set, group, or classification of hosts, which together make up an?Ansible?inventory.

What is dynamic inventory?

The?dynamic inventory?script can do anything to get the data (call an external API, pull information from a database or file, etc.), and?Ansible?will use it as an?inventory?source as long as it returns a JSON structure like the one above when the script is called with the --list.

No alt text provided for this image

What is docker?

Docker?is an open platform for developing, shipping, and running applications.?Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. With?Docker, you can manage your infrastructure in the same ways you manage your applications. And it also helps to install and the boot in just seconds.

What is a container?

A?Docker container?image is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries, and settings.

No alt text provided for this image

So, here we start with our task:-

No alt text provided for this image

Step 1:?Python3 should be installed on your controller node in order to install an ansible.

In my case, python3 is already installed. we can check its version by using the command:

python3 --version

        

Step 2:?Now, let's install ansible using the command:


pip3 install ansible
        
No alt text provided for this image

Step 3: Initially the inventory file is empty


 vim /etc/ansible/ansible.cfg
        
No alt text provided for this image

Step 4: Ansible Playbook for container setup and auto-updating of the inventory file

 
vim docker.yml
        
No alt text provided for this image
No alt text provided for this image

Let's check the index.html file

No alt text provided for this image

Step 5: Now let's check the code is correct or not.



ansible-playbook --syntax-check docker.yml

        
No alt text provided for this image

Step 6: let's Run the Playbooks

First, let’s set up the container and set up the inventory file


ansible-playbook docker.yml
        


No alt text provided for this image

Step 7: Inventory file is dynamically updated

No alt text provided for this image

Step 8: Now let's c Docker Service started and enabled in the system


systemctl status docker
        

Here I have used some modules of Ansible which are as follows:

?yum_repository?( For creating Docker Repo in Yum Configuration file in our Slave Node?

Package:?For installing the docker software),?

service?( For starting the Service of Docker),?

pip?(To install the Docker Python),?

docker_image?( For downloading the docker image from the Docker Hub),?

copy?(To copy my web page from Master (controller) to Slave(Target),?

docker_container?(For starting the docker webserver container).

Step 9: Let us see the output using the curl command


curl https://172.17.0.5/index.html
        
No alt text provided for this image

Step 9: Let's use the docker ps command to see it is launch or not.

No alt text provided for this image

Hence, we have successfully completed the task.

Github URL: https://github.com/pratikkprojecthub/ansibleprojects.git

Thanks for Reading the article !!! ????????

Hope you might find this article helpful!!!!

You can appreciate the article by giving it a like and posting comments about your feedback.

Feel free to ask any queries. Don’t forget to share this article with your colleagues.??

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

Pratik Kohad ????的更多文章

  • Javascript Integration With Docker

    Javascript Integration With Docker

    ?? Task Description?? ?? In this task you have to create a Web Application for Docker (one of the great…

  • Azure Kubernetes Service and its Use-Cases

    Azure Kubernetes Service and its Use-Cases

    Task Description ?? ??? Research for industry use-cases of Azure Kubernetes Service and create a blog, Article, or…

  • OSPF (Open Shortest Path First) Routing Protocol implemented using Dijkstra Algorithm

    OSPF (Open Shortest Path First) Routing Protocol implemented using Dijkstra Algorithm

    Task Description ?? ??? Write a blog describing how OSPF (Open Shortest Path First) Routing Protocol implemented using…

    2 条评论
  • MongoDB and its Use-Case

    MongoDB and its Use-Case

    Task Description?? ???Create one use-case blog or case study on how industries are using MongoDB. Hello, Connections…

  • Redhat OpenShift and its Use-Case

    Redhat OpenShift and its Use-Case

    Task Description?? ??? Research for industry use cases of RedHat OpenShift and create a blog, Article, or Video…

  • K-Means clustering and its Real World Use Case

    K-Means clustering and its Real World Use Case

    Task Description?? ??? Create a blog/article/video about explaining k-mean clustering and its real use case in the…

    2 条评论
  • Integration of AWS EC2 with WordPress using AWS RDS !!!

    Integration of AWS EC2 with WordPress using AWS RDS !!!

    ?? Task Description ?? ?? Create an AWS EC2 instance. ?? Configure the instance with Apache Web Server.

    1 条评论
  • Task 7.1 ??????

    Task 7.1 ??????

    Task Description?? ?? Elasticity Task ??Integrate LVM with Hadoop and provide Elasticity to DataNode Storage ??Increase…

  • Cyber Crime and Confusion Matrix

    Cyber Crime and Confusion Matrix

    Task Description?? ??? Cybercrime cases where they talk about confusion matrix or its two types of error. Hello…

    7 条评论
  • GUI Application On Docker Container?? ??????

    GUI Application On Docker Container?? ??????

    ?? Task Description?? ?? GUI container on the Docker ?? Launch a container on docker in GUI mode ?? Run any GUI…

社区洞察

其他会员也浏览了