What is Ansible?
Ansible is an open-source automation tool, or platform, used for IT tasks such as configuration management, application deployment, intraservice orchestration, and provisioning. Automation is crucial these days, with IT environments that are too complex and often need to scale too quickly for system administrators and developers to keep up if they had to do everything manually. Automation simplifies complex tasks, not just making developers’ jobs more manageable but allowing them to focus attention on other tasks that add value to an organization.
What is Docker?
Docker is a set of platform as a service (PaaS) products that use OS-level virtualization to deliver software in packages called containers. Containers are isolated from one another and bundle their own software, libraries and configuration files. All containers are run by a single operating system kernel and therefore use fewer resources than virtual machines.
Ansible Playbooks :
Ordered lists of tasks, saved so you can run those tasks in that order repeatedly. Playbooks are written in YAML format.
A list of managed nodes. An inventory file is also sometimes called a hostfile . Your inventory can specify information like IP address for each managed node.
Any machine with Ansible installed is known as controller node. You can run Ansible commands and playbooks by invoking the ansible or ansible-playbook command from any control node.
The network devices (and/or servers) you manage with Ansible. Managed nodes are also sometimes called hosts .
- 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
Install ansible in controller mode
pip3 install ansible
yum install sshpass#To see version of ansible installed
List of Managed Nodes in the inventory file
- 192.168.0.198 is IP of Managed Node
- ansible_ssh_user : Username of managed node
- ansible_ssh_pass: password of managed node
Ansible Configuration File
To view all Managed Nodes connected
ansible all --list-hosts
To check connectivity with all Managed Nodes
ansible all -m ping
Link to Code
Contribute to sarthak-sriw/ansible_ws development by creating an account on GitHub.
Check docker is configured and services are started in Managed Node
docker --versionsystemctl status docker
Check container is launched
Open the link in browser