Getting Started with Ansible

What is Ansible?

Ansible is Simple IT automation tools that managing your server infrastructure, Including Code Deploys, Handling services on your remote server, Installations and configurations server.

Here are some more key properties of Ansible:

  • Dead simple setup
  • Super fast & parallel by default
  • No server or client daemons; use existing SSHd out of the box
  • No additional software required on client boxes
  • Can be easily run from a checkout, no installation required
  • Modules are idempotent, but you can also easily use shell commands
  • Modules can be written in ANY language capable of returning JSON or key=value text pairs
  • Awesome API for creating very powerful distributed scripts
  • Does not have to run remote steps as root
  • Pluggable transports (SSH is just the default)
  • Source host info & variables from files or external software
  • The easiest config management system to use, ever.

Ansible Installation:

Getting started with ansible , installations steps for CentOS. You can find more details about other OS installation steps on official website.

You need some perquisites before installation ansible on centos

1)    Python 2.6 +

$ yum install python

2)    Additional python libraries

$ yum install python-paramiko
$ yum install PyYAML
$ yum install python-jinja2

I am installing ansible from my user named “roop”. So my current directory path is “/home/roop/”

Create your ansible project directory. for e.g I am using “myansible”

$ makdir myansible
$ cd myansible
$ git clone git://github.com/ansible/ansible.git
$ ./ansible/hacking/env-setup

It will setup ansible env . You will get output as below

Setting up Ansible to run out of checkout...

PATH=/home/ /roop/myansible/ansible/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/roop/bin
PYTHONPATH=/home/roop/myansible/ansible/lib:
ANSIBLE_LIBRARY=/home/roop/myansible/ansible/library:/usr/share/ansible/
MANPATH=/home/roop/myansible/ansible/docs/man:
Remember, you may wish to specify your host file with -i

Done!

So to setup ansible you need to run ./ansible/hacking/env-setup from your ansible directory (e.g myansible).

To avoid loss of env variable after session end please add below inside .bashrc . In my case as I am doing this roop user so I need to add in /home/roop/.bashrc

if [ -f ~/../home/roop/myansible/ansible/hacking/env-setup ]; then
source ~/../home/roop/myansible/ansible/hacking/env-setup -q
fi

Now write servers name in hosts file which you want to manage through ansible

You can write single hosts name or group of host name in host file like below

/etc/ansible/hosts

192.168.0.1

Or group multiple server with name

/etc/ansible/hosts

[webserver]
192.168.0.1
192.168.0.2
192.168.0.3

Now check your ansible is up or not

$ ansible all –m ping

Reference:-

http://server.dzone.com/articles/ansible-cm-deployment-and-ad
http://www.ansible.com/how-ansible-works

(Visited 52 times, 1 visits today)