ANSIBLE
DEVOPS ENGINEER
CHANDA GULSHAN.M.A
What is Ansible
Ansible is a tool that automates IT tasks like
setting up servers, installing apps, and managing
systems.
It’s easy to use, works without extra software,
and uses simple instructions written in YAML.
"Ansible is developed using Python."
"Ansible is owned by Red Hat, a subsidiary of
IBM."
Ansible nodes:
master node
slave node
After installing Ansible, it contains two main files:
inventory file
configuration file.
The master node and slave nodes communicate
using Python.
Ansible can be installed in two ways:
using pip
without using pip
Install ansible using pip:
Steps:
1.Create linux instance using AWS
2.Install python in Ansible master node
sudo yum install python3-pip - Installs the Python 3
package manager (pip) using yum on a Linux system with
sudo privileges.
3.Install ansible in master node
pip install ansible -Installs Ansible, an IT automation
tool, using Python's package manager (pip).
4.To check ansible version in master node
ansible --version - Displays the installed Ansible version
and related details.
5.Download the configuration file in ansible master node
wget <url link>-Downloads the .ansible.cfg configuration
file from the specified URL using wget.
configuration file of ansible:
Verify that the configuration file has been downloaded:
6.Put the slave node's IP address in the host file of the
master node.
create the host file using nano commands
put private ip address of the slave machine in hostfile
7.Verify the status of the slave machine.
ansible all -i host -m ping - used to check connectivity to all hosts listed in
the inventory file.
command:
output:
shell module:
ansible all -i host -m shell -a “mkdir sample” - This Ansible command
runs the mkdir sample shell command on all hosts in the host
inventory, creating a directory named "sample".
7.Verify the status of the slave machine.
output:
8.Install software in slave machine using shell module:
output:
package module
1.install software in slave machine using package
module
output:
2.Uninstall the software in slave machine using
package module
output:
project 1
Deploy the index.html file in slave machine
Steps:
1.create the index.html file
output:
2.copy the index.html file to slave machine using copy
module
output:
slave machine 1:
slave machine 2:
3.Check the directory on the slave machine and ensure it
exists.
output:
4.Start the httpd service on the slave machine.
output:
5.Deploy the index.html file on the slave machine.
output:
6.View the output using the slave machine's IP
address.