How Ansible works with Containerization Technology?
Ansible playbook can execute multiple tasks in one go!
Docker configuration, starting and enabling docker services, pulling docker image from docker hub, copying web pages and starting web server can be done at once with the help of Ansible.
Requirements: Ansible Controller Node (CN) where Ansible is present and you have to run the ansible playbook in it, Managed Node (MN) where you want tasks to be executed.
ansible.cfg file in Controller Node:
ip.txt is an Inventory file which contains Managed Node information such as IP Address Username and Password of Managed Node.
Ansible Playbook docker.yml and html file in Controller Node:
Before running the Ansible Playbook, check if required packages in Managed Node are already present or not.
Packages are not present in Managed Node, So here comes the role of Ansible!!!!
Ansible Playbook docker.yml :
Running docker.yml Ansible Playbook in Controller Node:
Now Lets check in the Managed Node whether the tasks are done or not!!!
As you can see, Docker and httpd web server is configured, Docker service is started and httpd docker image is downloaded and docker container is launched successfully!!!
--> Lets move onto the next part!
Starting httpd container and exposing it to the public:
--> Inspect docker container:
---> Now curl the docker container to print the code of web page index.html which is copied into the docker container from Controller Node.
Finally we can conclude that Ansible has done its job very perfectly!!!
Site Reliability Engineer at Crest data systems
4yGreat work