Integration of Docker with Ansible !!!
Anushka Visapure
Solution-Oriented DevOps Engineer || Skilled in Kubernetes | Terraform | Ansible | Docker | Git and GitHub | GitHub Action || Expanding Capabilities in AWS | GCP | Linux.
Integration of Docker with Ansible (Task 10)
Write an Ansible Playbook for Docker operations in the managed node
- 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
What is Ansible ?
- Ansible is an open-source software provisioning, configuration management, and application-deployment tool enabling infrastructure as code. It runs on many Unix-like systems, and can configure both Unix-like systems as well as Microsoft Windows. It includes its own declarative language to describe system configuration.
What is Docker ?
- Docker is an open-source project for automating the deployment of applications as portable, self-sufficient containers that can run on the cloud or on-premises. Docker is also a company that promotes and evolves this technology, working in collaboration with cloud, Linux, and Windows vendors, including Microsoft.
Pre-requisites:
- For the integratiom of Ansible with Docker we require two redhat8 os with yum configuration
- * Controller Node
- * Managed Node
So let's Start.......
So first we have to start both the os ..then go to the controller node and install the ansible . Ansible tool work on the python thus to install the ansible we have to use the pip3 command
command : pip3 install ansible
Then we have check wether the Ansible is install or not .For checking
command : ansible --version
Now we have to go at managed node ..and check the IP of the managed node
When we can get the IP of managed node then go to the controller node and create the inventory file
After that create the configuration file by using the command :
" cd /etc/ansible/"name_of_file".cfg "
Now check the connection between the controller node and managed node by using the command : ansible all -m ping
Then start the ansible-playbook
First we need the docker repository. For creating the repository we have download the docker package from the baseurl
Then we have install the docker_package
After installing the package we have to start the docker service
Then we have install the python software and python package for the docker
Then to run the container we need image ...so pull the image
And now we have create the docker container
Then the web page which we can copy in managed node copy to the apache webserver directory
Now we have to start the docker service
Lets see the outputs :
And finally check the docker service at managed node started or not
Lets check the output of webpages :
And finally Task completed successfully...
Cloud Technical Solutions Engineer @ Google
4 年Well done Anushka Visapure ??
DevOps @Forescout ?? | Google Developer Expert | AWS | DevOps | 3X GCP | 1X Azure | 1X Terraform | Ansible | Kubernetes | SRE | Platform | Jenkins | Tech Blogger ??
4 年Great Anushka Visapure