Ansible is an open-source automation platform. It is simple to set up, efficient and powerful. Key use cases supported are as follows.
- Application Deployment
- Configuration Management
- Automation of Tasks
- IT orchestration
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.
- Agentless – Not a Master-Client model & No need to install Agent on the client-side
- Lightweight and faster to deploy through SSH for operation on the network
- The language used is ‘Python”, which is inbuilt into Unix/Linux deployments
- YAML syntax for file configuration
- 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:-
- apt -get install ansible
- yum install ansible
Inventory File & Parameters Management:-
- Systems in the infrastructure are managed through the hosts file, the default path is /etc/ansible/hosts
- Enable password-less SSH Authentication between Ansible server and client host systems
For example, if you have database & web servers you can indicate it in the host’s file as follows
- [database-servers]
- DBtest1.database.com ansible_connection=ssh ansible_user=test1
- DBtest1.database.com ansible_connection=ssh ansible_user=test2
- [webservers]
- webserver1.ws.com ansible_connection=ssh ansible_user=testws1
- webserver2.ws.com ansible_connection=ssh ansible_user=testws2
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:-
- The Default Ansible configuration file is located at “/etc/ansible/ansible.cfg”
- Flexibility to use multiple configuration files depending upon the environment
# 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.
- Host Declaration
- Variable declaration (optional)
- Action/Tasks declaration
For instance, to create a basic apache web server following tasks are needed.
- Install httpd package
- Configure httpd service
- Start and enable httpd service
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