switch-b1: replace with model linksys-srw2048

This commit is contained in:
Astro 2021-09-13 22:33:07 +02:00
parent c98323c5a9
commit b4989028c6
2 changed files with 164 additions and 63 deletions

View File

@ -1,22 +1,19 @@
#!yaml|gpg #!yaml|gpg
switches: switches:
switch-b1: switch-b1:
model: '3com-4200G' model: 'linksys-srw2048'
location: Haus B Souterrain location: Haus B Souterrain
# Ports 1-24 oben # Ports 1-24 oben
# Ports 25-48 unten # Ports 25-48 unten
# Ports 49-52 unten seitlich (optisch)
# 10GE hinten
ports: ports:
switch-b2: switch-b2:
mode: bond mode: bond
group: 3 group: 3
ports: ports:
- TenGigabitEthernet 1/1/1 - g25
- GigabitEthernet 1/0/25 - g26
- GigabitEthernet 1/0/26 - g27
- GigabitEthernet 1/0/27 - g28
- GigabitEthernet 1/0/28
vlans: &switch_b_vlans vlans: &switch_b_vlans
- mgmt - mgmt
- core - core
@ -53,23 +50,23 @@ switches:
mgmt: mgmt:
mode: access mode: access
ports: ports:
- GigabitEthernet1/0/1 - g1
iso1: iso1:
mode: access mode: access
ports: ports:
- GigabitEthernet 1/0/2 - g2
iso2: iso2:
mode: access mode: access
ports: ports:
- GigabitEthernet 1/0/3 - g3
iso3: iso3:
mode: access mode: access
ports: ports:
- GigabitEthernet 1/0/4 - g4
ap8: ap8:
mode: trunk mode: trunk
ports: ports:
- GigabitEthernet 1/0/16 - g16
vlans: vlans:
- mgmt - mgmt
- pub - pub
@ -78,7 +75,7 @@ switches:
ap23: ap23:
mode: trunk mode: trunk
ports: ports:
- GigabitEthernet 1/0/10 - g10
vlans: vlans:
- mgmt - mgmt
- pub - pub
@ -87,10 +84,10 @@ switches:
mode: bond mode: bond
group: 2 group: 2
ports: ports:
- GigabitEthernet1/0/29 - g29
- GigabitEthernet1/0/30 - g30
- GigabitEthernet1/0/31 - g31
- GigabitEthernet1/0/32 - g32
vlans: vlans:
- mgmt - mgmt
- pub - pub
@ -134,12 +131,9 @@ switches:
- iso15 - iso15
- iso16 - iso16
switch-d1: switch-d1:
mode: bond mode: trunk
group: 5
ports: ports:
# 33 is not currently plugged - g34
- GigabitEthernet1/0/33
- GigabitEthernet1/0/34
vlans: vlans:
- mgmt - mgmt
- core - core
@ -152,13 +146,12 @@ switches:
- priv38 - priv38
- priv40 - priv40
server1: server1:
mode: bond mode: trunk
group: 7
ports: ports:
- GigabitEthernet1/0/46 # - g46
- GigabitEthernet1/0/47 # - g47
- GigabitEthernet1/0/48 # - g48
- GigabitEthernet1/0/24 - g24
vlans: &server1_vlans vlans: &server1_vlans
- mgmt - mgmt
- pub - pub
@ -219,19 +212,19 @@ switches:
mode: bond mode: bond
group: 1 group: 1
ports: ports:
- GigabitEthernet1/0/12 - g12
- GigabitEthernet1/0/38 - g38
- GigabitEthernet1/0/39 - g39
- GigabitEthernet1/0/40 - g40
vlans: *server1_vlans vlans: *server1_vlans
c3d2-server5: c3d2-server5:
mode: bond mode: bond
group: 6 group: 6
ports: ports:
- GigabitEthernet1/0/17 - g17
- GigabitEthernet1/0/18 - g18
- GigabitEthernet1/0/19 - g19
- GigabitEthernet1/0/20 - g20
vlans: &server_vlans vlans: &server_vlans
- mgmt - mgmt
- pub - pub
@ -245,52 +238,53 @@ switches:
mode: bond mode: bond
group: 8 group: 8
ports: ports:
- GigabitEthernet1/0/5 - g5
- GigabitEthernet1/0/6 - g6
- GigabitEthernet1/0/7 - g7
- GigabitEthernet1/0/8 - g8
vlans: *server_vlans vlans: *server_vlans
c3d2-server7: c3d2-server7:
mode: bond mode: bond
group: 9 group: 7
ports: ports:
- GigabitEthernet1/0/9 - g9
- GigabitEthernet1/0/11 - g11
- GigabitEthernet1/0/14 - g14
- GigabitEthernet1/0/15 - g15
vlans: *server_vlans vlans: *server_vlans
c3d2-server8: c3d2-server8:
mode: bond mode: bond
group: 10 group: 5
ports: ports:
- GigabitEthernet1/0/35 - g35
- GigabitEthernet1/0/36 - g36
- GigabitEthernet1/0/37 - g37
- GigabitEthernet1/0/13 - g13
vlans: *server_vlans vlans: *server_vlans
serv: serv:
mode: access mode: access
ports: ports:
# vps1 # vps1
- GigabitEthernet1/0/22 - g22
c3d2-monit: # c3d2-monit:
mode: trunk # mode: trunk
ports: # ports:
- GigabitEthernet1/0/21 # - g21
- GigabitEthernet1/0/45 # - g45
access: c3d2 # vlans:
# - c3d2
c3d2: c3d2:
mode: access mode: access
ports: ports:
- GigabitEthernet1/0/23 - g23
switch-c3d2-main: switch-c3d2-main:
mode: bond mode: bond
group: 4 group: 4
ports: ports:
- GigabitEthernet 1/0/41 - g41
- GigabitEthernet 1/0/42 - g42
- GigabitEthernet 1/0/43 - g43
- GigabitEthernet 1/0/44 - g44
vlans: vlans:
- mgmt - mgmt
- pub - pub

