another rework of the nova inventory

Hello,

I opened a pull request with rework of the OpenStack Nova inventory script. I did it because I wasn’t happy with the current state of the inventory, and also wasn’t happy with the two pull requests I saw open:
https://github.com/ansible/ansible/pull/8657
https://github.com/ansible/ansible/pull/7444

I think mine is taking the good from both of those and adding a bit more.

What I implemented in the nova inventory:

  • you can refer to instances by their nova name in ansible{-playbook} calls
  • you can refer to single tenants, regions and openstack environments in ansible{-playbook} calls
  • you can refer to a hostgroup when you pass the arbitrary --meta group= in “nova boot” [1]
  • it caches the state of the cloud => consequent calls are fast; you can build cache from cron
  • it tries to guess ansible_ssh_user based on name of image (‘\cubuntu’ → ‘ubuntu’, ‘\ccentos’ → ‘cloud-user’, …)
  • allows to access machines by their private ip [1]
  • it will work with no additional configuration, just handling single tenant from set OS_* environment variables (just like python-novaclient).
  • you can choose to heavy-configure it for multiple environments
  • it’s configured from simple YAML (I dislike ConfigParser). See nova.yml in the diff

[1] I took few ideas and some code from the other two pull reqeusts. I mentioned the authors in the code and in my pull request, I hope it’s enough credit given.

Later I will probably holler in the two former pull requests and in the threads regarding nova inventory in here.

Please comment!

Cheers,
Tomas

Link to the pull request:

https://github.com/ansible/ansible/pull/9378