Failed to import the required Python library (ansible-pylibssh)
Hi all,
I am clutching at straws and I am hoping to get some help.
I am getting the following error:
module_stderr: Failed to import the required Python library (ansible-pylibssh) on server-ansible's Python /root/snap/semaphore/common/ansible_env/bin/python. Please read the module documentation and install it in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter 7:57:46 PM module_stdout: '' 7:57:46 PM msg: |- 7:57:46 PM MODULE FAILURE 7:57:46 PM See stdout/stderr for the exact error
From what I can see, ansible-pylibssh is installed in the site-package of python3.10 bit not python3.8 which has a a symlink to python which in turns has a symlink to /usr/bin/python3.
Troubleshooting:
- I have tried the method outlined in this post but the issue still persist. https://github.com/semaphoreui/semaphore/issues/852
- I have also tried changing ansible_python_interpreter to point to /usr/bin/python3 but the issue still persist.
I have run out of ideas on what to do. Any help will be greatly appreciated.
IMHO we should deprecate the snap installation method as this leads quite often to issues.
Hi @pingunreachable (and @tboerger),
Did you figure out how to handle this issue? I've got a "standard" package based installation and I am too running into a similar problem. I get:
ModuleNotFoundError: No module named 'azure.mgmt.recoveryservicesbackup.models'
...
"msg": "Failed to import the required Python library (ansible[azure] (azure >= 2.0.0)) on semaphore's Python /usr/bin/python3. Please read the module documentation and install it in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter"
If I run this same playbook from the command line, however, it does work properly. Thus, I feel it's just a problem with Semaphore not inheriting the proper env vars. But, so far I've failed to identify a solution to this.
Any suggestions would be greatly appreciated. Thanks.
@mlanner
Sorry bro, unfortunately I wasn't able to figure out what the issue was. I have tried other different modules (docker) and nothing works despite installing all dependencies.
I have sort of given up troubleshooting. Not worth burning my weekends trying to figure out what's wrong. Will probably be trying out AWX to see how things are.
@pingunreachable
I just figured out one way to solve for it late my afternoon, at least partially. I'll post an update here later.
This is how I solved it (temporarily at least):
In the steps below I'm assuming the user running the playbooks is semaphore. If your setup is different, change to that username instead.
In your inventory (static, static yaml, file), add the following:
127.0.0.1 ansible_user=semaphore
In my case, Semaphore ran the playbook against localhost as root, which I don't think is right.
Then, in the root of the directory in which you're running the playbook(s), create an ansible.cfg file with the following contents:
[defaults]
collections_paths = /home/semaphore/.ansible/collections/ansible_collections/
Of course, check that your collections exist in the above mentioned directory. If they're not there, but somewhere else, just change the patch accordingly.
I hope this helps.