jhaals / ansible-vault

ansible lookup plugin for secrets stored in Vault(by HashiCorp)
BSD 3-Clause "New" or "Revised" License
347 stars 65 forks source link

Delay lookups #47

Closed GSrinivasulu27 closed 7 years ago

GSrinivasulu27 commented 7 years ago

Hi,

Thanks for the plugin 👍

we are trying to load all secrets using lookup's, but these lookup's are present global level in group/all/xyz.yml file these is eager loading file, how to delay lookup's in this file ? is there a way or any suggestions

now we facing because of eager loading lookup's

fatal: [127.0.0.1]: FAILED! => {"failed": true, "msg": "{{ my_creds.one_passwd }}: {{ lookup('hashi_vault', 'secret/{{ mysec }}/pswd/one') }}: Vault or GitHub authentication token missing. Specify with vault_token ansible variable or VAULT_TOKEN/VAULT_GITHUB_API_TOKEN environment variable or in $HOME/.vault-token (Current $HOME value is /home/hos)"}

If i remove lookup's from the global level and place into specific environment file then it is working as expected

we are using ansilbe: 2.1.1.0

jhaals commented 7 years ago

I'm glad to hear that you find it useful!

I'm not aware of any "delay" functionality, sounds like a bug/problem in the variable loading in ansible. Does it work if you set VAULT_TOKEN/VAULT_GITHUB_API_TOKEN using environment variables?

GSrinivasulu27 commented 7 years ago

Thanks for response

Yes it is working for environment variables, basically we are using Jenkins jobs to run deployment, so when we run job from Jenkins it is working, if we run from Git using some predefined jobs in Jenkins (Ex: run this please) then it is failing..

jhaals commented 7 years ago

Thanks for the update. I'd argue this is a problem that should be solved in ansible. It's worth checking with them if it's even supported instead of trying to solve/workaround this on the plugin layer.

GSrinivasulu27 commented 7 years ago

ok, Thanks 👍