moar switches configuration

This commit is contained in:
Astro 2016-11-14 00:36:36 +01:00
parent efb9ec2f80
commit 4d97712d6e
3 changed files with 75 additions and 22 deletions

View File

@ -6,45 +6,71 @@ switches:
switch-b2: switch-b2:
mode: trunk mode: trunk
ports: ports:
- 25 - '25'
- 26 - '26'
- 27 - '27'
- 28 - '28'
vlans: vlans:
- mgmt - mgmt
- pub - pub
switch-c1: switch-c1:
mode: trunk mode: trunk
ports: ports:
- 29 - '29'
- 30 - '30'
- 31 - '31'
- 32 - '32'
vlans: vlans:
- mgmt - mgmt
- pub - pub
switch-d1: switch-d1:
mode: trunk mode: trunk
ports: ports:
- 33 - '33'
- 34 - '34'
- 35 - '35'
- 36 - '36'
vlans: vlans:
- mgmt - mgmt
- pub - pub
mgmt: mgmt:
mode: access mode: access
ports: ports:
- 1 - '1'
pub: pub:
mode: access mode: access
ports: ports:
- 2 - '2'
- 3 - '3'
- 24 - '24'
- 37 - '37'
- 48 - '48'
switch-b2:
model: '3com-4200G'
location: Haus B Souterrain
ports:
switch-b2:
mode: trunk
ports:
- '25'
- '26'
- '27'
- '28'
vlans:
- mgmt
- pub
mgmt:
mode: access
ports:
- '1'
pub:
mode: access
ports:
- '2'
- '3'
- '24'
- '37'
- '48'
switch-d1: switch-d1:
model: 'TL-SG3210' model: 'TL-SG3210'
location: Turm D Keller location: Turm D Keller
@ -57,10 +83,32 @@ switches:
- pub - pub
up1: up1:
mode: access mode: access
ports: 5 ports:
- '5'
mgmt: mgmt:
mode: access mode: access
ports: 6 ports:
- '6'
pub: pub:
mode: access mode: access
ports: 7-8 ports:
- 7-8
switch-c1:
model: 'TL-SG3210'
location: Turm D Keller
ports:
switch-b1:
mode: trunk
ports: 1-4
vlans:
- mgmt
- pub
mgmt:
mode: access
ports:
- '6'
pub:
mode: access
ports:
- '5'
- 7-8

View File

@ -8,6 +8,8 @@ spawn telnet {{ pillar['hosts-inet']['mgmt'][hostname] }}
expect "Password:" expect "Password:"
send "secret\r" send "secret\r"
expect ">" expect ">"
send "\r"
expect ">"
send "enable\r" send "enable\r"
expect "Password:" expect "Password:"
send "secret\r" send "secret\r"
@ -86,12 +88,14 @@ expect "(config-if-range)#"
send "switchport trunk allowed vlan {{ ','.join(vlan_ids) }}\r" send "switchport trunk allowed vlan {{ ','.join(vlan_ids) }}\r"
expect "(config-if-range)#" expect "(config-if-range)#"
{%- elif conf['mode'] == 'access' %} {%- elif conf['mode'] == 'access' %}
send "interface range gigabitEthernet 1/0/{{ conf['ports'] }}\r" {%- for port in conf['ports'] %}
send "interface range gigabitEthernet 1/0/{{ port }}\r"
expect "(config-if-range)#" expect "(config-if-range)#"
send "switchport mode access\r" send "switchport mode access\r"
expect "(config-if-range)#" expect "(config-if-range)#"
send "switchport access vlan {{ pillar['vlans'][name] }}\r" send "switchport access vlan {{ pillar['vlans'][name] }}\r"
expect "(config-if-range)#" expect "(config-if-range)#"
{%- endfor %}
{%- endif %} {%- endif %}
send "exit\r" send "exit\r"
expect "(config)#" expect "(config)#"

View File

@ -4,6 +4,7 @@ base:
- server1-network - server1-network
- lxc-containers-1 - lxc-containers-1
- ospf - ospf
- switches
'*-gw': '*-gw':
- no-ssh - no-ssh
- forwarding - forwarding