-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
missing url key, plugin fails, even with ' | default('') ' #59
Comments
Hi,
|
Ok, so if its the same behaviour, i guess its OK :) thanks for the help! |
while other lookup also have the problem, i just found by accident that not all agree that simply fail is the best option: The File lookup may be logic to fail if the file is missing, but like passwordstore lookup, in vault lookup may be more friendly to have a option to ignore the missing key as they are possibly mode dynamic lookups |
@jhaals please reopen this as this limits a lot the ansible<->vault usage We want to store some private keys in the vault, but if they are missing, ansible would create then and upload to vault. We can not do this because right now, if the key is missing, the ansible will abort, forcing the manual creation of keys Please add the "ok_if_missing" option, so we can test if a value exists in vault, even if File lookup aborts It does not look as a hard change, If we do this and submit a pull request, would you accept it? |
@danielmotaleite sorry for necroposting, but |
Hi
i'm trying to find htpasswd for several users, but not all of then do have a htpasswd access, no entry in vault, so when they do not have, i get:
failed: [nginx-01] (item=user1) => {"failed": true, "msg": "AnsibleError: An unhandled exception occurred while running the lookup plugin 'vault'. Error was a <class 'ansible.errors.AnsibleError'>, original message: Unable to read secret/nginx/live/htpasswd/user1 from vault: HTTP Error 404: Not Found", "user": "user1"}
and stop the file template.
My template have this:
{% for user,pass in ( lookup('vault', 'secret/nginx/'+ env +'/htpasswd/' + office ) | default('') ).iteritems() %} {{ user }}:{{ pass }} {% endfor %}
I would assume that with the
| default('')
, the plugin would continue, but it just failsSo is any way for the
| default('')
to work? if not, maybe adding a extra parameter, or starting the url with+
, to flag that the query can fail silentlyThanks for the help and for the plugin
The text was updated successfully, but these errors were encountered: