Integration of Docker and Ansible
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
INTRODUCTION TO ANSIBLE -
*Ansible is tool which is used for Configuration Management (CM). In Ansible we only tell to “what to do”. We don’t need to tell “How to do” because Ansible already knows that “How to do this task” on each type of Operating System .
*This intelligence of Ansible comes from “modules” . Modules know “How to do this operation on each OS”. We don’t require to tell particular OS command. Ansible don’t perform any operation on OS. It is done by respective OS command. Ansible module know which command is required to run on OS to do this.
INTRODUCTION TO DOCKER -
*To setup operating system we have four technologies -
1). Bare Metal
2). Virtualization
3). Cloud
4). Containerization
*In Bare Metal , Virtualization and Cloud technologies operating system takes 1/2 hour to setup OS. If any reason OS is crashed then it will again take same time to setup this. But in Containerization technology OS takes less than only some seconds to setup this. It is very helpful in many cases.
*Docker is tool which works on containerization technology. Docker takes less than 1 second to set up all environment of OS. Docker is very fast to handle this . One of the reason is docker use base OS components.
Prerequisite -
Install two VM’s in the system . One as Controller Node and other as Managed Node and download ansible in Controller Node .
*Now follow these steps in the Controller Node -