Manali Jain
3 min readMar 17, 2021

--

🔰Write an Ansible PlayBook that does the following operations in the managed nodes:

🔹 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

PREREQUISITE -

  1. Install Ansible

CREATE INVENTORY FILE -

Inventory file must contain the following information about Target Node.-

  1. IP Address
  2. User name
  3. Password
  4. Connection

CODE -

I have used a dummy file but those who want to deploy code must use the proper code file.

CONFIGURE WEB SERVER ON DOCKER CONTAINER BY ANSIBLE -

  1. It will ask for a directory name.
  2. Mount the cd to folder.
  3. Configure yum.
  4. Install docker software.
  5. Start the docker service
  6. Pull http image.
  7. Start container service.

RUN -

[“ ansible-playbook file.yml ”] this is the command to run the ansible playbook.

FINAL PAGE-

As i have used dummy code.

CONTAINER RUNNING -

[ docker ps ] is the command which show all running containers.

[ netstat -tnlp ] is the command which is showing docker container running.

STEPS OF PLAYBOOK -

DVD MOUNTED-

YUM CONFIGURED-

OUTPUT-

GITHUB LINK — https://github.com/manali1230/Configure_Docker_and_Webserver_on_Docker_by_Ansible.git

Thank You for Reading!!

--

--

Manali Jain

You are the only one person who can Change Yourself…