Skip to content

Commit

Permalink
Replace configuration for switch interfaces
Browse files Browse the repository at this point in the history
- merge to replace - For most of the usecases merge is good enough but certain edge cases
might be effected due to certain configuration. changed some merge
statments to replaced.
- allow reusing ae members
  • Loading branch information
eshulman2 authored and openshift-merge-bot[bot] committed Aug 27, 2024
1 parent a191b19 commit 88a6b80
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 21 deletions.
2 changes: 1 addition & 1 deletion roles/switch_config/tasks/ios_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
{% endfor %}
cisco.ios.ios_l2_interfaces:
config: "{{ interface_config | from_yaml }}"
state: merged
state: replaced

- name: Save configuration
cisco.ios.ios_config:
Expand Down
71 changes: 51 additions & 20 deletions roles/switch_config/tasks/junos_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
{% endfor %}
junipernetworks.junos.junos_l2_interfaces:
config: "{{ interface_config | from_yaml }}"
state: merged
state: replaced

- name: Set MTU and description for the interfaces
vars:
Expand All @@ -78,24 +78,55 @@
junipernetworks.junos.junos_interfaces:
config: '{{ interface_config | from_yaml }}'
state: merged
- name: Configure AE
when: switch_vars['interfaces'] | selectattr('aggr_members', 'defined') | list != []
block:
- name: Empty nic config before adding to ae
vars:
interface_config: |
{% for interface in switch_vars['interfaces'] %}
{% if interface.aggr_members is defined %}
{% for member in interface.aggr_members %}
- name: "{{ member }}"
trunk: {}
{% endfor %}
{% endif %}
{% endfor %}
junipernetworks.junos.junos_l2_interfaces:
config: '{{ interface_config | from_yaml }}'
state: replaced

- name: Set aggregation for the interface
when: switch_vars['interfaces'] | selectattr('aggr_members', 'defined') != []
vars:
interface_config: |
{% for interface in switch_vars['interfaces'] %}
{% if interface.aggr_members is defined %}
- name: "{{ interface.iface }}"
members:
{% for member in interface.aggr_members %}
- member: "{{ member }}"
{% endfor %}
mode: active
{% endif %}
{% endfor %}
junipernetworks.junos.junos_lag_interfaces:
config: '{{ interface_config | from_yaml }}'
state: merged
# eshulman: Due to module issue resorted to commands :(
- name: Clear interfaces MTU before adding to ae
vars:
interface_config: |
{% for interface in switch_vars['interfaces'] %}
{% if interface.aggr_members is defined %}
{% for member in interface.aggr_members %}
- delete interfaces "{{ member }}" mtu
- delete interfaces "{{ member }}" unit 0
{% endfor %}
{% endif %}
{% endfor %}
junipernetworks.junos.junos_config:
lines: '{{ interface_config | from_yaml }}'

- name: Set aggregation for the interface
vars:
interface_config: |
{% for interface in switch_vars['interfaces'] %}
{% if interface.aggr_members is defined %}
- name: "{{ interface.iface }}"
members:
{% for member in interface.aggr_members %}
- member: "{{ member }}"
{% endfor %}
mode: active
{% endif %}
{% endfor %}
junipernetworks.junos.junos_lag_interfaces:
config: '{{ interface_config | from_yaml }}'
state: replaced


# For each vlan for which igmp snooping is configured, remove previous
Expand Down Expand Up @@ -144,7 +175,7 @@
{% endfor %}
junipernetworks.junos.junos_l3_interfaces:
config: "{{ irb_interfaces | from_yaml }}"
state: merged
state: replaced

- name: Assign irb Interface To VLAN Interface
vars:
Expand All @@ -156,7 +187,7 @@
{% endfor %}
junipernetworks.junos.junos_vlans:
config: "{{ vlan_interfaces | from_yaml }}"
state: merged
state: replaced

- name: Save configuration
junipernetworks.junos.junos_config:
Expand Down

0 comments on commit 88a6b80

Please sign in to comment.