Table of Contents
Was this article helpful?

0  out of  1 found this helpful

Try Vultr Today with

$50 Free on Us!

Want to contribute?

You could earn up to $600 by adding new articles.

Setting Up Ansible for Configuration Management on Ubuntu 14.04: Installing Ansible

Last Updated: Thu, Aug 13, 2015
Server Apps Ubuntu
Archived content

This article is outdated and may not work correctly for current operating systems or software.

Ansible is a configuration management system. Configuration management allows for automatic deployment, configuration, and centralized management of applications. This is handy if you need to deploy your application on multiple servers without the need for having to do this manually on all your servers. You can also add identical servers to your cluster. You could set up a load balancer/cluster/failover with this, for example.

Ansible provides configuration management so you can add identical servers to your cluster very easily. You can also do centralized management for all of your servers in one place. You can run an apt-get update on all servers at once!

Personally, I prefer Ansible because it does the job without having to manually install software on all your servers. It does deployment and management over SSH. SSH is a standard medium for server management, but a disadvantage here is that you need to enable SSH. Some might consider that a security risk, although Ansible works with SSH keys, which are more secure.

In this tutorial we'll see how we can install Ansible on Ubuntu 14.04.

Step 1: Installing Ansible

You can install Ansible with:

apt-get install ansible

You need to put all the servers that you want to manage with Ansible in the /etc/ansible/hosts file.

You will need to comment out all lines. Go to the latest line of the hosts file to create a category. Say you have a cluster of web and database servers. You could create two separate categories: web and db. If you would want to make a change on all database servers, you could use db as selection so only all database servers would be affected and not other servers such as your web servers in the web category.



localhost ansible_ssh_host=

web1 ansible_ssh_host=

web2 ansible_ssh_host=


db1 ansible_ssh_host=

db2 ansible_ssh_host=

db3 ansible_ssh_host=

db4 ansible_ssh_host=

Format: name ansible_ssh_host=ip

Note that if you're using Ansible 2.0, the ssh_ part has been deprecated. Instead use ansible_host.

name is just a name to refer to your server, ip is the actual IP.

This tells Ansible that you have 3 web servers on the IP addresses, and and 4 database servers on the IP addresses

Step 2: Setting up SSH keys

Ansible works with SSH keys. If your SSH key on nodes isn't the same as on your Ansible server, it will give you an error. Therefore, we need to generate an SSH key.


Now add your SSH key to your nodes. If all your nodes are at Vultr, go to the Vultr SSH key manager and add your public key. It can be found here:

cat ~/.ssh/

Then, when deploying your server, choose your SSH key in the "SSH Keys" section.

Step 3: Test Ansible

To see if you can ping all your servers in the hosts file, you can use the following command:

ansible -m ping all

This confirms whether or not your servers are online.

You can also execute a command:

ansible web -m command -a 'shutdown -h now'

We've just executed the command shutdown -h now on all servers in the web category.

At this point, Ansible is setup and ready to go. Seems pretty simple, right? Well, we haven't covered the most powerful feature of Ansible yet: playbooks. Learn more about playbooks in this tutorial.

Want to contribute?

You could earn up to $600 by adding new articles.