C2B2 logo icon

Automation with Ansible

Fresh from Ansible Fest that was held last week at the O2 in London, Red Hat's James Allen joined us at Skills Matter to talk about Ansible, and demonstrate how it can used for automation.

Principal Consultant, JBoss middleware specialist, and User Group host, Brian Randell, reflects on a fascinating DevOps focused meet-up with guest speaker, Red Hat's James Allen. 

It was good to be back at Skills Matter for June's JBUG meet-up, and great to welcome first-time JBUG speaker, James Allen. Starting with a short introduction on Red Hat and how they position themselves in the world of Open Source, James soon got stuck into telling us all about what Ansible can do! Here are my notes (excuse the brevity it places!) from the evening - and for anyone who couldn't join us, we're hopeful that James will be soon be able to share his presentation with us. 

Simple, powerful, and agentless

An example of Ansible's simplicity is that it uses YAML (yet another markup language) as its format for the Playbooks (for the uninitiated, a playbook being the instructions for the task that you want to perform). The beauty of using YAML is that not only is it common, but also simple to understand!

The power of Ansible comes in its use of Modules, the development of which are driven by vendors and the community. Modules are the pieces of code that actually get executed as part of a task instruction in a Playbook and can be written in virtually any language. There are thousands of these Modules in Ansible Galaxy, which is the community of modules or roles. Ansible Core has a number of modules that have been tried and tested from those in Ansible Galaxy.

Ansible is also agentless. So you don’t need to install and maintain an agent on each server in order to use it. Ansible will connect to a server, take everything it needs with it, run the playbook activities, and then remove itself.

With this in mind, you can start to see why Ansible downloads are currently running at about 1,000,000 a month, why there are over 80,000 subscribers to Ansible Galaxy, and how they come to be in the top 10 of developer communities!

How to use Ansible

James explained that Ansible can be used in two ways:

  • You can install Ansible using the free download and get started straight away.
  • Alternatively you can buy a subscription for Ansible Tower - which is used as a central server for your projects, jobs, security credentials, workflows and inventory.

The general thought here is that for small closely knit teams you can probably stick with the free version. If the estate is large and/or there are either many users or users who are spread apart from each other, then it's wise to use Ansible Tower. Ansible Tower will provide you an audit trail, and offer full control over what jobs are being run and when.

Other nice features I picked out include...

  • Inventories can be dynamically discovered. For example you can link Ansible up to vCenter to find all your virtual machines you are using there dynamically.
  • Workflows are a nice feature too where you can link playbooks together and take different actions dependent on a successful or failing run.
  • Surveys can also be added so that when you start a job you can be prompted for variables that can be dynamically input into that job.
  • Jobs can be scheduled so they can run when you want on what servers you want them to run on.

As a rule of thumb, Ansible Tower can support 200 concurrent jobs for each 4GB and 4 CPU on a server, and you can cluster Towers together to share the load.

Next, the Demo

As you can imagine, with such an introduction we couldn’t wait to see what Ansible could do.

James showed us Ansible Tower in operation, talking through some playbooks so we could see and start to understand the YAML required. He then ran a job that created a new server in AWS - which seemed a very simple and straightforward process.

James then showed us how, on that server (which was dynamically found by the inventory as it was connected to the AWS service so he didn’t need to add it in manually), he could use another playbook to install JBoss EAP (with associated dependencies, such as java), start it running and deploy an application onto it.

All this took no longer than a few minutes at most - a very impressive demonstration of the power of Ansible.

The talk ended with a lengthy Q & A session where everyone had questions and comments about what we had been shown - which is always a great sign of an evening well spent! James was an excellent, enthusiastic and very knowledgeable speaker, and we are grateful he could come and talk with us.

As ever, c2b2 kindly provided the pizzas and beers that followed, which nicely rounded off a very enjoyable evening!

Links and Resources