2019-08-23 11:36:26 +02:00
|
|
|
---
|
|
|
|
- debug:
|
|
|
|
msg: "Start nxos_l3_interfaces overridden integration tests connection={{ ansible_connection }}"
|
|
|
|
|
|
|
|
- set_fact: test_int1="{{ nxos_int1 }}"
|
|
|
|
- set_fact: test_int2="{{ nxos_int2 }}"
|
|
|
|
- set_fact: test_int3="{{ nxos_int3 }}"
|
|
|
|
|
|
|
|
- name: setup1
|
|
|
|
cli_config: &cleanup
|
|
|
|
config: |
|
2020-01-10 12:03:22 +01:00
|
|
|
no system default switchport
|
2019-08-23 11:36:26 +02:00
|
|
|
default interface {{ test_int1 }}
|
|
|
|
default interface {{ test_int2 }}
|
|
|
|
default interface {{ test_int3 }}
|
2020-01-10 12:03:22 +01:00
|
|
|
interface {{ test_int1 }}
|
|
|
|
no switchport
|
|
|
|
interface {{ test_int2 }}
|
|
|
|
no switchport
|
|
|
|
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: |
|
|
|
|
interface {{ test_int1 }}
|
|
|
|
ip address 192.168.10.2/24 tag 5
|
|
|
|
interface {{ test_int2 }}
|
|
|
|
ip address 10.1.1.1/24
|
|
|
|
|
|
|
|
- name: Gather l3_interfaces facts
|
|
|
|
nxos_facts: &facts
|
|
|
|
gather_subset:
|
|
|
|
- '!all'
|
|
|
|
- '!min'
|
|
|
|
gather_network_resources: l3_interfaces
|
|
|
|
|
|
|
|
- name: Overridden
|
|
|
|
nxos_l3_interfaces: &overridden
|
|
|
|
config:
|
|
|
|
- name: "{{ test_int3 }}"
|
|
|
|
ipv4:
|
|
|
|
- address: 10.1.1.3/24
|
|
|
|
state: overridden
|
|
|
|
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"
|
|
|
|
- "'interface {{ test_int1 }}' in result.commands"
|
|
|
|
- "'no ip address' in result.commands"
|
|
|
|
- "'interface {{ test_int2 }}' in result.commands"
|
|
|
|
- "'no ip address' in result.commands"
|
|
|
|
- "'interface {{ test_int3 }}' in result.commands"
|
|
|
|
- "'ip address 10.1.1.3/24' in result.commands"
|
|
|
|
- "result.commands|length == 6"
|
|
|
|
|
|
|
|
- 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 - Overridden
|
|
|
|
nxos_l3_interfaces: *overridden
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == false"
|
|
|
|
- "result.commands|length == 0"
|
|
|
|
|
|
|
|
always:
|
|
|
|
- name: teardown
|
|
|
|
cli_config: *cleanup
|
2020-01-10 12:03:22 +01:00
|
|
|
ignore_errors: yes
|