🔰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 docker container and expose it to the public
🔹 Copy the html code in /var/www/html directory and start the webserver
PREREQUISITE -
- Install Ansible
CREATE INVENTORY FILE -
Inventory file must contain the following information about Target Node.-
- IP Address
- User name
- Password
- Connection
CODE -
I have used a dummy file but those who want to deploy code must use the proper code file.
CONFIGURE WEB SERVER ON DOCKER CONTAINER BY ANSIBLE -
- It will ask for a directory name.
- Mount the cd to folder.
- Configure yum.
- Install docker software.
- Start the docker service
- Pull http image.
- Start container service.
RUN -
[“ ansible-playbook file.yml ”] this is the command to run the ansible playbook.
FINAL PAGE-
As i have used dummy code.
CONTAINER RUNNING -
[ docker ps ] is the command which show all running containers.
[ netstat -tnlp ] is the command which is showing docker container running.
STEPS OF PLAYBOOK -
DVD MOUNTED-
YUM CONFIGURED-
OUTPUT-
GITHUB LINK — https://github.com/manali1230/Configure_Docker_and_Webserver_on_Docker_by_Ansible.git
Thank You for Reading!!