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

community.general.keyring import keyring FAILED! #1

Open
docdyhr opened this issue Apr 19, 2021 · 7 comments
Open

community.general.keyring import keyring FAILED! #1

docdyhr opened this issue Apr 19, 2021 · 7 comments

Comments

@docdyhr
Copy link
Owner

docdyhr commented Apr 19, 2021

fatal: [localhost]: FAILED! => {"msg": "An unhandled exception occurred while running the lookup plugin 'community.general.keyring'. Error was a <class 'ansible.errors.AnsibleError'>, original message: Can't LOOKUP(keyring): missing required python library 'keyring'"}

Even when keyring is correctly installed ansible cannot reference the python keyring library with 'import keyring' from inside community.general.keyring. It seems that ansible has problems with python libraries installed outside of the ansible context.

@docdyhr
Copy link
Owner Author

docdyhr commented Apr 19, 2021

Could it be an issue with python paths / different versions of python installed on macOS?

@docdyhr
Copy link
Owner Author

docdyhr commented Apr 19, 2021

Do 'python3' and 'sudo python3' call the same python 3 packages?

@docdyhr
Copy link
Owner Author

docdyhr commented Apr 20, 2021

Tested community.general.keyring on a pure linux setup and it worked like a charm! So it's a macOS / python /
ansible issue then!

docdyhr added a commit that referenced this issue Apr 20, 2021
@docdyhr
Copy link
Owner Author

docdyhr commented Apr 20, 2021

When testet on another mac - it worked too!

@docdyhr
Copy link
Owner Author

docdyhr commented Apr 20, 2021

Installed python3 from python.org on top of the brew version the python.org on macOS on the Mac with problems and it some how worked. Added export PATH="/Library/Frameworks/Python.framework/Versions/3.9/bin:${PATH}" to my zsh profile. But I am still not entirely sure why macOS needs the python3 version from python.org in order to work properly with import statements from python libs in ansible.

@sargunv
Copy link

sargunv commented Jul 21, 2022

I ran into this issue and sort of got past it by adding the following to my playbook before I use keyring:

- ansible.builtin.pip:
    executable: /opt/homebrew/opt/ansible/libexec/bin/pip3
    name: keyring
    state: latest

However now I get this error when I'm trying to use it in ansible:

CleanShot 2022-07-20 at 19 07 00@2x

This is how I'm invoking it:

- ansible.builtin.set_fact:
    example_pw: "{{ pw_input or lookup('keyring', 'example user') }}"

@sargunv
Copy link

sargunv commented Jul 21, 2022

Invoking the keyring CLI manually works fine:

/opt/homebrew/opt/ansible/libexec/bin/keyring get example user

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants