[openstack-dev] Ansible inventory - Would you need another inventory system for your openstack cloud and how would you like it to be?

Monty Taylor mordred at inaugust.com
Thu May 12 18:58:30 UTC 2016


On 05/12/2016 12:25 PM, Sean M. Collins wrote:
> Monty Taylor wrote:
>> On 05/09/2016 09:27 AM, Jean-Philippe Evrard wrote:
>>> Hello everyone,
>>>
>>> I am using ansible for some time now, and I think the current default
>>> Ansible inventory system is lacking a few features, at least when
>>> working on an OpenStack cloud - whether it's for its deployment, its
>>> support or its usage.
>>> I'm thinking of developing a new inventory, based on (openstack-)ansible
>>> experience.
>>
>> Before we talk about making a new OpenStack Inventory for ansible, let's
>> work on fixing the existing one. We just replaced the nova.py dynamic
>> inventory plugin in the last year with the new openstack.py system.
> 
> Interesting - I'd like to know more. A quick find / grip didn't help me
> find anything, can you help?

Absolutely!


https://github.com/ansible/ansible/blob/devel/contrib/inventory/openstack.py

Is the OpenStack dynamic inventory itself. If you copy that file to
somewhere, make it executable, and point to it as your inventory, it
will behave as an inventory for all of the clouds and regions of those
clouds you have defined in your clouds.yaml file.

There are a few additional clouds.yaml settings you might want to add:

ansible:
  use_hostnames: True
cache:
  expiration_time: 86400
  path: /var/cache/ansible-inventory

the use_hostnames: True is an option you always want, but is not default
behavior because setting it as the default would be a behavior change
and we try VERY hard not to change behavior. It lists your hosts in the
inventory by name, rather than by UUID

The cache lines have it cache your inventory so that it's not doing the
actual list_servers() call every time you ansible.

It's worth noting that all of the information that nova provides - and
some additional information that shade digs out of things - is attached
to each server as an ansible dict variable called "openstack"

It will also great a lot of groups for you, based on nova metadata
values "group" and "groups" as well as ones for cloud, region, az, image
and flavor.

If you run the script by hand like this:

openstack.py --list

It'll spit the inventory info to stdout so that you can look at it.

There is an exceptional doc from Catalyst:

http://docs.catalystcloud.io/tutorials/ansible-openstack-dynamic-inventory.html

Most of the real work for the inventory is actually done in the shade
library - so fleshing out things for it can be done in gerrit should you
find things that would make your life better.



More information about the OpenStack-dev mailing list