mirror of https://github.com/ansible/ansible.git
Fix eos_l2_interface idempotency (#56531)
* Attempt to handle just mode trunk properly * Add test for trunk-only config and clean up tests * Add missing eapi tests and remove references to provider as we do not test localpull/56596/head
parent
18f22de67e
commit
63e33f7e71
@ -1,140 +1,108 @@
|
|||||||
---
|
---
|
||||||
- debug: msg="START eos_l2_interface cli/basic.yaml on connection={{ ansible_connection }}"
|
- debug:
|
||||||
|
msg: "START eos_l2_interface cli/basic.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
- name: Delete test interface switchports
|
- name: Delete test interface switchports
|
||||||
eos_l2_interface:
|
eos_l2_interface: &clear
|
||||||
name: Ethernet1
|
name: Ethernet1
|
||||||
state: absent
|
state: absent
|
||||||
authorize: yes
|
|
||||||
provider: "{{ cli }}"
|
|
||||||
become: yes
|
become: yes
|
||||||
|
|
||||||
- name: Set switchport mode to access on vlan 4000
|
- name: Set switchport mode to access on vlan 4000
|
||||||
eos_l2_interface:
|
eos_l2_interface: &vlan-4000
|
||||||
name: Ethernet1
|
name: Ethernet1
|
||||||
state: present
|
state: present
|
||||||
mode: access
|
mode: access
|
||||||
access_vlan: 4000
|
access_vlan: 4000
|
||||||
authorize: yes
|
|
||||||
provider: "{{ cli }}"
|
|
||||||
become: yes
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert: &changed
|
||||||
that:
|
that:
|
||||||
- 'result.changed == true'
|
- 'result.changed == true'
|
||||||
|
|
||||||
- name: Set switchport mode to access on vlan 4000 again (idempotent)
|
- name: Set switchport mode to access on vlan 4000 again (idempotent)
|
||||||
eos_l2_interface:
|
eos_l2_interface: *vlan-4000
|
||||||
name: Ethernet1
|
|
||||||
state: present
|
|
||||||
mode: access
|
|
||||||
access_vlan: 4000
|
|
||||||
authorize: yes
|
|
||||||
provider: "{{ cli }}"
|
|
||||||
become: yes
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert: &unchanged
|
||||||
that:
|
that:
|
||||||
- 'result.changed == false'
|
- 'result.changed == false'
|
||||||
|
|
||||||
- name: Change access vlan to 4001
|
- name: Change access vlan to 4001
|
||||||
eos_l2_interface:
|
eos_l2_interface: &vlan-4001
|
||||||
name: Ethernet1
|
name: Ethernet1
|
||||||
state: present
|
state: present
|
||||||
mode: access
|
mode: access
|
||||||
access_vlan: 4001
|
access_vlan: 4001
|
||||||
authorize: yes
|
|
||||||
provider: "{{ cli }}"
|
|
||||||
become: yes
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert: *changed
|
||||||
that:
|
|
||||||
- 'result.changed == true'
|
|
||||||
|
|
||||||
- name: Change access vlan to 4001 again (idempotent)
|
- name: Change access vlan to 4001 again (idempotent)
|
||||||
eos_l2_interface:
|
eos_l2_interface: *vlan-4001
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: *unchanged
|
||||||
|
|
||||||
|
- name: Change switchport mode to trunk
|
||||||
|
eos_l2_interface: &trunk
|
||||||
name: Ethernet1
|
name: Ethernet1
|
||||||
state: present
|
state: present
|
||||||
mode: access
|
mode: trunk
|
||||||
access_vlan: 4001
|
|
||||||
authorize: yes
|
|
||||||
provider: "{{ cli }}"
|
|
||||||
become: yes
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert: *changed
|
||||||
that:
|
|
||||||
- 'result.changed == false'
|
- name: Change switchport mode to trunk (idempotent)
|
||||||
|
eos_l2_interface: *trunk
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: *unchanged
|
||||||
|
|
||||||
- name: Change switchport mode to trunk and set native vlan to 4001
|
- name: Change switchport mode to trunk and set native vlan to 4001
|
||||||
eos_l2_interface:
|
eos_l2_interface: &trunk-native
|
||||||
name: Ethernet1
|
name: Ethernet1
|
||||||
state: present
|
state: present
|
||||||
mode: trunk
|
mode: trunk
|
||||||
native_vlan: 4001
|
native_vlan: 4001
|
||||||
authorize: yes
|
|
||||||
provider: "{{ cli }}"
|
|
||||||
become: yes
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert: *changed
|
||||||
that:
|
|
||||||
- 'result.changed == true'
|
|
||||||
|
|
||||||
- name: Change switchport mode to trunk and set native vlan to 4001 again (idempotent)
|
- name: Change switchport mode to trunk and set native vlan to 4001 again (idempotent)
|
||||||
eos_l2_interface:
|
eos_l2_interface: *trunk-native
|
||||||
name: Ethernet1
|
|
||||||
state: present
|
|
||||||
mode: trunk
|
|
||||||
native_vlan: 4001
|
|
||||||
authorize: yes
|
|
||||||
provider: "{{ cli }}"
|
|
||||||
become: yes
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert: *unchanged
|
||||||
that:
|
|
||||||
- 'result.changed == false'
|
|
||||||
|
|
||||||
- name: Set trunk allowed vlans to 20 and 4000
|
- name: Set trunk allowed vlans to 20 and 4000
|
||||||
eos_l2_interface:
|
eos_l2_interface: &trunk-allowed
|
||||||
name: Ethernet1
|
name: Ethernet1
|
||||||
state: present
|
state: present
|
||||||
mode: trunk
|
mode: trunk
|
||||||
trunk_allowed_vlans: 20,4000
|
trunk_allowed_vlans: 20,4000
|
||||||
authorize: yes
|
|
||||||
provider: "{{ cli }}"
|
|
||||||
become: yes
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert: *changed
|
||||||
that:
|
|
||||||
- 'result.changed == true'
|
|
||||||
|
|
||||||
- name: Set trunk allowed vlans to 20 and 4000 again (idempotent)
|
- name: Set trunk allowed vlans to 20 and 4000 again (idempotent)
|
||||||
eos_l2_interface:
|
eos_l2_interface: *trunk-allowed
|
||||||
name: Ethernet1
|
|
||||||
state: present
|
|
||||||
mode: trunk
|
|
||||||
trunk_allowed_vlans: 20,4000
|
|
||||||
authorize: yes
|
|
||||||
provider: "{{ cli }}"
|
|
||||||
become: yes
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert: *unchanged
|
||||||
that:
|
|
||||||
- 'result.changed == false'
|
|
||||||
|
|
||||||
- name: Tear down switchports
|
- name: Tear down switchports
|
||||||
eos_l2_interface:
|
eos_l2_interface: *clear
|
||||||
name: Ethernet1
|
|
||||||
state: absent
|
|
||||||
authorize: yes
|
|
||||||
provider: "{{ cli }}"
|
|
||||||
become: yes
|
become: yes
|
||||||
|
|
||||||
- debug: msg="END eos_l3_interface cli/basic.yaml on connection={{ ansible_connection }}"
|
- debug: msg="END eos_l2_interface cli/basic.yaml on connection={{ ansible_connection }}"
|
||||||
|
@ -0,0 +1,108 @@
|
|||||||
|
---
|
||||||
|
- debug:
|
||||||
|
msg: "START eos_l2_interface eapi/basic.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
|
- name: Delete test interface switchports
|
||||||
|
eos_l2_interface: &clear
|
||||||
|
name: Ethernet1
|
||||||
|
state: absent
|
||||||
|
become: yes
|
||||||
|
|
||||||
|
- name: Set switchport mode to access on vlan 4000
|
||||||
|
eos_l2_interface: &vlan-4000
|
||||||
|
name: Ethernet1
|
||||||
|
state: present
|
||||||
|
mode: access
|
||||||
|
access_vlan: 4000
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: &changed
|
||||||
|
that:
|
||||||
|
- 'result.changed == true'
|
||||||
|
|
||||||
|
- name: Set switchport mode to access on vlan 4000 again (idempotent)
|
||||||
|
eos_l2_interface: *vlan-4000
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: &unchanged
|
||||||
|
that:
|
||||||
|
- 'result.changed == false'
|
||||||
|
|
||||||
|
- name: Change access vlan to 4001
|
||||||
|
eos_l2_interface: &vlan-4001
|
||||||
|
name: Ethernet1
|
||||||
|
state: present
|
||||||
|
mode: access
|
||||||
|
access_vlan: 4001
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: *changed
|
||||||
|
|
||||||
|
- name: Change access vlan to 4001 again (idempotent)
|
||||||
|
eos_l2_interface: *vlan-4001
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: *unchanged
|
||||||
|
|
||||||
|
- name: Change switchport mode to trunk
|
||||||
|
eos_l2_interface: &trunk
|
||||||
|
name: Ethernet1
|
||||||
|
state: present
|
||||||
|
mode: trunk
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: *changed
|
||||||
|
|
||||||
|
- name: Change switchport mode to trunk (idempotent)
|
||||||
|
eos_l2_interface: *trunk
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: *unchanged
|
||||||
|
|
||||||
|
- name: Change switchport mode to trunk and set native vlan to 4001
|
||||||
|
eos_l2_interface: &trunk-native
|
||||||
|
name: Ethernet1
|
||||||
|
state: present
|
||||||
|
mode: trunk
|
||||||
|
native_vlan: 4001
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: *changed
|
||||||
|
|
||||||
|
- name: Change switchport mode to trunk and set native vlan to 4001 again (idempotent)
|
||||||
|
eos_l2_interface: *trunk-native
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: *unchanged
|
||||||
|
|
||||||
|
- name: Set trunk allowed vlans to 20 and 4000
|
||||||
|
eos_l2_interface: &trunk-allowed
|
||||||
|
name: Ethernet1
|
||||||
|
state: present
|
||||||
|
mode: trunk
|
||||||
|
trunk_allowed_vlans: 20,4000
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: *changed
|
||||||
|
|
||||||
|
- name: Set trunk allowed vlans to 20 and 4000 again (idempotent)
|
||||||
|
eos_l2_interface: *trunk-allowed
|
||||||
|
become: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: *unchanged
|
||||||
|
|
||||||
|
- name: Tear down switchports
|
||||||
|
eos_l2_interface: *clear
|
||||||
|
become: yes
|
||||||
|
|
||||||
|
- debug: msg="END eos_l2_interface eapi/basic.yaml on connection={{ ansible_connection }}"
|
Loading…
Reference in New Issue