Introduction

Ansible is an open source automation platform. It is very, very simple to setup and powerful. Ansible can help you with configuration management, application deployment and task automation. It can also do IT orchestration, where you have to run tasks in sequence and create a chain of events which must happen on several different servers or devices.

Unlike Puppet or Chef it doesn’t use an agent on the remote host. Instead Ansible uses SSH which is assumed to be installed on all the systems you want to manage. Also it’s written in Python which needs to be installed on the remote host. This means that you don’t have to setup a client server environment before using Ansible, you can just run it from any of your machines and from the clients point of view there is no knowledge of any Ansible server (you can run Puppet in standalone mode, but Puppet still needs to be installed). There are some other requirements though, for example if you want to do something related to git on a remote machine a git package must first be installed on the remote machine.

Let's get started

Ubuntu

$ sudo apt-get update
$ sudo apt-get install software-properties-common
$ sudo apt-add-repository ppa:ansible/ansible
$ sudo apt-get update
$ sudo apt-get install ansible

Debian

Debian users can leverage the same source as the Ubuntu PPA. Add the following line to /etc/apt/sources.list:

deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main

Then run the following commands:

$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367
$ sudo apt-get update
$ sudo apt-get install ansible

Mac OSX

The preferred way to install ansible on a Mac is via pip, see the pip section below.

Arch Linux

$ pacman -S ansible

Pip

Ansible can be installed via “pip”, the Python package manager. If ‘pip’ isn’t already available in your version of Python, you can get pip by:

$ sudo easy_install pip

Then install Ansible with:

$ sudo pip install ansible

Or if you are looking for the latest development version:

$ sudo pip install git+git://github.com/ansible/ansible.git@devel

note if you're installing on OS X Mavericks, you may encounter some noise from your compiler. A workaround is to do the following:

$ sudo CFLAGS=-Qunused-arguments CPPFLAGS=-Qunused-arguments pip install ansible

Running From Source

Ansible is easy to run from a checkout - root permissions are not required to use it and there is no software to actually install. No daemons or database setup are required.

To install from source, clone the Ansible git repository:

$ git clone git://github.com/ansible/ansible.git --recursive
$ cd ./ansible

Once git has cloned the Ansible repository, setup the Ansible environment:

Using Bash:

$ source ./hacking/env-setup

If you don't have pip installed in your version of Python, install pip:

$ sudo easy_install pip

Now let's test things:

$ ansible --version

You should see the below output, if you did, congratulations.

ansible 2.4.0
config file = /Users/mitchelldavis/Desktop/aws/agent-tools/ansible.cfg
configured module search path = [u'/Users/mitchelldavis/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /Library/Python/2.7/site-packages/ansible
executable location = /usr/local/bin/ansible
python version = 2.7.10 (default, Feb 7 2017, 00:08:15) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)]