Skip to content
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

[PR #5436/e4b9e098 backport][stable-5] Clearer error logging in passwordstore lookup #5458

Conversation

patchback[bot]
Copy link

@patchback patchback bot commented Nov 2, 2022

This is a backport of PR #5436 as merged into main (e4b9e09).

(re-creation of ansible/ansible#47120)

SUMMARY

There are many reasons why password store would return exit code 1. Just search for "exit 1" in https://git.zx2c4.com/password-store/tree/src/password-store.sh. This change creates clearer error messages, so one can see what is actually wrong.

Fixes #3759

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

lookup passwordstore

ADDITIONAL INFORMATION

before:

fatal: [testhost-01]: FAILED! => {
    "changed": false,
    "msg": "AnsibleError: An unhandled exception occurred while templating '{{ test_pass }}'. Error was a <class 'ansible.errors.AnsibleError'>, original message: An unhandled exception occurred while templating '{{ lookup(\"passwordstore\", \"{{ test_passwordstore_path }}/test create={{ not ansible_check_mode }}\") }}'. Error was a <class 'ansible.errors.AnsibleError'>, original message: An unhandled exception occurred while running the lookup plugin 'passwordstore'. Error was a <class 'ansible.errors.AnsibleError'>, original message: command ['pass', 'insert', '-f', '-m', u'testpath/test']. returned non-zero exit status 1"
}

after:

fatal: [testhost-01]: FAILED! => {
    "changed": false,
    "msg": "AnsibleError: An unhandled exception occurred while templating '{{ test_pass }}'. Error was a <class 'ansible.errors.AnsibleError'>, original message: An unhandled exception occurred while templating '{{ lookup(\"passwordstore\", \"{{ test_passwordstore_path }}/test create={{ not ansible_check_mode }}\") }}'. Error was a <class 'ansible.errors.AnsibleError'>, original message: An unhandled exception occurred while running the lookup plugin 'passwordstore'. Error was a <class 'ansible.errors.AnsibleError'>, original message: exit code 1 while running ['pass', 'insert', '-f', '-m', u'testpath/test']. Error output: Enter contents of testpath/test and press Ctrl+D when finished:\n\ngpg: ABCDEF0123456789: There is no assurance this key belongs to the named user\ngpg: [stdin]: encryption failed: Unusable public key\nPassword encryption aborted.\n"
}

* Clearer error logging in passwordstore lookup

* Add changelog fragment for passwordstore errmsgs

Co-authored-by: Sylvia van Os <[email protected]>
(cherry picked from commit e4b9e09)
@ansibullbot ansibullbot added backport bug This issue/PR relates to a bug lookup lookup plugin new_contributor Help guide this first time contributor plugins plugin (any type) labels Nov 2, 2022
@felixfontein felixfontein merged commit 1badcff into stable-5 Nov 2, 2022
@felixfontein felixfontein deleted the patchback/backports/stable-5/e4b9e098c74e405cae911d01d2561e208ff3421c/pr-5436 branch November 2, 2022 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug lookup lookup plugin new_contributor Help guide this first time contributor plugins plugin (any type)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants