nutanix.ansible
nutanix.ansible copied to clipboard
Hostnames key support in inventory
Hi, I added the support of the "hostnames" key in inventory definition. In the hostname key, you may specify a Jinja2 template that modifies the ansible_hostname. For example, I use this option in order to convert vm name in lower case.
---
plugin: 'nutanix.ncp.ntnx_prism_vm_inventory'
data:
offset: 0
length: 3000
hostnames:
- status.name | lower
With this patch you have to specify the property as returned by Prism Central REST API; perhaps it will be more simple if you use the object you add to ansible inventory but it seems a bit of refactoring is needed.
Hope it helps,
Thanks
@Gianlu Thank you for the contribution. I tried locally and its a good usecase.
@Gevorg-Khachatryan-97 Please can you verify this once :
- Check if we can pick vm inventory object directly instead of rest api response. Instead of "status.name" if we can use "name".
Currently moving it to 1.9.1 -> 1.9.2, as we are near to release.
Thanks.
@Gianlu / @Gevorg-Khachatryan-97 Can you please raise a Github issue with reference docs. Thanks
@Gianlu Can we can add more examples for this ? Inside examples folder.
Thanks
Hi @bhati-pradeep,
I'm sorry for the delay. I pushed a commit where I modify your inventory example with the hostnames
modification.
I hope we can target 1.9.2 release.
Let me know if you want further modifications.