forked from zentralwerk/network
switch configuration for 3com-4200G
This commit is contained in:
parent
c71427dc61
commit
efb9ec2f80
|
@ -1,4 +1,10 @@
|
|||
hosts-inet:
|
||||
mgmt:
|
||||
server1: 10.0.0.1
|
||||
switch-b1: 10.0.0.10
|
||||
switch-b2: 10.0.0.11
|
||||
switch-c1: 10.0.0.12
|
||||
switch-d1: 10.0.0.13
|
||||
core:
|
||||
server1: 172.20.72.1
|
||||
serv-gw: 172.20.72.2
|
||||
|
|
|
@ -4,4 +4,4 @@ subnets-inet:
|
|||
pub: 172.20.76.0/23
|
||||
priv1: 172.20.74.0/28
|
||||
priv2: 172.20.75.0/28
|
||||
mgm: 10.0.0.0/24
|
||||
mgmt: 10.0.0.0/24
|
||||
|
|
|
@ -1,4 +1,50 @@
|
|||
switches:
|
||||
switch-b1:
|
||||
model: '3com-4200G'
|
||||
location: Haus B Souterrain
|
||||
ports:
|
||||
switch-b2:
|
||||
mode: trunk
|
||||
ports:
|
||||
- 25
|
||||
- 26
|
||||
- 27
|
||||
- 28
|
||||
vlans:
|
||||
- mgmt
|
||||
- pub
|
||||
switch-c1:
|
||||
mode: trunk
|
||||
ports:
|
||||
- 29
|
||||
- 30
|
||||
- 31
|
||||
- 32
|
||||
vlans:
|
||||
- mgmt
|
||||
- pub
|
||||
switch-d1:
|
||||
mode: trunk
|
||||
ports:
|
||||
- 33
|
||||
- 34
|
||||
- 35
|
||||
- 36
|
||||
vlans:
|
||||
- mgmt
|
||||
- pub
|
||||
mgmt:
|
||||
mode: access
|
||||
ports:
|
||||
- 1
|
||||
pub:
|
||||
mode: access
|
||||
ports:
|
||||
- 2
|
||||
- 3
|
||||
- 24
|
||||
- 37
|
||||
- 48
|
||||
switch-d1:
|
||||
model: 'TL-SG3210'
|
||||
location: Turm D Keller
|
||||
|
|
|
@ -7,3 +7,5 @@ base:
|
|||
- dhcp
|
||||
'upstream1':
|
||||
- upstream.upstream1
|
||||
'server1':
|
||||
- switches
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
vlans:
|
||||
core: 1
|
||||
serv: 2
|
||||
pub: 3
|
||||
mgmt: 4
|
||||
mgmt: 1
|
||||
core: 2
|
||||
serv: 3
|
||||
pub: 4
|
||||
up1: 10
|
||||
up2: 11
|
||||
up3: 12
|
||||
up4: 13
|
||||
|
|
|
@ -0,0 +1,101 @@
|
|||
{# http://h20628.www2.hp.com/km-ext/kmcsdirect/emr_na-c02586144-1.pdf #}
|
||||
{%- import_yaml "netmasks.yaml" as netmasks -%}
|
||||
#!/usr/bin/expect -f
|
||||
|
||||
spawn telnet {{ pillar['hosts-inet']['mgmt'][hostname] }}
|
||||
expect "Password:"
|
||||
send "secret\r"
|
||||
expect ">"
|
||||
send "system-view\r"
|
||||
expect "]"
|
||||
|
||||
send "sysname {{ hostname }}\r"
|
||||
expect "]"
|
||||
|
||||
send "user-interface vty 0 4\r"
|
||||
expect "ui-vty0-4]"
|
||||
send "screen-length 0\r"
|
||||
expect "ui-vty0-4]"
|
||||
send "user privilege level 3\r"
|
||||
expect "ui-vty0-4]"
|
||||
send "set authentication password simple secret\r"
|
||||
expect "ui-vty0-4]"
|
||||
send "quit\r"
|
||||
expect "{{ hostname }}]"
|
||||
|
||||
send "local-user admin\r"
|
||||
expect -- "-luser-admin]"
|
||||
send "password simple secret\r"
|
||||
expect -- "-luser-admin]"
|
||||
send "quit\r"
|
||||
expect "{{ hostname }}]"
|
||||
|
||||
{%- for name, vlan in pillar['vlans'].items() %}
|
||||
|
||||
send "vlan {{ vlan }}\r"
|
||||
expect -- "-vlan{{ vlan }}]"
|
||||
send "description {{ name }}\r"
|
||||
expect -- "-vlan{{ vlan }}]"
|
||||
send "quit\r"
|
||||
expect "{{ hostname }}]"
|
||||
|
||||
{# Actually only used for mgmt_vlan, switches are not routers #}
|
||||
send "interface Vlan-interface {{ vlan }}\r"
|
||||
expect "]"
|
||||
send "description {{ name }}\r"
|
||||
expect "]"
|
||||
{%- set net_hosts = pillar['hosts-inet'].get(name) %}
|
||||
{%- set ipaddr = net_hosts and net_hosts.get(hostname) %}
|
||||
{%- if ipaddr %}
|
||||
send "ip address {{ ipaddr }} {{ netmasks[pillar['subnets-inet'][name].split('/')[1]] }}\r"
|
||||
expect "]"
|
||||
{%- endif %}
|
||||
send "quit\r"
|
||||
expect "{{ hostname }}]"
|
||||
|
||||
{%- endfor %}
|
||||
|
||||
{%- set group = 0 %}
|
||||
{%- for name, conf in switch['ports'].items() %}
|
||||
{%- if conf['mode'] == 'trunk' %}
|
||||
{%- set group = group + 1 %}
|
||||
{%- for port in conf['ports'] %}
|
||||
send "interface gigabitEthernet 1/0/{{ port }}\r"
|
||||
expect "]"
|
||||
send "lacp enable\r"
|
||||
expect "]"
|
||||
send "port link-aggregation group {{ group }}\r"
|
||||
expect "]"
|
||||
send "port link-type trunk\r"
|
||||
expect "]"
|
||||
{%- for vlan_name in conf['vlans'] %}
|
||||
send "port trunk permit vlan {{ pillar['vlans'][vlan_name] }}\r"
|
||||
expect "]"
|
||||
{%- endfor %}
|
||||
send "quit\r"
|
||||
expect "{{ hostname }}]"
|
||||
{%- endfor %}
|
||||
|
||||
{%- elif conf['mode'] == 'access' %}
|
||||
{%- for port in conf['ports'] %}
|
||||
send "interface gigabitEthernet 1/0/{{ port }}\r"
|
||||
expect "]"
|
||||
send "port link-type access\r"
|
||||
expect "]"
|
||||
send "port access vlan {{ pillar['vlans'][name] }}\r"
|
||||
send "quit\r"
|
||||
expect "{{ hostname }}]"
|
||||
{%- endfor %}
|
||||
|
||||
{%- endif %}
|
||||
{%- endfor %}
|
||||
|
||||
send "save main\r"
|
||||
expect "Y/N]"
|
||||
send "YES\r"
|
||||
expect "press the enter key):"
|
||||
send "\r"
|
||||
expect "]"
|
||||
send "quit\r"
|
||||
expect ">"
|
||||
send "quit\r"
|
|
@ -8,8 +8,6 @@ spawn telnet {{ pillar['hosts-inet']['mgmt'][hostname] }}
|
|||
expect "Password:"
|
||||
send "secret\r"
|
||||
expect ">"
|
||||
send "\r"
|
||||
expect ">"
|
||||
send "enable\r"
|
||||
expect "Password:"
|
||||
send "secret\r"
|
||||
|
|
Loading…
Reference in New Issue