I’ve tried a few connections:

It seems that ansible_user is not honoured with the network_cli plugin so make 
sure you’re not using that still:

$ ansible cisco -m ios_command -a "commands='sh ip int br'" -e 
'ansible_connection=network_cli' -e 'ansible_network_os=ios' -e 
'ansible_user=ansible' -k
SSH password:
rtr1 | FAILED! => {
    "changed": false,
    "msg": "Failed to authenticate: Authentication failed."
}

Both remote_user and -u username work for me:

$ ansible cisco -m ios_command -a "commands='sh ip int br'" -e 
'ansible_connection=network_cli' -e 'ansible_network_os=ios' -u ansible -k
SSH password:
rtr1 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "stdout": [
        "Interface              IP-Address      OK? Method Status               
 Protocol\nGigabitEthernet1       172.16.253.234  YES DHCP   up                 
   up      \nLoopback0              192.168.1.1     YES manual up               
     up      \nTunnel0                10.100.100.1    YES manual up             
       up      \nTunnel1                10.200.200.1    YES manual up           
         up      \nVirtualPortGroup0      192.168.35.101  YES TFTP   up         
           up"
    ],
    "stdout_lines": [
        [
            "Interface              IP-Address      OK? Method Status           
     Protocol",
            "GigabitEthernet1       172.16.253.234  YES DHCP   up               
     up      ",
            "Loopback0              192.168.1.1     YES manual up               
     up      ",
            "Tunnel0                10.100.100.1    YES manual up               
     up      ",
            "Tunnel1                10.200.200.1    YES manual up               
     up      ",
            "VirtualPortGroup0      192.168.35.101  YES TFTP   up               
     up"
        ]
    ]
}


$ ansible cisco -m ios_command -a "commands='sh ip int br'" -e 
'ansible_connection=network_cli' -e 'ansible_network_os=ios' -e 
'remote_user=ansible' -k
SSH password:
[WARNING]: Found variable using reserved name: remote_user

rtr1 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "stdout": [
        "Interface              IP-Address      OK? Method Status               
 Protocol\nGigabitEthernet1       172.16.253.234  YES DHCP   up                 
   up      \nLoopback0              192.168.1.1     YES manual up               
     up      \nTunnel0                10.100.100.1    YES manual up             
       up      \nTunnel1                10.200.200.1    YES manual up           
         up      \nVirtualPortGroup0      192.168.35.101  YES TFTP   up         
           up"
    ],
    "stdout_lines": [
        [
            "Interface              IP-Address      OK? Method Status           
     Protocol",
            "GigabitEthernet1       172.16.253.234  YES DHCP   up               
     up      ",
            "Loopback0              192.168.1.1     YES manual up               
     up      ",
            "Tunnel0                10.100.100.1    YES manual up               
     up      ",
            "Tunnel1                10.200.200.1    YES manual up               
     up      ",
            "VirtualPortGroup0      192.168.35.101  YES TFTP   up               
     up"
        ]
    ]
}

Note that I had to remove/disable the valid SSH keys in the router, as the 
first auth method is publckey. Until I did this I could still connect.


I think you’re hitting this bug: 
https://github.com/ansible/ansible/issues/59381 
<https://github.com/ansible/ansible/issues/59381> which refers to 
https://github.com/paramiko/paramiko/issues/1390 
<https://github.com/paramiko/paramiko/issues/1390>




> On 21 Jan 2020, at 13:53, Yehuda Pinhas <[email protected]> wrote:
> 
> Hi!
> 
> To simplify stuff I am troubleshooting this problem with the command below:
> ansible -m ios_command -e commands='sh ip int br' -i /etc/ansible/inventory/ 
> R-TEST-SNIF -e 'ansible_connection=network_cli' -e 'ansible_network_os=ios' 
> -u ansible -k
> It will make it easier to troubleshoot this problem without messing around 
> with multiple files and folders.
> 
>   - It runs the ios_command module on the host R-TEST-SNIF that is located on 
> the inventory folder. -e is extra_vars and those are ansible_connection & 
> ansible_network_os.
> -u for username = ansible, -k for prompting SSH Password.
> 
> Result is the same - No Existing Sessions.
> Below im attaching proof that ping works and SSH by cli is working to the 
> remote router and the ansible does not.
> 
> <Capture.PNG>
> 
> 
> 
> 
> Suggestions?
> 
> -- 
> You received this message because you are subscribed to a topic in the Google 
> Groups "Ansible Project" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/ansible-project/VeJcHLrMyQc/unsubscribe 
> <https://groups.google.com/d/topic/ansible-project/VeJcHLrMyQc/unsubscribe>.
> To unsubscribe from this group and all its topics, send an email to 
> [email protected] 
> <mailto:[email protected]>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/9320b24b-6542-4de2-9077-561a4092b33d%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/ansible-project/9320b24b-6542-4de2-9077-561a4092b33d%40googlegroups.com?utm_medium=email&utm_source=footer>.
> <Capture.PNG>

-- 
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/83FB24B1-59A2-4A79-97C2-CDC2682756D3%40gmail.com.

Reply via email to