
Ansible PlayBook to install docker -community edition and launch a docker container with httpd configured and service started .
In this practical I used 192.168.43.103 as Controller Node and 192.168.43.105 as Managed Node .
In Ansible Playbook :




tasks:
STEP 1
Configuring Yum with docker repo link ,So that later if we ask the “package” module to install docker-ce package .It would be installed smoothly . Here I am using “copy” module.

STEP 2
Now , Installing Docker Package with help of “package” module .

STEP 3
Installing Python Interpretor ,So that later if Docker requires python module ,I can install it easily .Here I used “package” module , ‘register’ keyword to register to all the output in value ,and then I used “debug” module which helped me to show the output when we run the playbook .

STEP 4
Now to launch any docker container ,We need to install docker-py module. Here I used ‘command’ and ‘register’ keyword and “debug” module .

STEP 5
Starting the docker services .I used “service” module here.

STEP 6
To launch any container ,We need to have a Docker-Image and this practical is all about to launch a Web server. So in hub.docker.com ,There is one image which is purely dedicated on httpd which I am using .Here I used “docker_image” module .

STEP 7
Creating a new folder in the Managed node ,So that I could link that folder as my httpd document root folder .Here I used “file” module .

STEP 8
Creating a new webpage in that Folder, So that later I can link that folder in the document root. Here I used “copy” module .

STEP 9
Launching a Docker container using httpd image which I downloaded before .Here I used “docker_container” module .

After Running the Playbook :
ansible-playbook docker1.yml



Now Finally, My webpage is deployed which is running on httpd container .