OpenStack Dynamic Inventory

Hi All,
I am trying to use the nova.py script provided as a jumping off point for using OpenStack as a dynamic inventory repository.I am experiencing a problem where the script does not work if I use the hostname (claims there is no host by that name). It works fine if I use the IP address. In fact, if I modify the nova.py script to return the JSON associated with a particular hostname, Ansible still claims that “No hosts matched”.

I guess I don’t understand what Ansible is using in the JSON to key on for the hostname. I am using version 1.3.3.

At least looking at the EC2 example, I see a hostname specified:

ansible -i ec2.py -u ubuntu us-east-1d -m ping

This looks like its logging in as the user ubuntu to the host us-east-1d. I am looking for the same behavior in an OpenStack environment.

Albion

So what you select for the host pattern will need to match what comes back from the inventory script

do ./ec2.py --list to see what names come back

you can also just reference host by groups

Hi Michael,
Thanks, this sheds some light on it (and works as you indicated).

So what is going on under the hood? Is Ansible just calling the nova.py script with –list to get the groups and hostname(s)? Is the –host just for the user or is that called for other functions?

Thanks, this is very helpful.
Albion

–host is called to get variables for the host if and only if the inventory script is not optimized to return things all in one call.

More details that should be helpful are listed here:

http://ansibleworks.com/docs/intro_dynamic_inventory.html

and regarding that specifically:

http://ansibleworks.com/docs/developing_inventory.html

Hi Michael.

I modified the nova.py script since it turns out it was setup to key on the host IP address (public or private). My version resolves by hostname using the instance “name” attribute.

Thanks again.
Albion