Integrating Ansible with Docker.
Task Description :-
- Create a Ansible Playbook to configure the docker
- Create a Ansible Playbook which will create docker Image and launch the container with this image & update the inventory dynamically
- Create a Ansible playbook which will configure webserver inside the docker container
Let’s start doing our task :-
- Create a Ansible Playbook to configure the docker-
Let’s write Ansible playbook to configure the docker
this playbook configure the docker in your base system, Let’s run this playbook.
ansible-playbook configuredocker.yml
- Create a Ansible Playbook which will create docker Image and launch the container with this image & update the inventory dynamically
Let’s write playbook
Before run this playbook we have to create Dockerfile
Let’s create Dockerfile:-
mkdir /dw
vim /dw/Dockerfile
When we create docker image using this Dockerfile then SSH will be enabled in this image and we can connect our container with SSH.
Now let’s run our playbook:-
ansible-playbook container.yml
Output of playbook
- Everything is working fine let move to another step.
- Create a Ansible playbook which will configure webserver inside the docker container:-
This above playbook launch the webserver inside container.
Let’s run this playbook
ansible-playbook webserver.yml
Playbook runs successfully.
Let’s connect our webserver
http://docker-host-ip:port-no/webpage-name
it’s working fine.
Thanks for Reading