Ansible Playbook to configure Docker
WHAT IS ANSIBLE?
Ansible is powerful IT automation that you can learn quickly. It is simple enough for everyone in your IT team to use, yet powerful enough to automate even the most complex deployments.
Ansible Architecture is designed in such a way which uses some intelligence kind of thing and knows how to do, we only need to specify what to do.
Ansible can be used in 2 ways for configuration management:
1. Ad-hoc
2. PlayBook
🔹 Configure Docker
🔹 Start and enable Docker services
🔹 Pull the httpd server image from the Docker Hub
🔹 Run the docker container and expose it to the public
🔹 Copy the html code in /var/www/html directory and start the web server
IP of CN
IP of MN
Checking whether Ansible is installed or not:
ansible — version
Creating inventory:
Updating the ansible configuration file:
Checking the hosts, and connectivity to the hosts:
Creating a Play Book:
# vim dock_conf.yml
Executing PlayBook:
Let’s verify the Managed node:
Checking docker yum repo configuration
2. Checking Docker installation and services:
3. Checking the docker pulled image and checking whether the container is launched or not:
4. Port checking:
The docker named webserver1 is successfully launched in MN.
5. Going inside docker container to verify further things:
6. Checking the container webserver1 IP:
Our webserver is deployed successfully, now check the webpage: