Configuring Docker and HTTPD server using Ansible Playbook
Task Description
- 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 webserver.
In this task, I have created an ansible playbook, through which the docker is installed, configured, and started.
Further, I have pulled the HTTPD docker image from the docker hub and copied files in it.
and then I started the webserver.
— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —
- hosts : all
tasks :
- -name : repository
yum_repository :
name : docker repo
description : Docker repo
baseurl : “https://download.docker.com/linux/centos/7/x86_64/stable/”
gpgcheck: no— command : “yum install docker-ce — nobest -y”
- name :
service :
name : “docker”
state : started- pip:
name : docker- name : Pulling httpd server image
docker_image :
name : “httpd”
source : pull- name : Webpage Copy
copy :
src : “my.html”
dest : /home- name : container creation
docker_container :
name : web
image : httpd
state : started
ports :
— “8080:80”
volumes:
— /home:/usr/local/apache2/htdocs