Ansible : An Automation Engine
Posted: Mon May 15, 2017 12:16 pm
Ansible is an open source automation engine. With ansible it is possible to perform application deployment, intra service orchestration, cloud provisioning and more over it is a configuration management tool. Ansible is acquired by Redhat and is included as a part of fedora and is also available for redhat enterprise Linux as well as for other operating systems
Ansible is super easy to setup and it just requires to install a package ansible in the controlling machine. The users can setup the ansible inventory where the nodes to be managed are listed. Ansible defines a property called playbooks which works as scripts, it is pushed to one or every nodes and executed. Playbooks are written in yaml script and the connections are by default made through ssh. Ansible comes loaded with a library of modules which can be executed directly or through playbooks and if needed the users can define one of their own. Ansible also provides plugins and api's which could be handy when put to the production environment. The major factor that makes ansible different from any of its kind is its agentless architecture. The agentless architecture requires no programs to be installed and no background daemons to run in the nodes to make connection with the control machine.
Ansible installation on Redhat Enterprise Linux 7
sudo rpm -i epel-release-latest-7.noarch.rpm
After installing EPEL, you need to update your package list.
sudo yum update
And that’s it! Now install Ansible
sudo yum install ansible
To ping your Ansible server on localhost. You should receive a “pong” in response.
ansible localhost -m ping
Ansible’s inventory file defaults to the location /etc/ansible/hosts
The format for /etc/ansible/hosts looks like this:
mail.example.com
[webservers]
froo.example.com
bar.example.com
[dbservers]
one.example.com
two.example.com
three.example.com
The headings in brackets are group names, which are used in classifying systems and deciding what systems you are controlling at what times and for what purpose.
Ansible playbook example:
---
-hosts: webservers
tasks:
- name: Installs nginx web server
yum: pkg=nginx state=installed update_cache=true
notify:
- start nginx
- name: Upload default index.html for node
copy: src=static_files/index.html dest=/usr/share/nginx/www/ mode=0644
handlers:
- name: start nginx
service: name=nginx state=started
• /etc/ansible — The main configuration folder
• /etc/ansible/hosts — This file holds information for the hosts/and host groups you will configure
• /etc/ansible/ansible.cfg — The main configuration file for Ansible
• /etc/ansible/roles — This folder allows you to create folders for each server role.
Ansible is super easy to setup and it just requires to install a package ansible in the controlling machine. The users can setup the ansible inventory where the nodes to be managed are listed. Ansible defines a property called playbooks which works as scripts, it is pushed to one or every nodes and executed. Playbooks are written in yaml script and the connections are by default made through ssh. Ansible comes loaded with a library of modules which can be executed directly or through playbooks and if needed the users can define one of their own. Ansible also provides plugins and api's which could be handy when put to the production environment. The major factor that makes ansible different from any of its kind is its agentless architecture. The agentless architecture requires no programs to be installed and no background daemons to run in the nodes to make connection with the control machine.
Ansible installation on Redhat Enterprise Linux 7
sudo rpm -i epel-release-latest-7.noarch.rpm
After installing EPEL, you need to update your package list.
sudo yum update
And that’s it! Now install Ansible
sudo yum install ansible
To ping your Ansible server on localhost. You should receive a “pong” in response.
ansible localhost -m ping
Ansible’s inventory file defaults to the location /etc/ansible/hosts
The format for /etc/ansible/hosts looks like this:
mail.example.com
[webservers]
froo.example.com
bar.example.com
[dbservers]
one.example.com
two.example.com
three.example.com
The headings in brackets are group names, which are used in classifying systems and deciding what systems you are controlling at what times and for what purpose.
Ansible playbook example:
---
-hosts: webservers
tasks:
- name: Installs nginx web server
yum: pkg=nginx state=installed update_cache=true
notify:
- start nginx
- name: Upload default index.html for node
copy: src=static_files/index.html dest=/usr/share/nginx/www/ mode=0644
handlers:
- name: start nginx
service: name=nginx state=started
• /etc/ansible — The main configuration folder
• /etc/ansible/hosts — This file holds information for the hosts/and host groups you will configure
• /etc/ansible/ansible.cfg — The main configuration file for Ansible
• /etc/ansible/roles — This folder allows you to create folders for each server role.