cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1681
Views
4
Helpful
19
Replies

Managing Switch with Ansible Via SSH

sleepless swan
Level 1
Level 1

I am trying to manage a Catalyst 2960 switch with Ansible. The ansible controller is installed on a Linux VM. I haven't been able to SSH to the switch from the controller despite the service being enabled on the switch and the controller. 

 

Connection:

- PC connected to switch with an ethernet cable. The port is configured with an IP in the same subnet as the VM. 

Switch configuration

 

version 12.2
no service pad
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname ansible
!
boot-start-marker
boot-end-marker
!
!
username mikko privilege 15 password 0 P@ssw0rd
username pocha privilege 15 secret 5 $1$OgQZ$HheCqdqxYg5az5KEaTrNV.
no aaa new-model
system mtu routing 1500
ip subnet-zero
!
ip domain-name ansible.bh
!
!
!
!
!
!
!
!
spanning-tree mode pvst
spanning-tree extend system-id
!
vlan internal allocation policy ascending
!
ip ssh version 1
!
!
interface FastEthernet0/1
 switchport mode access
!
interface FastEthernet0/2
!
interface FastEthernet0/3
!
interface FastEthernet0/4
!
interface FastEthernet0/5
!
interface FastEthernet0/6
!
interface FastEthernet0/7
!
interface FastEthernet0/8
!
interface FastEthernet0/9
!
interface FastEthernet0/10
!
interface FastEthernet0/11
!
interface FastEthernet0/12
!
interface FastEthernet0/13
!
interface FastEthernet0/14
!
interface FastEthernet0/15
!
interface FastEthernet0/16
!
interface FastEthernet0/17
!
interface FastEthernet0/18
!
interface FastEthernet0/19
!
interface FastEthernet0/20
!
interface FastEthernet0/21
!
interface FastEthernet0/22
!
interface FastEthernet0/23
!
interface FastEthernet0/24
!
interface GigabitEthernet0/1
!
interface GigabitEthernet0/2
!
interface Vlan1
 ip address 192.168.7.17 255.255.255.0
 no ip route-cache
!
ip http server
ip http secure-server
!
control-plane
!
!
line con 0
line vty 0 4
 login local
 transport input ssh
line vty 5 15
 login local
 transport input ssh
!
end

 

Whenever I try to ssh to the switch from the vm, I get a 'no route to host' error. Pinging gives a destination unreachable error.

I've tried to ssh to the switch using Putty, but the connection timed out. 

Is it actually possible to manage the switch using Ansible with the current setup? 

 

19 Replies 19

I added another Bridged adapter with PC attached to F0/1, no luck. 

sleeplessswan_0-1710053465075.png

I also set a static IP on the Linux VM for the other adapter to be in the same subnet, but still unable to ping the switch.

sleeplessswan_1-1710053578909.png

I'm not sure if the adapter type matters because from what I read it wouldn't make any difference in this case.

The PC itself can ping and SSH to the switch just fine, so I'm pretty sure the problem lies somewhere in the VM, just don't know where.

Change the Promiscuous Mode for the Bridged Adapter, Adapter 1, to Allow.

Regards, LG
*** Please Rate All Helpful Responses ***

I tried that, but still unable to ping. 

sleeplessswan_1-1710066160339.png

 

I setup a static IP connection for the ethernet interface on Linux. Before that, the ethernet would just not connect at all

sleeplessswan_2-1710066224199.png

 

sleeplessswan_0-1710066138528.png

 

liviu.gheorghe
Spotlight
Spotlight

It's more than sure a problem related to VirtualBox or it's configuration. I presume that pinging the switch from the PC on which you installed VirtualBox is successful.

I think you would get more info on a Oracle/VirtualBox forum.

Regards, LG
*** Please Rate All Helpful Responses ***

The PC can indeed ping and SSH to the switch.

I shall head over to VB forums then. Thank you so much for the time and effort!