Configure Docker Using Ansible Playbook.
Hello Everyone !! Hope Everything is going well …
Here we are going to configure dockers using ansible playbook. but before this Let me brief the terms
Docker:
Docker is a tool designed to make it easier to create, deploy, and run applications by using containers. Containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and deploy it as one package.
Ansible:
Ansible is an automation tool that provides simple but powerful automation for cross-platform computer support. It is primarily intended for IT professionals, who use it for application deployment, updates on workstations and servers, cloud provisioning, configuration management.
Task Description
🔰Write an Ansible PlayBook that does the following operations in the managed nodes:
🔹 Configure Docker
🔹 Start Docker services
🔹 Pull the httpd server image from the Docker Hub
🔹 Run the docker container and expose it to the public
Tasks:
- Configure Docker :-
- configure yum using yum_repository ansible module
- install docker using yum which is a cmd of linux and to run command using ansible we need to use command module
- Docker SDK for Python
A Python library for the Docker Engine API. It lets you do anything the docker
command does, but from within Python apps – run containers, manage containers, manage Swarms, etc.
2. Start and enable Docker services
service is a ansible module to manage services
3. Pull the httpd server image from the Docker Hub
docker_image is a ansible module used to pull the docker images
4. Run the docker container and expose it to the public
docker_container is a ansible used to run docker container and published_port is a attribute used to expose the post to webservers’s port
** Final playbook
** Command to run ansible playbook
ansible-playbook <name_of_playbook>
As we exposed the port at 8080 thus URL to check the web server is
<ip of base OS(where we run the playbook )>:8080
Here the web server runs successful !!!!
— — — — — — — — —— — 🎉Thank You 🎉 — — — — — — — — — —
****This artical comes under the ARTH-The School of Technology program mentorship of Mr. Vimal Daga sir *****