Configuring Web Server 0n Docker Container Using Ansible .
Nikhil Suryawanshi
MLOps Engineer | 7x GCP | Kubernetes | Terraform | AWS | DevOps | Java | Python
Task Description??
??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 web server
Tools Required for the task-
controller node configured with ansible
Managed node .
Lets start the process.
Now I am in my controller node in which I already configured Ansible and here I write code for Ansible.
/etc/ansible/ansible.cfg- is path of configuration file of ansible.
This config file contains the location of Inventory.
In inventory the IP, user name and password of managed node is written whom we want to configure.
Here I have my playbook for ansible and webpage that I have to copy in docker web container.
Web page -
Ansible Playbook -
Let me show you that I don’t have docker installed and configured in managed node.
Now Atlast we have to run one single command from which our managed node will be configure for the ansible task that is listed above.
“ansible-playbook confweb.yml”
when you run this command . you will see this kind of output.
Docker has been installed. & Docker services has been started.
Image is pulled from docker hub .
Docker container has launched .
Yum has been configured for docker, Docker repo has been created.
Webpage has been copied in this directory .
This is the website that is running on docker container that has been launched by docker (in a managed node that has been configured by Ansible).
TASK COMPLETED !!!!!
Cloud Technical Solutions Engineer @ Google
4 年Great work ??