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

Add templating support in some inventory field #463

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

Conversation

Gianlu
Copy link
Contributor

@Gianlu Gianlu commented Feb 9, 2024

Hi,
I submit this PR in order to add Jinja templating support in inventory for these fields:

  • hostname
  • username
  • password
  • port

I think that it can be very useful based on my scenarios. You already have the support for environment variables but I have scenarios where I have to query 2 (or more) Prism Central because I have to target distributed applications (I have a PC for site).
In my configuration:

./inventory
├── 00_pc01.nutanix.yaml
├── 00_pc02.nutanix.yaml
└── 99_final.yml

in 00_pc01.nutanix.yaml I have:

plugin: nutanix.ncp.ntnx_prism_vm_inventory
nutanix_hostname: "{{ lookup('ansible.builtin.env', 'PC_1_HOSTNAME') }}"
nutanix_username: "{{ lookup('ansible.builtin.env', 'PC_1_USERNAME') }}"
nutanix_password: "{{ lookup('ansible.builtin.env', 'PC_1_PASSWORD') }}"

When I run

$ ansible-inventory --list -y --output test.yml

I have PCs Inventory merged.

I hope it hepls

bye

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant