Variables in lookup statement for vault

17 views
Skip to first unread message

K S-Dean

unread,
Mar 5, 2018, 12:47:09 PM3/5/18
to Ansible Project
"{{ 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 

Kai Stian Olstad

unread,
Mar 6, 2018, 1:19:48 PM3/6/18
to ansible...@googlegroups.com
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 }}"


--
Kai Stian Olstad
Reply all
Reply to author
Forward
0 new messages