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

Clearer error logging in passwordstore lookup #5436

Merged
merged 2 commits into from
Nov 2, 2022

Conversation

jplitza
Copy link
Contributor

@jplitza jplitza commented Oct 28, 2022

(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"
}

@ansibullbot ansibullbot added bug This issue/PR relates to a bug lookup lookup plugin plugins plugin (any type) labels Oct 28, 2022
Copy link
Collaborator

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution! Can you please add a changelog fragment? Thanks.

@felixfontein felixfontein added check-before-release PR will be looked at again shortly before release and merged if possible. backport-5 labels Oct 28, 2022
Copy link
Collaborator

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. If nobody complains, I'm going to merge this in ~a week.

@felixfontein felixfontein removed the check-before-release PR will be looked at again shortly before release and merged if possible. label Nov 2, 2022
@felixfontein felixfontein merged commit e4b9e09 into ansible-collections:main Nov 2, 2022
@patchback
Copy link

patchback bot commented Nov 2, 2022

Backport to stable-5: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-5/e4b9e098c74e405cae911d01d2561e208ff3421c/pr-5436

Backported as #5458

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Nov 2, 2022
* 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)
@felixfontein
Copy link
Collaborator

@jplitza thanks for your contribution!

@github-actions
Copy link

github-actions bot commented Nov 2, 2022

Docs Build 📝

Thank you for contribution!✨

This PR has been merged and your docs changes will be incorporated when they are next published.

felixfontein pushed a commit that referenced this pull request Nov 2, 2022
* 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)

Co-authored-by: Jan-Philipp Litza <[email protected]>
rekup pushed a commit to rekup/community.general that referenced this pull request Nov 3, 2022
* Clearer error logging in passwordstore lookup

* Add changelog fragment for passwordstore errmsgs

Co-authored-by: Sylvia van Os <[email protected]>
russoz pushed a commit to russoz-ansible/community.general that referenced this pull request Nov 5, 2022
* Clearer error logging in passwordstore lookup

* Add changelog fragment for passwordstore errmsgs

Co-authored-by: Sylvia van Os <[email protected]>
bratwurzt pushed a commit to bratwurzt/community.general that referenced this pull request Nov 7, 2022
* Clearer error logging in passwordstore lookup

* Add changelog fragment for passwordstore errmsgs

Co-authored-by: Sylvia van Os <[email protected]>
bratwurzt pushed a commit to bratwurzt/community.general that referenced this pull request Nov 7, 2022
* Clearer error logging in passwordstore lookup

* Add changelog fragment for passwordstore errmsgs

Co-authored-by: Sylvia van Os <[email protected]>
This was referenced Nov 20, 2022
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 plugins plugin (any type)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

passwordstore: Improve error messages
4 participants