Hi,
Is there a way to assign the value of a lookup (in this case a password) to a variable and register it so that the registered variable can then be used in different tasks of play without having to call the lookup itself multiple times?
The closest I have got is using the debug module where I thought I could maybe register the msg. It is not working though as register is not a valid option for debug I think.
- debug:
msg: “{{ lookup(‘vault’,vaultLookupString) }}”
Ideally I would like a named task like below but this does not work.
-
name: Obtain password
PASSWROD= “{{ lookup(‘vault’,vaultLookupString) }}”
register: PASSWORD -
name: Use registered PASSWORD from previous task to do stuff
copy:
dest:
content:
DB_USER=dbuser
DB_PASSWORD= PASSWORD -
name: Use registered PASSWORD again to do more stuff
…
Currently I am having to do this which I want to avoid as more tasks rely on the password.
- name: Use registered PASSWORD from previous task to do stuff
copy:
dest:
content:
DB_USER=dbuser
DB_PASSWORD= “{{ lookup(‘vault’,vaultLookupString) }}”
Any help much appreciated.