View File

@ -0,0 +1,107 @@
{# https://www.crc.id.au/real-console-on-linksys-srw2024-switch/ #}
{%- import_yaml "netmasks.yaml" as netmasks -%}
#!/usr/bin/expect -f
spawn telnet {{ pillar['hosts-inet']['mgmt'][hostname] }}
expect "Password:"
send "admin\t{{ switch['password'] }}\r"
# ^z
send "\x1A"
expect ">"
send "lcli\r"
expect "User Name:"
send "admin\r"
expect "Password:"
send "{{ switch['password'] }}\r"
expect "# "
send "configure\r"
expect "(config)# "
send "hostname {{ hostname }}\r"
expect "(config)# "
send "management vlan 4094\r"
expect "(config)# "
send "vlan database\r"
expect "(config-vlan)# "
{%- for name, vlan in pillar['vlans'].items() %}
{%- if name != 'mgmt' %}
send "no vlan {{ vlan }}\r"
{%- endif %}
send "vlan {{ vlan }}\r"
expect "(config-vlan)#"
{%- endfor %}
send "exit\r"
expect "(config)#"
{%- for name, vlan in pillar['vlans'].items() %}
send "interface vlan {{ vlan }}\r"
expect "(config-if)#"
send "name {{ name }}\r"
expect "(config-if)#"
send "exit\r"
expect "(config)#"
{%- endfor %}
{%- for name, conf in switch['ports'].items() %}
{%- if conf['mode'] == 'trunk' %}
{%- for port in conf['ports'] %}
send "interface ethernet {{ port }}\r"
expect "(config-if)#"
send "no channel-group\r"
expect "(config-if)#"
send "switchport mode trunk\r"
expect "(config-if)#"
{%- set vlan_ids = [] %}
{%- for name in conf['vlans'] %}
{%- if vlan_ids.append('' ~ pillar['vlans'][name]) %}
{%- endif %}
{%- endfor %}
send "switchport trunk allowed vlan add {{ ','.join(vlan_ids) }}\r"
expect "(config-if)#"
send "exit\r"
expect "(config)#"
{%- endfor %}
{%- elif conf['mode'] == 'bond' %}
send "interface range ethernet {{ ','.join(conf['ports']) }}\r"
expect "(config-if)#"
send "switchport trunk allowed vlan remove all\r"
expect "(config-if)#"
send "channel-group {{ conf['group'] }} mode auto\r"
expect "(config-if)#"
send "interface port-channel {{ conf['group'] }}\r"
expect "(config-if)#"
send "exit\r"
send "interface port-channel {{ conf['group'] }}\r"
expect "(config-if)#"
send "switchport mode trunk\r"
expect "(config-if)#"
{%- set vlan_ids = [] %}
{%- for name in conf['vlans'] %}
{%- if vlan_ids.append('' ~ pillar['vlans'][name]) %}
{%- endif %}
{%- endfor %}
send "switchport trunk allowed vlan add {{ ','.join(vlan_ids) }}\r"
expect "(config-if)#"
send "exit\r"
expect "(config)#"
{%- elif conf['mode'] == 'access' %}
{%- for port in conf['ports'] %}
send "interface ethernet {{ port }}\r"
expect "(config-if)#"
send "no channel-group\r"
expect "(config-if)#"
send "switchport mode access\r"
expect "(config-if)#"
send "switchport access vlan {{ pillar['vlans'][name] }}\r"
expect "(config-if)#"
send "exit\r"
expect "(config)#"
{%- endfor %}
{%- endif %}
{%- endfor %}