What is Ansible
Ansible is a radically simple IT automation engine that automates cloud provisioning, configuration management, application deployment, intra-service orchestration, and many other IT needs.
Ansible is the simplest way to automate apps and IT infrastructure. Application Deployment + Configuration Management + Continuous Delivery.
What is 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.
PROBLEM STATEMENT :
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 httpd container and expose it to the public
🔹 Copy the html code in /var/www/html directory and start the web server
In this following problem statement we will integrate Docker with Ansible. And that Docker container has a Web Server on which we deploy a website. For solving this use case we have to follow some steps and all the steps must be done by using ansible play.
STEP 1: In this step I will configure my Ansible so that they can get connected to managed nodes.
STEP 2:In this step I will check the managed nodes such that it don’t have docker repository and docker installed in it.
STEP 3:In this step I will create a task1_playcode directory which contain the playbook code for this task.
STEP 4:In this step I will start writing the plays for each & every step that is mentioned in problem statement & that file will be in YAML format
Filename = dockercode.yml
In this play we write one play which copies a sample web page code from my system to docker container.
STEP 5:In this step I will run this playbook file by following command:
STEP 6:In this step I will check the managed node and observe that now it has:
Webserver image pulled i.e. ashwani2399/webserver:v1
One conatiner is running