# another rework of the nova inventory

**URL:** <https://forum.ansible.com/t/another-rework-of-the-nova-inventory/16552>\
**Category:** Ansible Developer\
**Tags:** ubuntu\
**Created:** [October 19, 2014, 11:57am UTC](https://forum.ansible.com/t/another-rework-of-the-nova-inventory/16552 "2014-10-19T11:57:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tomas\_Karasek](https://avatars.discourse-cdn.com/v4/letter/t/f1d935/32.png) [@Tomas\_Karasek](https://forum.ansible.com/u/Tomas_Karasek)\
**Post date:** [October 19, 2014, 11:57am UTC](https://forum.ansible.com/t/another-rework-of-the-nova-inventory/16552/1 "2014-10-19T11:57:37Z")

</div>

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/8657)  
[https://github.com/ansible/ansible/pull/7444](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

---

<div class="post-metadata">

**Author:** ![Tomas\_Karasek](https://avatars.discourse-cdn.com/v4/letter/t/f1d935/32.png) [@Tomas\_Karasek](https://forum.ansible.com/u/Tomas_Karasek)\
**Post date:** [October 19, 2014, 11:58am UTC](https://forum.ansible.com/t/another-rework-of-the-nova-inventory/16552/2 "2014-10-19T11:58:05Z")

</div>

Link to the pull request:

[https://github.com/ansible/ansible/pull/9378](https://github.com/ansible/ansible/pull/9378)
