0

I am using pyenv and venvs and poetry for my ansible setup.

Recently I removed system pip installed files. New thing in Debian 12, you can't install pkgs through pip anymore without forcing them.

I noticed my cisco playbook doesn't activate.

This is my group_vars/switches.yml file for my switches.yml playbook for cisco switches.

---
ansible_connection: ansible.netcommon.network_cli
ansible_network_os: cisco.ios.ios
ansible_network_cli_ssh_type: libssh

After installing everything in my venv using poetry install pkgs install nicely and also does ansible-pylibssh.

When running the playbook switches.yml I get this error:

PLAY [Configuration of switches] **********************************************************************************************************************************************************************************

TASK [Gathering Facts] ********************************************************************************************************************************************************************************************
fatal: [REDACTED]: FAILED! => {"ansible_facts": {}, "changed": false, "failed_modules": {"cisco.ios.ios_facts": {"failed": true, "invocation": {"module_args": {"available_network_resources": false, "gather_network_resources": null, "gather_subset": ["min"]}}, "msg": "Failed to import the required Python library (ansible-pylibssh) on REDACTED'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"}}, "msg": "The following modules failed to execute: cisco.ios.ios_facts\n"}

Even when adding ansible_python_interpreter it tries to use the /usr/bin/python3 instead of which python which points to /root/.pyenv/shims/python

2 Answers 2

0

After a good nights sleep and closing all terminal windows it seems to work.

I used auto python discovery in the end.

Sign up to request clarification or add additional context in comments.

Comments

0

The key to the problem is here:

If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter

In other words, you did not activate the venv which has the ansible module installed before running ansible. Activate the proper venv before running ansible and it will solve the problem... otherwise install the dependency with pip install ansible-pylibssh

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.