2019-08-23 11:36:26 +02:00
|
|
|
---
|
|
|
|
- debug:
|
|
|
|
msg: "Start nxos_l3_interfaces replaced integration tests connection={{ ansible_connection }}"
|
|
|
|
|
2020-01-10 12:03:22 +01:00
|
|
|
- set_fact:
|
|
|
|
test_int3: "{{ nxos_int3 }}"
|
|
|
|
subint3: "{{ nxos_int3 }}.42"
|
2019-08-23 11:36:26 +02:00
|
|
|
|
|
|
|
- name: setup1
|
|
|
|
cli_config: &cleanup
|
|
|
|
config: |
|
2020-01-10 12:03:22 +01:00
|
|
|
no system default switchport
|
|
|
|
default interface {{ test_int3 }}
|
|
|
|
interface {{ test_int3 }}
|
|
|
|
no switchport
|
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- name: setup2 cleanup all L3 states on all interfaces
|
|
|
|
nxos_l3_interfaces:
|
|
|
|
state: deleted
|
2019-08-23 11:36:26 +02:00
|
|
|
|
|
|
|
- block:
|
2020-01-10 12:03:22 +01:00
|
|
|
- name: setup3
|
2019-08-23 11:36:26 +02:00
|
|
|
cli_config:
|
|
|
|
config: |
|
2020-01-10 12:03:22 +01:00
|
|
|
interface {{ subint3 }}
|
|
|
|
encapsulation dot1q 42
|
2019-08-23 11:36:26 +02:00
|
|
|
ip address 192.168.10.2/24
|
2020-01-10 12:03:22 +01:00
|
|
|
no ip redirects
|
|
|
|
ip unreachables
|
2019-08-23 11:36:26 +02:00
|
|
|
|
|
|
|
- name: Gather l3_interfaces facts
|
|
|
|
nxos_facts: &facts
|
|
|
|
gather_subset:
|
|
|
|
- '!all'
|
|
|
|
- '!min'
|
|
|
|
gather_network_resources: l3_interfaces
|
|
|
|
|
|
|
|
- name: Replaced
|
|
|
|
nxos_l3_interfaces: &replaced
|
|
|
|
config:
|
2020-01-10 12:03:22 +01:00
|
|
|
- name: "{{ subint3 }}"
|
|
|
|
dot1q: 442
|
|
|
|
# Note: device auto-disables redirects when secondaries are present
|
|
|
|
redirects: false
|
|
|
|
unreachables: false
|
|
|
|
ipv4:
|
|
|
|
- address: 192.168.20.2/24
|
|
|
|
tag: 5
|
|
|
|
- address: 192.168.200.2/24
|
|
|
|
secondary: True
|
2019-08-23 11:36:26 +02:00
|
|
|
state: replaced
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
2020-01-10 12:03:22 +01:00
|
|
|
- "result.before|length == (ansible_facts.network_resources.l3_interfaces|length|int - rsvd_intf_len|int)"
|
2019-08-23 11:36:26 +02:00
|
|
|
- "result.changed == true"
|
2020-01-10 12:03:22 +01:00
|
|
|
- "'interface {{ subint3 }}' in result.commands"
|
|
|
|
- "'encapsulation dot1q 442' in result.commands"
|
|
|
|
- "'no ip unreachables' in result.commands"
|
|
|
|
- "'ip address 192.168.20.2/24 tag 5' in result.commands"
|
|
|
|
- "'ip address 192.168.200.2/24 secondary' in result.commands"
|
|
|
|
- "result.commands|length == 5"
|
2019-08-23 11:36:26 +02:00
|
|
|
|
|
|
|
- name: Gather l3_interfaces post facts
|
|
|
|
nxos_facts: *facts
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
2020-01-10 12:03:22 +01:00
|
|
|
- "result.after|length == (ansible_facts.network_resources.l3_interfaces|length|int - rsvd_intf_len|int)"
|
2019-08-23 11:36:26 +02:00
|
|
|
|
|
|
|
- name: Idempotence - Replaced
|
|
|
|
nxos_l3_interfaces: *replaced
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == false"
|
|
|
|
- "result.commands|length == 0"
|
|
|
|
|
2020-01-10 12:03:22 +01:00
|
|
|
- name: Replaced with no optional attrs specified
|
|
|
|
nxos_l3_interfaces: &replaced_no_attrs
|
|
|
|
config:
|
|
|
|
- name: "{{ subint3 }}"
|
|
|
|
state: replaced
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == true"
|
|
|
|
- "'interface {{ subint3 }}' in result.commands"
|
|
|
|
- "'no encapsulation dot1q' in result.commands"
|
|
|
|
- "'no ip address' in result.commands"
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
# 'ip redirects' normally auto-enables due to rmv'ing the secondaries;
|
|
|
|
# this behavior is unreliable on legacy platforms thus command is explicit.
|
|
|
|
- "'ip redirects' in result.commands"
|
|
|
|
when: platform is match('N[3567]')
|
|
|
|
|
|
|
|
- name: Idempotence - Replaced with no attrs specified
|
|
|
|
nxos_l3_interfaces: *replaced_no_attrs
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == false"
|
|
|
|
- "result.commands|length == 0"
|
|
|
|
|
2019-08-23 11:36:26 +02:00
|
|
|
always:
|
|
|
|
- name: teardown
|
2020-01-10 12:03:22 +01:00
|
|
|
cli_config:
|
|
|
|
config: |
|
|
|
|
no interface {{ subint3 }}
|
|
|
|
ignore_errors: yes
|