Monday, May 25, 2020

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.

Here are some important reasons for using Ansible, such as:
  • Ansible is free.
  • Ansible is very consistent and lightweight, and no constraints regarding the operating system or underlying hardware are present.
  • It is very secure due to its agentless capabilities and open SSH security features.
  • No need of any special system administrator skills to install and use it.
  • Its modularity regarding plugins, inventories, modules, and playbooks make Ansible perfect companion orchestrate large environments.
Installing Ansible on Ubuntu:

>sudo yum update -y

>yum install ansible  -y 

>Add remote Server’s IP that you want to manage, in the Ansible Inventory file. 
Ansible Inventory is managed by the file – /etc/ansible/hosts.
sudo nano/etc/ansible/hosts

>ansible-inventory  –list -y

>Establish SSh Connection:
 ssh-keygen -t rsa

The above command will create two files id_rsa and id_rsa.pub inside the .ssh folder. Copy the content of public-key (id_rsa.pub).

>ls  -al ~/.ssh

>cat  ~/.ssh/id_rsa.pub

>Create a folder .ssh on the home directory of any user such as ec2-user on Managed node(Remote Servers). Create a file name authorized_keys  inside .ssh folder

$ mkdir  /home/ec2-user/.ssh

$ touch  /home/ec2-user/.ssh/authorized_keys

>Copy the content of id_rsa.pub from inside the file authorized_keys

>Check connectivity to all Slaves using the following command.
$ansible all -m ping -u ec2-user

>Check connectivity to a host group using the following command.
$ ansible WebServer -m ping -u ec2-user

Sample Playbook: Sample Playbook

No comments:

Post a Comment

ES12 new Features