Integration of Docker and Ansible
Deployment Of WebServer On Docker Using Ansible:-
TASK1-
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.
Basic prerequisite :-
Install two VM’s in your system . One as Controller Node and the other as Managed Node. and download ansible in manager node.
Basic Terms :-
Ansible :- It is an open-source automation tool, or platform, used for IT tasks such as configuration management, application deployment, intraservice orchestration, and provisioning.It’s one of the most useful use case is , suppose we don’t know commands of different types of os so we just need to tell ansible that what we want to do.
Controller Node:- A controller node is a Linux server that has Ansible installed on it and is used for managing remote hosts or nodes.
Managed Node:- The remote systems managed by the controller node are known as Managed Hosts or Managed Node.
Playbook:- It is one of the core features of ansible and tell ansible what to execute. They are like a to-do list for ansible that contains a list of tasks.
Now Follow these steps in the Controller Node:-
1- Check the version of the Ansible installed in the controller node by using ansible — version command.
2- Now, follow the screenshots given below:-
vim /etc/ansible/ansible.cfg
This is the main configuration file of ansible.
This is the inventory file of ansible which is present at location->
vim /etc/hosts.txt
Than we have to make file..
- vim docker_setup.yml
3- Run the Ansible-Playbook by using the command:-
ansible-playbook docker_setup.yml
OUTPUT:-
4- On Browser, type the IP Address:port/filename.