Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

Abiquo has created a dynamic inventory plugin for Ansible. What is Ansible? 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”

The dynamic inventory plugin makes it easy for Abiquo users to automate VM configuration with Ansible. Users with access to Abiquo's API can use it to generate an Ansible inventory file of their resources.

An Ansible inventory file is an INI format text file that contains a host catalog. The host catalog lists the hosts on which you can execute Ansible playbooks (configuration templates).

Here is an example of the inventory file. As you can see, the format is JSON and the host data is grouped in categories.

{
 "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": []
 }
}

The most basic category is the host definition itself. It’s just the Abiquo virtual machine name and an IP address:

{ "ABQ_0601a901-2845-4b3f-a52b-964c90b33240": [ "192.168.0.11" ] }

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:

{
	"CentOS_6.5_x64": {
		"children": [
			"ABQ_d7985e52-4551-4b00-a21e-b6d823264e2d",
			"ABQ_0601a901-2845-4b3f-a52b-964c90b33240"
		],
		"hosts": []
	}
}

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, which are defined as the children:

{
	"DEV_Wordpress": {
		"children": [
			"ABQ_d7985e52-4551-4b00-a21e-b6d823264e2d",
			"ABQ_0601a901-2845-4b3f-a52b-964c90b33240",
			"ABQ_deb6b10b-f876-4da5-bb7b-07b4f51c98d4"
		],
		"hosts": []
	}
}

For a video demonstration, please see http://www.abiquo.com/2014/05/14/abiquo-dynamic-inventory-plugin-for-ansible/

  • No labels