Ansible Setup for Easy Automation

What is Ansible
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. It includes its own declarative language to describe system configuration. Ansible was written by Michael DeHaan and acquired by Red Hat in 2015. Ansible is agentless, temporarily connecting remotely via SSH or Windows Remote Management (allowing remote PowerShell execution) to do its tasks.
Ansible helps you manage multiple machines by selecting a portion of Ansible’s inventory stored in a simple ASCII text file. Inventory is configurable and the target machine inventory can be obtained dynamically or from cloud-based sources in various formats (YAML, INI). Ansible Vault has been able to store sensitive data in encrypted files since 2014. In contrast to other popular configuration management software such as Chef, Puppet, and CFEngine, Ansible uses an agentless architecture. This causes the Ansible software to not run normally or to be installed on the controlled node. Instead, Ansible tunes the node by temporarily installing and running the module on the node via SSH. During the orchestration task, the process running the module communicates with the control machine using JSON-based protocols over standard inputs and outputs. If Ansible does not manage the node, it does not run daemons or install software and therefore does not consume resources on the node.
EFFICIENT ARCHITECTURE
Ansible works by connecting to your nodes and pushing out small programs, called “Ansible Modules” to them. These programs are written to be resource models of the desired state of the system. Ansible then executes these modules (over SSH by default), and removes them when finished.
Your library of modules can reside on any machine, and there are no servers, daemons, or databases required. Typically you’ll work with your favorite terminal program, a text editor, and probably a version control system to keep track of changes to your content. To use Ansible, We need the help of Ansible Master and add master ssh to all clients. Here we’ll discuss the ansible set up.
The architecture of the System

The master setup
All Node must have a login for the Ansible - For Ubuntu
sudo apt-get install ansible- Set an SSH
ssh ansible@master_host_address— Copy the ssh id and add it to the known host
ssh-copy-id ansible@node_host_address - Copy the RSA to the Client Node using SCP( Secure Copy Paste)
scp id_rsa.pub clientName@IP_ADDRESS:.ssh/id_rsa.pub- Add all the hosts in the Ansible — go to the Ansible folder — The Ansible folder directory is (/etc/ansible) — Edit the host's folder
[linux]
Linux Node Address 1
Linux Node Address 2
……
Linux Node Address N- Run ansible code to run the ping all
ansible all -i hosts -m pingOr to run from any other folder
ansible all -m pingClient Setup Process :
- Enable SSH
- Log in to the System
- Add user ansible
sudo adduser ansibleSome Ansible Commands
Gather All Information It will show all the information
ansible all -m gather_factsLimit Gather All Information
It will show all the information
ansible all -m gather_facts — limit IP_ADDRESSPing the Nodes
ansible all -m pingGet System Name and Uptime Details
ansible all -m shell -a “uname -a; uptime”Get System Process Details
ansible all -m shell -a “ps -eaf | grep http”Hope this helps you. Now your system is ready to do/ perform any automation task.
