Ansible is a free software platform for configuring and managing computers. It combines multi-node software deployment, ad hoc task execution, and configuration management.It manages nodes over SSH or PowerShell and requires Python (2.4 or later)  to be installed on them. Modules work over JSON and standard output and can be written in any programming language. The system uses YAML to express reusable descriptions of systems. Ansible is a radically simple IT automation platform that makes your applications and systems easier to deploy by avoiding writing scripts or custom code to deploy and update your applications. You automate in a language that approaches plain English, using SSH, with no agents to install on remote systems.

It is one of the well know deployment configuration tools besides Chef, Puppet, SaltStack, Docker, or something else.  It supports one of the goals of DevOPS that is; Increased usage of data center automation and configuration management tools.  As DevOPS, being able to perform deployments with ease is a plus. Developers always want to have an argument about which of these configuration tools is the best. Such discussions reminds me of the discussions that we always have about which software language is the best. My answer is always  all these tools are good depending on your situation and what you want to achieve.

Ansible is simple to use since the language is not complex, allows management of cloud instances instantly without any modification, and being exceptionally good for usual IT stuff (config+apps+zero downtime rolling updates+hotfixes, etc) as opposed to being configuration management specific, where you might have to strap a tool like Fabric and Capistrano on top. It is also very secure since it uses openSSH. Scripting for Chef and Puppet not an easy task and it is considered a programmer’s job and it is not that easy  whereas, Ansible and SaltStack use yaml configurations.

How to use ansible on localhost

You might need to do this at times especially when the machine is a developer machine.

Please follow this guide to install ansible using other means but in this tutorial we shall install ansible via apt. Ansible is available via PPA so let us install it via PPA

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

Next install Openssh server and openssh client. Most linux servers have the client installed by default.

$ sudo apt-get install openssh-client
$ sudo apt-get install openssh-server

Once install generate an SSH key by following the instructions

$ mkdir ~/.ssh
$ sudo chmod 700 ~/.ssh
$ ssh-keygen -t rsa

This is the most interesting part, since you are accessing the same machine that is both a client and a server. You will need the localhost / 127.0.0.1 to get authorized. Punch in this. Remember to replace [user] with your correct details.

$ ssh-copy-id [user]@127.0.0.1

Once this is successful then you are ready to use ansible to configure localhost. For starters add the localhost information to any group you need to configure.

$ sudo vi /etc/ansible/hosts

When installing any playbook, remember to append the the user performing the action for example

$ ansible-playbook site.yml -u mistaguy

.

 

 

 

LEAVE A REPLY

Please enter your comment!
Please enter your name here