Skip to content

Commit

Permalink
lookups: return a more useful error on failure
Browse files Browse the repository at this point in the history
  • Loading branch information
flowerysong committed Jun 10, 2024
1 parent 24e0b94 commit f560b29
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions plugins/plugin_utils/lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,20 @@ def run(self, terms, variables=None, **kwargs):
ret = []

for term in terms:
display.debug('flowerysong.hvault lookup term: {0}'.format(term))
display.debug(f'flowerysong.hvault lookup term: {term}')

try:
secret = self.client.get(term)
except URLError as e:
raise AnsibleError('Unable to fetch secret') from e
raise AnsibleError(f'Unable to fetch secret {term}: {e}"')

display.vvvv('flowerysong.hvault lookup found {0}'.format(secret))
display.vvvv(f'flowerysong.hvault lookup found {secret}')

if secret:
if 'data' in secret and (not self.has_option('raw') or not self.get_option('raw')):
secret = secret['data']
ret.append(secret)
else:
raise AnsibleError('Unable to find secret matching "{0}"'.format(term))
raise AnsibleError(f'Unable to find secret matching "{term}"')

return ret

0 comments on commit f560b29

Please sign in to comment.