You might have heard about Ansible recently, but if you haven’t, we recommend that you have a look at the Ansible official website. To summarize using Ansible’s own description:

“Ansible is a radically simple IT orchestration engine that automates configuration management, application deployment, and many other IT needs”

Abiquo has a native Chef integration (Chef is yet another configuration manager). However, we want to enable our users to work with whichever technology they feel comfortable with, so we’ve contributed to Ansible with the Abiquo dynamic inventory plugin, which makes Abiquo integration with Ansible a piece of cake.

Without going into too much detail, an Ansible inventory is an INI format text file that contains a host catalog needed to execute playbooks (configuration templates) on hosts that are listed in it.
Now, with the Abiquo dynamic inventory plugin for Ansible, a user with access to Abiquo’s API can generate an inventory file that Ansible can use containing the list of all the user’s resources in useful categories.

Let’s see an example of the Abiquo dynamic inventory plugin output:

[code language=”ruby” gutter=”false”] {
"ABQ_0601a901-2845-4b3f-a52b-964c90b33240": [
"192.168.0.11"
],
"ABQ_d7985e52-4551-4b00-a21e-b6d823264e2d": [
"192.168.0.10"
],
"ABQ_deb6b10b-f876-4da5-bb7b-07b4f51c98d4": [
"192.168.0.20"
],
"Amsterdam2": {
"children": [
"ABQ_d7985e52-4551-4b00-a21e-b6d823264e2d",
"ABQ_0601a901-2845-4b3f-a52b-964c90b33240",
"ABQ_deb6b10b-f876-4da5-bb7b-07b4f51c98d4"
],
"hosts": [] },
"Apache_FE1": {
"children": [
"ABQ_d7985e52-4551-4b00-a21e-b6d823264e2d"
],
"hosts": [] },
"Apache_FE2": {
"children": [
"ABQ_0601a901-2845-4b3f-a52b-964c90b33240"
],
"hosts": [] },
"CentOS_6.5_x64": {
"children": [
"ABQ_d7985e52-4551-4b00-a21e-b6d823264e2d",
"ABQ_0601a901-2845-4b3f-a52b-964c90b33240"
],
"hosts": [] },
"DEV_Wordpress": {
"children": [
"ABQ_d7985e52-4551-4b00-a21e-b6d823264e2d",
"ABQ_0601a901-2845-4b3f-a52b-964c90b33240",
"ABQ_deb6b10b-f876-4da5-bb7b-07b4f51c98d4"
],
"hosts": [] },
"MASTER_MariaDB": {
"children": [
"ABQ_deb6b10b-f876-4da5-bb7b-07b4f51c98d4"
],
"hosts": [] },
"Ubuntu_12.04.4_x64": {
"children": [
"ABQ_deb6b10b-f876-4da5-bb7b-07b4f51c98d4"
],
"hosts": [] },
"_meta": {
"hostvars": {}
},
"all": {
"children": [
"ABQ_d7985e52-4551-4b00-a21e-b6d823264e2d",
"ABQ_0601a901-2845-4b3f-a52b-964c90b33240",
"ABQ_deb6b10b-f876-4da5-bb7b-07b4f51c98d4"
],
"hosts": [] }
}
[/code]

The JSON text shown above is a sample inventory file generated by the Abiquo dynamic inventory plugin. You can see that the hosts are helpfully grouped in different categories.
The most basic category is the host definition itself. It’s just the Abiquo virtual machine name and an IP address:

[code language=”ruby” gutter=”false”] { "ABQ_0601a901-2845-4b3f-a52b-964c90b33240": [ "192.168.0.11" ] }
[/code]

You can choose which of the host’s IP addresses to use by indicating a specific network interface or just the first public IP assigned to the virtual machine in the Abiquo dynamic inventory plugin configuration file.

Once a basic host entry has been defined, you have different associations that may be useful for applying playbooks in bulk mode:

  • Description label
  • Datacenter
  • Virtual Appliance
  • Template

The next host group is:

[code language=”ruby” gutter=”false”] {
"CentOS_6.5_x64": {
"children": [
"ABQ_d7985e52-4551-4b00-a21e-b6d823264e2d",
"ABQ_0601a901-2845-4b3f-a52b-964c90b33240"
],
"hosts": []    }
}
[/code]

This group contains all hosts using the CentOS 6.5 x64 template, so, if we want to apply a package to update all hosts which are using this template, we just need to specify that label in our playbook.

In the same way, you can execute a playbook on all hosts deployed in a Virtual Appliance:

[code language=”ruby” gutter=”false”] {
"DEV_Wordpress": {
"children": [
"ABQ_d7985e52-4551-4b00-a21e-b6d823264e2d",
"ABQ_0601a901-2845-4b3f-a52b-964c90b33240",
"ABQ_deb6b10b-f876-4da5-bb7b-07b4f51c98d4"
],
"hosts": [] }
}
[/code]

At this point, you are probably imagining how simple and easy it is to automate tedious and repetitive sysadmin tasks with Abiquo and Ansible.

You can view a simple demo video which shows how to update Apache httpd packages on some virtual machines deployed in Abiquo using the dynamic inventory plugin for Ansible: