Cisco switch unreachable

50 views
Skip to first unread message

Phil F

unread,
Jul 10, 2017, 11:46:52 AM7/10/17
to Ansible Project
Hi,

I have just installed Ansible for the first time and am attempting to connect to a Cisco switch, this needs to be with username and password.

From both an Ubuntu server and my Mac I can ssh to the box with the same username and password I have configured in the ansible inventory.

I have attempted from an Ubuntu host and my Mac, however I am receiving the following error:

===============================================================

xxxx:/etc/ansible$ ansible -m ping all

xxxx | UNREACHABLE! => {

"changed": false,

"msg": "Failed to connect to the host via ssh: Connection to 192.168.10.200 closed by remote host.\r\nConnection closed\r\n",

"unreachable": true

}

===============================================================

Ansible config:

host1 ansible_host=192.168.10.200 ansible_user=xxxx ansible_ssh_pass=xxxx

Debug from switch shows the succesful authentication and subsequent closing of the connection:

*Jul  8 06:20:52.804: SSH2 1: MAC compared for #8 :ok
*Jul  8 06:20:52.804: SSH2 1: input: padlength 37 bytes
*Jul  8 06:20:52.808: SSH2 1: send:packet of  length 16 (length also includes padlen of 10)
*Jul  8 06:20:52.808: SSH2 1: computed MAC for sequence no.#8 type 52
*Jul  8 06:20:52.808: SSH2 1: authentication successful for ansibleuser
*Jul  8 06:20:52.814: SSH2 1: ssh_receive: 64 bytes received 
*Jul  8 06:20:52.814: SSH2 1: input: total packet length of 48 bytes
*Jul  8 06:20:52.814: SSH2 1: partial packet length(block size)16 bytes,needed 32 bytes,
               maclen 16
*Jul  8 06:20:52.814: SSH2 1: MAC compared for #9 :ok
*Jul  8 06:20:52.814: SSH2 1: input: padlength 19 bytes
*Jul  8 06:20:52.814: SSH2 1: channel open request
*Jul  8 06:20:52.815: SSH2 1: send:packet of  length 32 (length also includes padlen of 10)
*Jul  8 06:20:52.815: SSH2 1: computed MAC for sequence no.#9 type 91
*Jul  8 06:20:52.818: SSH2 1: ssh_receive: 144 bytes received 
*Jul  8 06:20:52.818: SSH2 1: input: total packet length of 48 bytes
*Jul  8 06:20:52.818: SSH2 1: partial packet length(block size)16 bytes,needed 32 bytes,
               maclen 16
*Jul  8 06:20:52.818: SSH2 1: MAC compared for #10 :ok
*Jul  8 06:20:52.818: SSH2 1: input: padlength 7 bytes
*Jul  8 06:20:52.818: SSH2 1: env request
*Jul  8 06:20:52.819: SSH2 1: input: total packet length of 64 bytes
*Jul  8 06:20:52.819: SSH2 1: partial packet length(block size)16 bytes,needed 48 bytes,
               maclen 16
*Jul  8 06:20:52.819: SSH2 1: MAC compared for #11 :ok
*Jul  8 06:20:52.819: SSH2 1: input: padlength 11 bytes
*Jul  8 06:20:52.819: SSH2 1: send:packet of  length 16 (length also includes padlen of 6)
*Jul  8 06:20:52.819: SSH2 1: computed MAC for sequence no.#10 type 99
*Jul  8 06:20:52.819: SSH2 1: exec request
*Jul  8 06:20:52.819: SSH2 1: exec message received
*Jul  8 06:20:52.819: SSH2 1: starting shell for vty
*Jul  8 06:20:52.821: SSH2 1: send:packet of  length 96 (length also includes padlen of 19)
*Jul  8 06:20:52.821: SSH2 1: computed MAC for sequence no.#11 type 94
*Jul  8 06:20:52.926: SSH2 1: send:packet of  length 48 (length also includes padlen of 18)
*Jul  8 06:20:52.926: SSH2 1: computed MAC for sequence no.#12 type 98
*Jul  8 06:20:52.927: SSH2 1: send:packet of  length 16 (length also includes padlen of 6)
*Jul  8 06:20:52.927: SSH2 1: computed MAC for sequence no.#13 type 96
*Jul  8 06:20:52.927: SSH2 1: send:packet of  length 16 (length also includes padlen of 6)
*Jul  8 06:20:52.927: SSH2 1: computed MAC for sequence no.#14 type 97
*Jul  8 06:20:52.927: SSH1: Session terminated normally

Using a playbook:


xxxx:~/ansible/playbooks$ ansible-playbook tst.yml




PLAY [testdevices] ************************************************************************************************************************




TASK [Gathering Facts] ********************************************************************************************************************

fatal: [host1]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Connection closed\r\nConnection to 192.168.10.200 closed by remote host.\r\n", "unreachable": true}

to retry, use: --limit @/home/exinadmin/ansible/playbooks/tst.retry




PLAY RECAP ********************************************************************************************************************************

xxxx       : ok=0 changed=0 unreachable=1 failed=0 

Any help will be greatly appreciated !

Phil.









Kai Stian Olstad

unread,
Jul 10, 2017, 1:59:21 PM7/10/17
to ansible...@googlegroups.com
On 08. juli 2017 13:17, Phil F wrote:
> Hi,
>
> I have just installed Ansible for the first time and am attempting to
> connect to a Cisco switch, this needs to be with username and password.
>
> From both an Ubuntu server and my Mac I can ssh to the box with the same
> username and password I have configured in the ansible inventory.
>
> I have attempted from an Ubuntu host and my Mac, however I am receiving the
> following error:
>
> ===============================================================
>
> xxxx:/etc/ansible$ ansible -m ping all
>
> xxxx | UNREACHABLE! => {
>
> "changed": false,
>
> "msg": "Failed to connect to the host via ssh: Connection to 192.168.10.200
> closed by remote host.\r\nConnection closed\r\n",
>
> "unreachable": true
>
> }

This is one of the more asked and answered question so I just gona give
you a link.

https://groups.google.com/d/msg/ansible-project/KR1DDD4Avr8/o4lw-YpuAgAJ


--
Kai Stian Olstad

Phil F

unread,
Jul 10, 2017, 3:40:43 PM7/10/17
to Ansible Project
Yeah I should have done a search first - thanks, fixed :-)
Reply all
Reply to author
Forward
0 new messages