SUMMARY
On spinning up a network device in the local instance, libssh fails to connect via ssh while running a playbook. Anything other than local works fine.
ISSUE TYPE
PYLISSH and LIBSSH VERSION
ansible-pylibssh==0.3.0
Source : libssh-0.9.6-1.fc35.src.rpm
OS / ENVIRONMENT
STEPS TO REPRODUCE
ansbile.cfg
--------------
[persistent_connection]
ssh_type = libssh
inventory
------------
[iosDevice1]
localhost
[iosDevice1:vars]
ansible_network_os=ios
ansible_user=user
ansible_password=pass
ansible_connection=network_cli
ansible_network_cli_ssh_type=libssh
ansible_become=true
ansible_ssh_port=8022
playbook.yml
--------------
---
- name: Tests libssh
hosts: iosDevice1
gather_facts: no
tasks:
- name: Gathering vlans
cisco.ios.ios_facts:
gather_subset: ['!all', '!min']
gather_network_resources: ['vlans']
EXPECTED RESULTS
Works properly with connection paramiko, same should be with libssh
ACTUAL RESULTS
fails with ssh connection failed: ssh connect failed: Connection refused
TASK [Gathering vlans] **************************************************************************************************************************************************************
task path: /home/machine/Work/Area51/vlan_bug_fact.yml:6
redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon.network_cli
redirecting (type: terminal) ansible.builtin.ios to cisco.ios.ios
redirecting (type: cliconf) ansible.builtin.ios to cisco.ios.ios
<localhost> attempting to start connection
<localhost> using connection plugin ansible.netcommon.network_cli
Found ansible-connection at path /home/machine/MyVnvs/dev38/bin/ansible-connection
<localhost> local domain socket does not exist, starting it
<localhost> control socket path is /home/machine/.ansible/pc/15955bcd40
<localhost> redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon.network_cli
<localhost> Loading collection ansible.netcommon from /home/machine/Work/Area51/collections/ansible_collections/ansible/netcommon
<localhost> redirecting (type: terminal) ansible.builtin.ios to cisco.ios.ios
<localhost> Loading collection cisco.ios from /home/machine/Work/Area51/collections/ansible_collections/cisco/ios
<localhost> redirecting (type: cliconf) ansible.builtin.ios to cisco.ios.ios
<localhost> local domain socket listeners started successfully
<localhost> loaded cliconf plugin ansible_collections.cisco.ios.plugins.cliconf.ios from path /home/machine/Work/Area51/collections/ansible_collections/cisco/ios/plugins/cliconf/ios.py for network_os ios
<localhost> ssh type is set to libssh
<localhost>
<localhost> local domain socket path is /home/machine/.ansible/pc/15955bcd40
redirecting (type: action) cisco.ios.ios_facts to cisco.ios.ios
redirecting (type: action) cisco.ios.ios_facts to cisco.ios.ios
<localhost> ANSIBLE_NETWORK_IMPORT_MODULES: enabled via connection option
<localhost> ANSIBLE_NETWORK_IMPORT_MODULES: found cisco.ios.ios_facts at /home/machine/Work/Area51/collections/ansible_collections/cisco/ios/plugins/modules/ios_facts.py
<localhost> ANSIBLE_NETWORK_IMPORT_MODULES: running cisco.ios.ios_facts
<localhost> ANSIBLE_NETWORK_IMPORT_MODULES: complete
<localhost> ANSIBLE_NETWORK_IMPORT_MODULES: Result: {'failed': True, 'msg': 'ssh connection failed: ssh connect failed: Connection refused', 'exception': ' File "/home/machine/Work/Area51/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/network.py", line 251, in get_capabilities\n capabilities = Connection(module._socket_path).get_capabilities()\n File "/home/machine/MyVnvs/dev38/lib/python3.8/site-packages/ansible/module_utils/connection.py", line 200, in __rpc__\n raise ConnectionError(to_text(msg, errors=\'surrogate_then_replace\'), code=code)\n', 'invocation': {'module_args': {'gather_subset': ['!all', '!min'], 'gather_network_resources': ['vlans'], 'available_network_resources': False, 'provider': None}}, '_ansible_parsed': True}
The full traceback is:
File "/home/machine/Work/Area51/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/network.py", line 251, in get_capabilities
capabilities = Connection(module._socket_path).get_capabilities()
File "/home/machine/MyVnvs/dev38/lib/python3.8/site-packages/ansible/module_utils/connection.py", line 200, in __rpc__
raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)
fatal: [localhost]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"available_network_resources": false,
"gather_network_resources": [
"vlans"
],
"gather_subset": [
"!all",
"!min"
],
"provider": null
}
},
"msg": "ssh connection failed: ssh connect failed: Connection refused"
}
SUMMARY
On spinning up a network device in the local instance, libssh fails to connect via ssh while running a playbook. Anything other than local works fine.
ISSUE TYPE
PYLISSH and LIBSSH VERSION
OS / ENVIRONMENT
STEPS TO REPRODUCE
EXPECTED RESULTS
Works properly with connection paramiko, same should be with libssh
ACTUAL RESULTS
fails with
ssh connection failed: ssh connect failed: Connection refused