'ansible dynamic inventory and hashi corp plugin

How I can use the dynamic inventory plugin for vmware and password from hashi corp plugin?

Structure:

inventory/
├── vmware.vmware.yaml
└── group_vars/
    └── all.yaml

vmware.vmware.yaml

plugin: community.vmware.vmware_vm_inventory
strict: False
hostname: XXXXXXXX
username: "{{ username_esxi }}
password: "{{ password_esxi }}"
validate_certs: False
with_tags: True

all.yaml

username_esxi:  "{{ lookup('community.hashi_vault.hashi_vault', 'secret=secret/hello:username token=c975b780-d1be-8016-866b-01d0f9b688a5 url=http://myvault:8200') }}"
password_esxi:  "{{ lookup('community.hashi_vault.hashi_vault', 'secret=secret/hello:password token=c975b780-d1be-8016-866b-01d0f9b688a5 url=http://myvault:8200') }}"

But, as I see in a console, vmware inventory plugin does not see this variables and try use them as words "{{ username_esxi }}".



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source