Variables in lookup statement for vault

"{{ lookup('vault', 'pki/issue/webserver common_name=\"test.example.com\" ip_sans=\"{{ IP_ADDR }}, {{ var=hostvars[inventory_hostname].ansible_ssh_host }}\" format=\"pem\" key_bits=4096').certificate }}"

Hi im trying to use a variable inside a lookup statement which I’m using to query vault

I’m using the following plugin https://github.com/jhaals/ansible-vault

Now i’ve tried it with {{ variable }}, + variable +, var=variable but none of these seem to work and i don’t know the correct format.

Is this possible ?

Regards K

Curly brackets doesn't stack so you can't use {{ }} inside {{ }}
So something like this should work.

{{ lookup('vault', 'pki/issue/webserver common_name=test.example.com ip_sans=' ~ IP_ADDR ~ ' var=' ~ hostvars[inventory_hostname].ansible_ssh_host ~ ' format=pem key_bits=4096').certificate }}"