Note: currently working on how to copy html images into the container.

Except last part everything is configured as per my knowledge.

🔰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 (incomplete)
and start the web server (httpd image automatically starts the webserver and by default prints “It Works!”)

To do the following, first we need to add the ip addresses and authentication details of the managed nodes into the text file and provide the location of the file to the ansible configuration file ansible.cfg.

The content of ip.txt file:

the content of ansible.cfg file:

Checking the connection:

Getting pre-requisite library community.general for ansible that contains module docker_images that can be used to manipulate docker. Command used to install the dependent library is — ansible-galaxy collection install community.general.

The playbook That will perform the following task-

Screenshots of the execution of the tasks:

checking on browser to see whether the webserver can be connected or not: