Hi. I have the same problem with Ansible 2.16.2 installed via PIP in venv.
Using the same config/inventory/playbook I have no problems when using
Ansible 2.9.6 installed on Ubuntu 20.04 with Python 3.8
This is my cfg file:
[defaults]
inventory = ./inventory
host_key_checking = False
retry_files_enabled = False
gathering = explicit
action_warnings = False
library =
[persistent_connection]
command_timeout = 200
connect_timeout = 200
connect_retry_timeout = 100
This is my inventory file
[all]
[all:children]
ios
nxos
[all:vars]
ansible_user=alexd
ansible_password=S00perP@ss!
ansible_connection = ansible.netcommon.network_cli
### This is needed for IOS, IOS-XE, NXOS
connect_timeout = 200
command_timeout = 200
#connection = paramiko
[ios]
[ios:children]
routers
switches
[ios:vars]
ansible_network_os=cisco.ios.ios
ansible_become=yes
ansible_become_method=enable
ansible_become_password=Enable
[routers]
R1 ansible_host=192.168.122.10
R2 ansible_host=192.168.122.12
And this is the playbook:
- name: "PLAY 1: Gather Data from network devices"
hosts: R2
connection: paramiko
collections:
- cisco.ios
gather_facts: false
become: true
become_method: enable
tasks:
- name: "TASK 1: IOS >> Show version"
cisco.ios.ios_command:
commands: show version
register: show_version
- name: "TASK 2: debug"
debug:
msg: "{{ show_version }}"
The ansible ping Work perfectly with both routers.
(venv) ubuntu@ubuntu:~/DevAuto/AnsibleTest2$ ansible -m ping routers
[WARNING]: ansible-pylibssh not installed, falling back to paramiko
R2 | SUCCESS => {
"changed": false,
"ping": "pong"
}
R1 | SUCCESS => {
"changed": false,
"ping": "pong"
}
However playbook fails with "Authentication failed" message
(venv) ubuntu@ubuntu:~/DevAuto/AnsibleTest2$ ansible-playbook
get_info_ios.yml
PLAY [PLAY 1: Gather Data from network devices]
**********************************************************************************************************************************************
TASK [TASK 1: IOS >> Show version]
***********************************************************************************************************************************************************
[WARNING]: ansible-pylibssh not installed, falling back to paramiko
fatal: [R2]: FAILED! => {"changed": false, "msg":* "Failed to authenticate:
Authentication failed: transport shut down or saw EOF"}*
PLAY RECAP
***********************************************************************************************************************************************************************************
R2 : ok=0 changed=0 unreachable=0 *failed=1
* skipped=0 rescued=0 ignored=0
Need help!
On Thursday, January 4, 2024 at 4:05:57 PM UTC+1 mohamed mostafa wrote:
> dears,
>
> Kindly help to solve this issue, i have the below error when run ad-hoc
> command "ios_ping "
>
> [mohamedlocalhost proj]$ ansible -m ios_ping 192.168.1.101 -a
> "dest=192.168.1.101"
> SSH password:
> [WARNING]: ansible-pylibssh not installed, falling back to paramiko
> 192.168.1.101 | FAILED! => {
> "changed": false,
> "msg": "Failed to authenticate: Authentication failed: transport shut
> down or saw EOF"
>
> i can use ping module normally please check attachment 1
>
> the ansible can ssh this device .101 , this device is eve-ng cisco L3 IOL
> .when i check the logs and make debug on it i found below
>
> *Dec 25 16:46:01.337: SSH2 0: MAC compared for #5 :ok
> *Dec 25 16:46:01.337: SSH2 0: input: padlength 15 bytes
> *Dec 25 16:46:01.337: SSH2 0: Using method = publickey
> *Dec 25 16:46:01.337: SSH2 0: Received publickey algo = rsa-sha2-512
> *Dec 25 16:46:01.337: SSH2 0: Unsupported public key algorithm
> rsa-sha2-512 in SSH2_MSG_USERAUTH_REQUEST
> *Dec 25 16:46:01.337: SSH0: password authentication failed for root
>
>
> =======================================
>
> [mohamedlocalhost proj]$ ansible -m ios_ping 192.168.1.101 -a
> "dest=192.168.1.101" -vvv
> ansible [core 2.15.7]
> config file = /home/mohamed/RED_Hat_Course/proj/ansible.cfg
> configured module search path =
> ['/home/mohamed/.ansible/plugins/modules',
> '/usr/share/ansible/plugins/modules']
> ansible python module location =
> /home/mohamed/.local/lib/python3.9/site-packages/ansible
> ansible collection location =
> /home/mohamed/.ansible/collections:/usr/share/ansible/collections
> executable location = /home/mohamed/.local/bin/ansible
> python version = 3.9.18 (main, Sep 22 2023, 17:58:34) [GCC 8.5.0
> 20210514 (Red Hat 8.5.0-20)] (/usr/bin/python3.9)
> jinja version = 3.1.2
> libyaml = True
> Using /home/mohamed/RED_Hat_Course/proj/ansible.cfg as config file
> SSH password:
> host_list declined parsing /home/mohamed/RED_Hat_Course/proj/cisco as it
> did not pass its verify_file() method
> script declined parsing /home/mohamed/RED_Hat_Course/proj/cisco as it did
> not pass its verify_file() method
> auto declined parsing /home/mohamed/RED_Hat_Course/proj/cisco as it did
> not pass its verify_file() method
> Parsed /home/mohamed/RED_Hat_Course/proj/cisco inventory source with ini
> plugin
> Skipping callback 'default', as we already have a stdout callback.
> Skipping callback 'minimal', as we already have a stdout callback.
> Skipping callback 'oneline', as we already have a stdout callback.
> [WARNING]: ansible-pylibssh not installed, falling back to paramiko
> redirecting (type: modules) ansible.builtin.ios_ping to cisco.ios.ios_ping
> redirecting (type: action) ansible.builtin.ios to cisco.ios.ios
> redirecting (type: action) ansible.builtin.ios to cisco.ios.ios
> redirecting (type: modules) ansible.builtin.ios_ping to cisco.ios.ios_ping
> The full traceback is:
> File
> "/home/mohamed/.local/lib/python3.9/site-packages/ansible_collections/cisco/ios/plugins/module_utils/network/ios/ios.py",
>
> line 60, in get_capabilities
> capabilities = Connection(module._socket_path).get_capabilities()
> File
> "/home/mohamed/.local/lib/python3.9/site-packages/ansible/module_utils/connection.py",
>
> line 200, in __rpc__
> raise ConnectionError(to_text(msg, errors='surrogate_then_replace'),
> code=code)
> 192.168.1.101 | FAILED! => {
> "changed": false,
> "invocation": {
> "module_args": {
> "afi": "ip",
> "count": null,
> "dest": "192.168.1.101",
> "df_bit": false,
> "egress": null,
> "ingress": null,
> "source": null,
> "state": "present",
> "timeout": null,
> "vrf": null
> }
> },
> "msg": "Failed to authenticate: Authentication failed: transport shut
> down or saw EOF"
>
>
> ============================
> inventory=cisco
> [all]
> 192.168.1.101
> 192.168.1.102
> 192.168.1.103
>
> [usa]
> 192.168.1.101
> 192.168.1.102
>
> [uk]
> 192.168.1.103
>
>
> ansible.cfg
>
> [defaults]
> host_key_checking = False
> inventory = cisco
> ask_pass = true
> gathering = explicit
> interpreter_python = /usr/bin/python
>
> [persistent_connection]
> command_timeout = 200
> connect_timeout = 200
> connect_retry_timeout = 100
>
>
> Group_var
> ansible_connection: ansible.netcommon.network_cli
> ansible_network_os: cisco.ios.ios
> ansible_user: root
> ansible_password: admin
> ansible_vrf: MGMT
>
>
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/0557978f-cd9f-4201-8c07-0dd00f283fb0n%40googlegroups.com.