Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hostnames key support in inventory #399

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Gianlu
Copy link
Contributor

@Gianlu Gianlu commented Sep 23, 2023

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

@bhati-pradeep bhati-pradeep added the 1.9.1 Bug fixes & Improvements label Sep 28, 2023
@bhati-pradeep bhati-pradeep added 1.9.3_triage Bug fixes & Improvements and removed 1.9.1 Bug fixes & Improvements labels Oct 30, 2023
@bhati-pradeep
Copy link
Collaborator

bhati-pradeep commented Oct 30, 2023

@Gianlu Thank you for the contribution. I tried locally and its a good usecase.

@Gevorg-Khachatryan-97 Please can you verify this once :

  1. 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.

@bhati-pradeep
Copy link
Collaborator

@Gianlu / @Gevorg-Khachatryan-97 Can you please raise a Github issue with reference docs. Thanks

@bhati-pradeep
Copy link
Collaborator

@Gianlu Can we can add more examples for this ? Inside examples folder.

Thanks

@Gianlu
Copy link
Contributor Author

Gianlu commented Feb 8, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.9.3_triage Bug fixes & Improvements
Projects
Development

Successfully merging this pull request may close these issues.

2 participants