Site icon Nimesa

Ansible – In a Nutshell

Ansible is an open-source automation platform. It is simple to set up, efficient and powerful. Key use cases supported are as follows.

It is available for free and open-source. The Enterprise version is available in the name of “Ansible Tower”. The benefits of using Ansible are as follows.

  1. Agentless – Not a Master-Client model & No need to install Agent on the client-side
  2. Lightweight and faster to deploy through SSH for operation on the network
  3. The language used is ‘Python”, which is inbuilt into Unix/Linux deployments
  4. YAML syntax for file configuration
  5. Larger Community for support

See the below link for Ansible Terminologies

https://docs.ansible.com/ansible/latest/reference_appendices/glossary.html

Install Ansible using apt -get (or) yum commands:-

Inventory File & Parameters Management:- 

For example, if you have database & web servers you can indicate it in the host’s file as follows

ansbile_connection: connection type to the host

ansible_user: Default ssh user name to use

For more information on ansible parameters, see the below link

http://docs.ansible.com/ansible/latest/intro_inventory.html#list-of-behavioral-inventory-parameters

How Ansible works:-

Ansible Configuration Files:-

[root@<server_name> ~]# vi /etc/ansible/ansible.cfg
# config file for ansible — https://ansible.com/
# ===============================================
# nearly all parameters can be overridden in ansible-playbook
# or with command line flags. ansible will read ANSIBLE_CONFIG,
# ansible.cfg in the current working directory, .ansible.cfg in
# the home directory or /etc/ansible/ansible.cfg, whichever it
# finds first
[defaults] # some basic default values…
#inventory      = /etc/ansible/hosts
#library        = /usr/share/my_modules/
#module_utils   = /usr/share/my_module_utils/
#remote_tmp     = ~/.ansible/tmp
#local_tmp      = ~/.ansible/tmp
#forks          = 5
#poll_interval  = 15
#sudo_user      = root
#ask_sudo_pass = True
#ask_pass      = False

Write your first Playbook using YAML files:-

Ansible playbooks are a way to use commands to do some operations on remote computers in a scripted manner. Instead of using Ansible commands individually to remote computers, you can configure entire deployments by passing it as scripts to one or more systems.

Each playbook contains one or more plays, which map hosts to a certain function. Ansible does this through tasks, which are basically module calls.

YAML is sensitive and you need to be cognizant about using spaces. TABs are not allowed.  Characters should start exactly after the previous parameter starts. It contains three sections.

For instance, to create a basic apache web server following tasks are needed.

So the YAML file can look like the one below.

[root@ansiblenode ~]# vi install.yml

– hosts: all
tasks:
– name: Install httpd Package
yum: name=httpd state=latest
– name: Copy httpd configuration file
copy: src=/data/httpd.original dest=/etc/httpd/conf/httpd.conf
– name: Start and Enable httpd service
service: name=httpd state=restarted enabled=yes

About Nimesa

Nimesa is enterprise-class Application-Aware data protection, cost management & copy data management solution for applications running on AWS. It uses native AWS capabilities like EBS snapshots capabilities to automatically protect the environment. It provides simple policy-based lifecycle management of snapshots and clones of EC2 instances.

To know more of how to protect your environment using Nimesa refer to the previous blog

Try Nimesa for free