2017-10-26 17:27:55 +02:00
|
|
|
---
|
2018-01-05 18:39:04 +01:00
|
|
|
- debug: msg="START connection={{ ansible_connection }} nxos_static_route sanity test"
|
|
|
|
- debug: msg="Using provider={{ connection.transport }}"
|
|
|
|
when: ansible_connection == "local"
|
2017-10-26 17:27:55 +02:00
|
|
|
|
2018-12-04 05:27:35 +01:00
|
|
|
# Flag used to test the track feature. Some platforms
|
|
|
|
# don't support it so this flag will be toggled accordingly.
|
|
|
|
- set_fact: test_track_feature="true"
|
|
|
|
|
|
|
|
- name: configure track
|
|
|
|
nxos_config:
|
|
|
|
lines:
|
|
|
|
- track 1 ip sla 1
|
|
|
|
provider: "{{ connection }}"
|
|
|
|
register: cmd_result
|
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- debug: msg="cmd result {{ cmd_result }}"
|
2018-11-16 05:03:22 +01:00
|
|
|
|
2018-12-04 05:27:35 +01:00
|
|
|
- set_fact: test_track_feature="false"
|
|
|
|
when: cmd_result.failed
|
|
|
|
|
|
|
|
- debug: msg="Test Track Feature {{ test_track_feature }}"
|
|
|
|
|
2019-03-21 14:22:46 +01:00
|
|
|
- name: Setup and teardown, remove test routes if present
|
|
|
|
nxos_static_route: &setup_teardown
|
|
|
|
aggregate:
|
|
|
|
- { prefix: "192.168.1.164/32", next_hop: "192.0.2.3" }
|
|
|
|
- { prefix: "192.168.20.64/24", next_hop: "192.0.2.3" }
|
|
|
|
- { prefix: "192.168.22.64/24", next_hop: "192.0.2.3" }
|
|
|
|
- { prefix: "192.168.24.64/24", next_hop: "192.0.2.3" }
|
|
|
|
vrf: "{{ item }}"
|
|
|
|
provider: "{{ connection }}"
|
|
|
|
state: absent
|
|
|
|
with_items: "{{ vrfs }}"
|
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- name: Setup noise routes to ensure testing while non-test routes present
|
|
|
|
nxos_static_route:
|
|
|
|
prefix: "192.168.1.164/32"
|
|
|
|
next_hop: "192.0.2.3"
|
|
|
|
vrf: "{{ item }}"
|
|
|
|
provider: "{{ connection }}"
|
|
|
|
state: present
|
|
|
|
with_items: "{{ vrfs }}"
|
|
|
|
|
2018-12-04 05:27:35 +01:00
|
|
|
- block:
|
2017-10-26 17:27:55 +02:00
|
|
|
- name: create static route
|
2018-11-16 05:03:22 +01:00
|
|
|
nxos_static_route: &configure_static
|
2017-10-26 17:27:55 +02:00
|
|
|
prefix: "192.168.20.64/24"
|
2018-05-30 19:03:20 +02:00
|
|
|
next_hop: "192.0.2.3"
|
2017-10-26 17:27:55 +02:00
|
|
|
route_name: testing
|
|
|
|
pref: 100
|
|
|
|
tag: 5500
|
2018-03-26 17:13:32 +02:00
|
|
|
vrf: "{{ item }}"
|
2018-07-02 15:43:51 +02:00
|
|
|
provider: "{{ connection }}"
|
2018-03-26 17:13:32 +02:00
|
|
|
with_items: "{{ vrfs }}"
|
2017-10-26 17:27:55 +02:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: &true
|
|
|
|
that:
|
|
|
|
- "result.changed == true"
|
|
|
|
|
2018-11-16 05:03:22 +01:00
|
|
|
- name: "Conf static Idempotence"
|
|
|
|
nxos_static_route: *configure_static
|
2018-03-26 17:13:32 +02:00
|
|
|
with_items: "{{ vrfs }}"
|
2017-10-26 17:27:55 +02:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: &false
|
|
|
|
that:
|
|
|
|
- "result.changed == false"
|
|
|
|
|
2018-03-26 17:13:32 +02:00
|
|
|
- name: change static route
|
2018-11-16 05:03:22 +01:00
|
|
|
nxos_static_route: &change_static
|
|
|
|
prefix: "192.168.20.64/24"
|
|
|
|
next_hop: "192.0.2.3"
|
|
|
|
route_name: default
|
|
|
|
pref: 10
|
|
|
|
tag: default
|
|
|
|
vrf: "{{ item }}"
|
|
|
|
provider: "{{ connection }}"
|
|
|
|
with_items: "{{ vrfs }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: *true
|
|
|
|
|
|
|
|
- name: "Change Idempotence"
|
|
|
|
nxos_static_route: *change_static
|
|
|
|
with_items: "{{ vrfs }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: *false
|
|
|
|
|
|
|
|
- name: configure static route with track
|
|
|
|
nxos_static_route: &config_static_track
|
2018-03-26 17:13:32 +02:00
|
|
|
prefix: "192.168.20.64/24"
|
2018-05-30 19:03:20 +02:00
|
|
|
next_hop: "192.0.2.3"
|
2018-03-26 17:13:32 +02:00
|
|
|
route_name: default
|
|
|
|
pref: 10
|
|
|
|
tag: default
|
2018-11-16 05:03:22 +01:00
|
|
|
track: 1
|
2018-03-26 17:13:32 +02:00
|
|
|
vrf: "{{ item }}"
|
2018-07-02 15:43:51 +02:00
|
|
|
provider: "{{ connection }}"
|
2018-03-26 17:13:32 +02:00
|
|
|
with_items: "{{ vrfs }}"
|
|
|
|
register: result
|
2018-12-04 05:27:35 +01:00
|
|
|
when: test_track_feature
|
2018-03-26 17:13:32 +02:00
|
|
|
|
|
|
|
- assert: *true
|
2018-12-04 05:27:35 +01:00
|
|
|
when: test_track_feature
|
2018-03-26 17:13:32 +02:00
|
|
|
|
2018-11-16 05:03:22 +01:00
|
|
|
- name: "Config track Idempotence"
|
|
|
|
nxos_static_route: *config_static_track
|
2018-03-26 17:13:32 +02:00
|
|
|
with_items: "{{ vrfs }}"
|
|
|
|
register: result
|
2018-12-04 05:27:35 +01:00
|
|
|
when: test_track_feature
|
2018-03-26 17:13:32 +02:00
|
|
|
|
|
|
|
- assert: *false
|
2018-12-04 05:27:35 +01:00
|
|
|
when: test_track_feature
|
2018-03-26 17:13:32 +02:00
|
|
|
|
2018-11-16 05:03:22 +01:00
|
|
|
- name: configure static route with not configured track
|
2018-12-04 05:27:35 +01:00
|
|
|
nxos_static_route:
|
2018-11-16 05:03:22 +01:00
|
|
|
prefix: "192.168.20.64/24"
|
|
|
|
next_hop: "192.0.2.3"
|
|
|
|
route_name: default
|
|
|
|
pref: 10
|
|
|
|
tag: default
|
|
|
|
track: 2
|
|
|
|
vrf: "{{ item }}"
|
|
|
|
provider: "{{ connection }}"
|
|
|
|
with_items: "{{ vrfs }}"
|
|
|
|
register: result
|
|
|
|
ignore_errors: yes
|
2018-12-04 05:27:35 +01:00
|
|
|
when: test_track_feature
|
2018-11-16 05:03:22 +01:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.failed == True"
|
2018-12-04 05:27:35 +01:00
|
|
|
when: test_track_feature
|
2018-11-16 05:03:22 +01:00
|
|
|
|
2017-10-26 17:27:55 +02:00
|
|
|
- name: remove static route
|
2018-11-16 05:03:22 +01:00
|
|
|
nxos_static_route: &remove_static
|
2017-10-26 17:27:55 +02:00
|
|
|
prefix: "192.168.20.64/24"
|
2018-05-30 19:03:20 +02:00
|
|
|
next_hop: "192.0.2.3"
|
2017-10-26 17:27:55 +02:00
|
|
|
route_name: testing
|
|
|
|
pref: 100
|
2018-03-26 17:13:32 +02:00
|
|
|
vrf: "{{ item }}"
|
2018-07-02 15:43:51 +02:00
|
|
|
provider: "{{ connection }}"
|
2017-10-26 17:27:55 +02:00
|
|
|
state: absent
|
2018-03-26 17:13:32 +02:00
|
|
|
with_items: "{{ vrfs }}"
|
2017-10-26 17:27:55 +02:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: *true
|
|
|
|
|
|
|
|
- name: "Remove Idempotence"
|
2018-11-16 05:03:22 +01:00
|
|
|
nxos_static_route: *remove_static
|
2018-03-26 17:13:32 +02:00
|
|
|
with_items: "{{ vrfs }}"
|
2017-10-26 17:27:55 +02:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: *false
|
|
|
|
|
2017-12-20 12:38:29 +01:00
|
|
|
- name: configure static route(aggregate)
|
|
|
|
nxos_static_route: &conf_agg
|
|
|
|
aggregate:
|
2018-05-30 19:03:20 +02:00
|
|
|
- { prefix: "192.168.22.64/24", next_hop: "192.0.2.3" }
|
|
|
|
- { prefix: "192.168.24.64/24", next_hop: "192.0.2.3" }
|
2018-07-02 15:43:51 +02:00
|
|
|
provider: "{{ connection }}"
|
2017-12-20 12:38:29 +01:00
|
|
|
register: result
|
|
|
|
|
2018-11-16 05:03:22 +01:00
|
|
|
- assert: *true
|
2017-12-20 12:38:29 +01:00
|
|
|
|
|
|
|
- name: configure static route aggregate(Idempotence)
|
|
|
|
nxos_static_route: *conf_agg
|
|
|
|
register: result
|
|
|
|
|
2018-11-16 05:03:22 +01:00
|
|
|
- assert: *false
|
2017-12-20 12:38:29 +01:00
|
|
|
|
|
|
|
- name: remove static route aggregate
|
|
|
|
nxos_static_route: &remove_agg
|
|
|
|
aggregate:
|
2018-05-30 19:03:20 +02:00
|
|
|
- { prefix: "192.168.22.64/24", next_hop: "192.0.2.3" }
|
|
|
|
- { prefix: "192.168.24.64/24", next_hop: "192.0.2.3" }
|
2018-07-02 15:43:51 +02:00
|
|
|
provider: "{{ connection }}"
|
2017-12-20 12:38:29 +01:00
|
|
|
state: absent
|
|
|
|
register: result
|
|
|
|
|
2018-11-16 05:03:22 +01:00
|
|
|
- assert: *true
|
2017-12-20 12:38:29 +01:00
|
|
|
|
|
|
|
- name: remove static route aggregate(Idempotence)
|
|
|
|
nxos_static_route: *remove_agg
|
|
|
|
register: result
|
|
|
|
|
2018-11-16 05:03:22 +01:00
|
|
|
- assert: *false
|
2017-12-20 12:38:29 +01:00
|
|
|
|
2017-10-26 17:27:55 +02:00
|
|
|
always:
|
2018-11-16 05:03:22 +01:00
|
|
|
- name: remove track
|
|
|
|
nxos_config:
|
|
|
|
lines:
|
|
|
|
- no track 1
|
|
|
|
provider: "{{ connection }}"
|
|
|
|
ignore_errors: yes
|
2018-12-04 05:27:35 +01:00
|
|
|
when: test_track_feature
|
2018-11-16 05:03:22 +01:00
|
|
|
|
2019-03-21 14:22:46 +01:00
|
|
|
- name: teardown test routes
|
|
|
|
nxos_static_route: *setup_teardown
|
2018-03-26 17:13:32 +02:00
|
|
|
with_items: "{{ vrfs }}"
|
2017-10-26 17:27:55 +02:00
|
|
|
ignore_errors: yes
|
|
|
|
|
2018-01-05 18:39:04 +01:00
|
|
|
- debug: msg="END connection={{ ansible_connection }} nxos_static_route sanity test"
|