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
After a good nights sleep and closing all terminal windows it seems to work.
I used auto python discovery in the end.