forked from zentralwerk/network
salt/switches: sort output stably
This commit is contained in:
parent
f54fa47fd8
commit
4260ec2405
|
@ -44,7 +44,7 @@ send "info-center source default channel loghost log level informational\r"
|
||||||
expect "]"
|
expect "]"
|
||||||
|
|
||||||
|
|
||||||
{%- for name, vlan in pillar['vlans'].items() %}
|
{%- for name, vlan in pillar['vlans'].items()|sort(attribute='1') %}
|
||||||
send "vlan {{ vlan }}\r"
|
send "vlan {{ vlan }}\r"
|
||||||
expect -- "-vlan{{ vlan }}]"
|
expect -- "-vlan{{ vlan }}]"
|
||||||
send "name {{ name }}\r"
|
send "name {{ name }}\r"
|
||||||
|
@ -65,7 +65,7 @@ send "quit\r"
|
||||||
expect "{{ hostname }}]"
|
expect "{{ hostname }}]"
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
|
||||||
{%- for name, conf in switch['ports'].items() %}
|
{%- for name, conf in switch['ports'].items()|sort(attribute='1.ports') %}
|
||||||
{%- if conf['mode'] == 'trunk' or conf['mode'] == 'bond' %}
|
{%- if conf['mode'] == 'trunk' or conf['mode'] == 'bond' %}
|
||||||
{%- if conf['mode'] == 'bond' %}
|
{%- if conf['mode'] == 'bond' %}
|
||||||
send "link-aggregation group {{ conf['group'] }} mode static\r"
|
send "link-aggregation group {{ conf['group'] }} mode static\r"
|
||||||
|
@ -78,7 +78,7 @@ expect {
|
||||||
send "link-aggregation group {{ conf['group'] }} description {{name}}\r"
|
send "link-aggregation group {{ conf['group'] }} description {{name}}\r"
|
||||||
expect "]"
|
expect "]"
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- for port in conf['ports'] %}
|
{%- for port in conf['ports']|sort %}
|
||||||
send "interface {{ port }}\r"
|
send "interface {{ port }}\r"
|
||||||
expect "]"
|
expect "]"
|
||||||
send "undo stp edged-port\r"
|
send "undo stp edged-port\r"
|
||||||
|
@ -104,7 +104,7 @@ expect "]"
|
||||||
# Deconfigure all but mgmt vlan
|
# Deconfigure all but mgmt vlan
|
||||||
send "undo port trunk permit vlan 2 to 4094\r"
|
send "undo port trunk permit vlan 2 to 4094\r"
|
||||||
expect "]"
|
expect "]"
|
||||||
{%- for vlan_name in conf['vlans'] %}
|
{%- for vlan_name in conf['vlans']|sort %}
|
||||||
send "port trunk permit vlan {{ pillar['vlans'][vlan_name] }}\r"
|
send "port trunk permit vlan {{ pillar['vlans'][vlan_name] }}\r"
|
||||||
expect "]"
|
expect "]"
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
@ -119,7 +119,7 @@ expect "{{ hostname }}]"
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
|
||||||
{%- elif conf['mode'] == 'access' %}
|
{%- elif conf['mode'] == 'access' %}
|
||||||
{%- for port in conf['ports'] %}
|
{%- for port in conf['ports']|sort %}
|
||||||
send "interface {{ port }}\r"
|
send "interface {{ port }}\r"
|
||||||
expect "]"
|
expect "]"
|
||||||
send "undo port link-aggregation group\r"
|
send "undo port link-aggregation group\r"
|
||||||
|
|
|
@ -36,7 +36,7 @@ expect "(config)# "
|
||||||
# timesync sntp
|
# timesync sntp
|
||||||
# ip timep manual {#ntp#} interval 10
|
# ip timep manual {#ntp#} interval 10
|
||||||
|
|
||||||
{%- for name, vlan in pillar['vlans'].items() %}
|
{%- for name, vlan in pillar['vlans'].items()|sort(attribute='1') %}
|
||||||
send "vlan {{ vlan }}\r"
|
send "vlan {{ vlan }}\r"
|
||||||
expect "(vlan-{{ vlan }})#"
|
expect "(vlan-{{ vlan }})#"
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ expect "(config)# "
|
||||||
|
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
|
||||||
{%- for name, conf in switch['ports'].items() %}
|
{%- for name, conf in switch['ports'].items()|sort(attribute='1.ports') %}
|
||||||
{%- if conf['mode'] == 'bond' %}
|
{%- if conf['mode'] == 'bond' %}
|
||||||
|
|
||||||
{%- if not conf.get('lacp', True) %}
|
{%- if not conf.get('lacp', True) %}
|
||||||
|
@ -84,7 +84,7 @@ send "trunk {{ conf['ports'] }} trk{{ conf['group'] }} lacp\r"
|
||||||
expect "(config)# "
|
expect "(config)# "
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
{%- for vlan_name in conf['vlans'] %}
|
{%- for vlan_name in conf['vlans']|sort %}
|
||||||
send "vlan {{ pillar['vlans'][vlan_name] }} tagged trk{{ conf['group'] }}\r"
|
send "vlan {{ pillar['vlans'][vlan_name] }} tagged trk{{ conf['group'] }}\r"
|
||||||
expect "(config)# "
|
expect "(config)# "
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
@ -95,7 +95,7 @@ expect "(config)# "
|
||||||
send "no interface {{ conf['ports'] }} lacp\r"
|
send "no interface {{ conf['ports'] }} lacp\r"
|
||||||
expect "(config)# "
|
expect "(config)# "
|
||||||
|
|
||||||
{%- for vlan_name in conf['vlans'] %}
|
{%- for vlan_name in conf['vlans']|sort %}
|
||||||
send "vlan {{ pillar['vlans'][vlan_name] }} tagged {{ conf['ports'] }}\r"
|
send "vlan {{ pillar['vlans'][vlan_name] }} tagged {{ conf['ports'] }}\r"
|
||||||
expect "(config)# "
|
expect "(config)# "
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
|
|
@ -48,7 +48,7 @@ expect "(config-line)#"
|
||||||
send "exit\r"
|
send "exit\r"
|
||||||
expect "(config)#"
|
expect "(config)#"
|
||||||
|
|
||||||
{%- for name, vlan in pillar['vlans'].items() %}
|
{%- for name, vlan in pillar['vlans'].items()|sort(attribute='1') %}
|
||||||
{%- if name != 'mgmt' %}
|
{%- if name != 'mgmt' %}
|
||||||
send "vlan {{ vlan }}\r"
|
send "vlan {{ vlan }}\r"
|
||||||
expect "(config-vlan)#"
|
expect "(config-vlan)#"
|
||||||
|
@ -72,7 +72,7 @@ expect "(config)#"
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
|
||||||
{%- set group = 0 %}
|
{%- set group = 0 %}
|
||||||
{%- for name, conf in switch['ports'].items() %}
|
{%- for name, conf in switch['ports'].items()|sort(attribute='1.ports') %}
|
||||||
{%- if conf['mode'] == 'trunk' or conf['mode'] == 'bond' %}
|
{%- if conf['mode'] == 'trunk' or conf['mode'] == 'bond' %}
|
||||||
send "interface range gigabitEthernet 1/0/{{ conf['ports'] }}\r"
|
send "interface range gigabitEthernet 1/0/{{ conf['ports'] }}\r"
|
||||||
expect "(config-if-range)#"
|
expect "(config-if-range)#"
|
||||||
|
@ -84,7 +84,7 @@ expect "(config-if-range)#"
|
||||||
#send "port-channel load-balance src-dst-ip\r"
|
#send "port-channel load-balance src-dst-ip\r"
|
||||||
#expect "(config-if-range)#"
|
#expect "(config-if-range)#"
|
||||||
{%- set vlan_ids = [] %}
|
{%- set vlan_ids = [] %}
|
||||||
{%- for name in conf['vlans'] %}
|
{%- for name in conf['vlans']|sort %}
|
||||||
{%- if vlan_ids.append('' ~ pillar['vlans'][name]) %}
|
{%- if vlan_ids.append('' ~ pillar['vlans'][name]) %}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
@ -93,7 +93,7 @@ expect "(config-if-range)#"
|
||||||
send "exit\r"
|
send "exit\r"
|
||||||
expect "(config)#"
|
expect "(config)#"
|
||||||
{%- elif conf['mode'] == 'access' %}
|
{%- elif conf['mode'] == 'access' %}
|
||||||
{%- for port in conf['ports'] %}
|
{%- for port in conf['ports']|sort %}
|
||||||
send "interface range gigabitEthernet 1/0/{{ port }}\r"
|
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"
|
||||||
|
|
|
@ -25,13 +25,13 @@ send "management vlan 4094\r"
|
||||||
expect "(config)# "
|
expect "(config)# "
|
||||||
send "vlan database\r"
|
send "vlan database\r"
|
||||||
expect "(config-vlan)# "
|
expect "(config-vlan)# "
|
||||||
{%- for name, vlan in pillar['vlans'].items() %}
|
{%- for name, vlan in pillar['vlans'].items()|sort(attribute='1') %}
|
||||||
send "vlan {{ vlan }}\r"
|
send "vlan {{ vlan }}\r"
|
||||||
expect "(config-vlan)#"
|
expect "(config-vlan)#"
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
send "exit\r"
|
send "exit\r"
|
||||||
expect "(config)#"
|
expect "(config)#"
|
||||||
{%- for name, vlan in pillar['vlans'].items() %}
|
{%- for name, vlan in pillar['vlans'].items()|sort(attribute='1') %}
|
||||||
send "interface vlan {{ vlan }}\r"
|
send "interface vlan {{ vlan }}\r"
|
||||||
expect "(config-if)#"
|
expect "(config-if)#"
|
||||||
send "name {{ name }}\r"
|
send "name {{ name }}\r"
|
||||||
|
@ -40,10 +40,10 @@ send "exit\r"
|
||||||
expect "(config)#"
|
expect "(config)#"
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
|
||||||
{%- for name, conf in switch['ports'].items() %}
|
{%- for name, conf in switch['ports'].items()|sort(attribute='1.ports') %}
|
||||||
|
|
||||||
{%- if conf['mode'] == 'trunk' %}
|
{%- if conf['mode'] == 'trunk' %}
|
||||||
{%- for port in conf['ports'] %}
|
{%- for port in conf['ports']|sort %}
|
||||||
send "interface ethernet {{ port }}\r"
|
send "interface ethernet {{ port }}\r"
|
||||||
expect "(config-if)#"
|
expect "(config-if)#"
|
||||||
send "no channel-group\r"
|
send "no channel-group\r"
|
||||||
|
@ -51,7 +51,7 @@ expect "(config-if)#"
|
||||||
send "switchport mode trunk\r"
|
send "switchport mode trunk\r"
|
||||||
expect "(config-if)#"
|
expect "(config-if)#"
|
||||||
{%- set vlan_ids = [] %}
|
{%- set vlan_ids = [] %}
|
||||||
{%- for name in conf['vlans'] %}
|
{%- for name in conf['vlans']|sort %}
|
||||||
{%- if vlan_ids.append('' ~ pillar['vlans'][name]) %}
|
{%- if vlan_ids.append('' ~ pillar['vlans'][name]) %}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
@ -77,7 +77,7 @@ expect "(config-if)#"
|
||||||
send "switchport mode trunk\r"
|
send "switchport mode trunk\r"
|
||||||
expect "(config-if)#"
|
expect "(config-if)#"
|
||||||
{%- set vlan_ids = [] %}
|
{%- set vlan_ids = [] %}
|
||||||
{%- for name in conf['vlans'] %}
|
{%- for name in conf['vlans']|sort %}
|
||||||
{%- if vlan_ids.append('' ~ pillar['vlans'][name]) %}
|
{%- if vlan_ids.append('' ~ pillar['vlans'][name]) %}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
@ -88,7 +88,7 @@ send "exit\r"
|
||||||
expect "(config)#"
|
expect "(config)#"
|
||||||
|
|
||||||
{%- elif conf['mode'] == 'access' %}
|
{%- elif conf['mode'] == 'access' %}
|
||||||
{%- for port in conf['ports'] %}
|
{%- for port in conf['ports']|sort %}
|
||||||
send "interface ethernet {{ port }}\r"
|
send "interface ethernet {{ port }}\r"
|
||||||
expect "(config-if)#"
|
expect "(config-if)#"
|
||||||
send "no channel-group\r"
|
send "no channel-group\r"
|
||||||
|
|
Loading…
Reference in New Issue