ARTH — Task 10
🔰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 web server
Ansible is an open-source software provisioning, configuration management, and application-deployment tool enabling infrastructure as code. It runs on many Unix-like systems, and can configure both Unix-like systems as well as Microsoft Windows.
Note: I’m using one controller node and one host node for this task
How to install ansble
pip install ansible
then
yum install sshpass
to check it
type ansible — version

now to add inventory:
mkdir /ip.txt
This file acts as a DB of IPs to manage, in it

now, we know that it is inventory but ansible does not know it so we have to configure it
go to: cd /etc/ansible
make a file of any name but extension should be .cfg, in yhis file we write the path of inventory.

Note:I have added host_key_checking=false
now run : ansible all — list-hosts

Note: Prerequisites: Yum configured for docker
To check connectivity to the target nodes:type
ansible all -m ping

now to configure the yum using playbook:

type : ansible-playbook — syntax-check <file_name.yml>


Yum playbook file

Now to install the docker using ansible: we have to configure the yum repo for docker ,so we have to add docker repo in the playbook

now for docker i have created a another playbook
To install docker:

now the docker file

you are done