--- - debug: msg="START connection={{ ansible_connection }} nxos_static_route sanity test" - debug: msg="Using provider={{ connection.transport }}" when: ansible_connection == "local" - block: - name: configure track nxos_config: lines: - track 1 ip sla 1 provider: "{{ connection }}" - name: create static route nxos_static_route: &configure_static prefix: "192.168.20.64/24" next_hop: "192.0.2.3" route_name: testing pref: 100 tag: 5500 vrf: "{{ item }}" provider: "{{ connection }}" with_items: "{{ vrfs }}" register: result - assert: &true that: - "result.changed == true" - name: "Conf static Idempotence" nxos_static_route: *configure_static with_items: "{{ vrfs }}" register: result - assert: &false that: - "result.changed == false" - name: change static route 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 prefix: "192.168.20.64/24" next_hop: "192.0.2.3" route_name: default pref: 10 tag: default track: 1 vrf: "{{ item }}" provider: "{{ connection }}" with_items: "{{ vrfs }}" register: result - assert: *true - name: "Config track Idempotence" nxos_static_route: *config_static_track with_items: "{{ vrfs }}" register: result - assert: *false - name: configure static route with not configured track nxos_static_route: &config_static_track 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 - assert: that: - "result.failed == True" - name: remove static route nxos_static_route: &remove_static prefix: "192.168.20.64/24" next_hop: "192.0.2.3" route_name: testing pref: 100 vrf: "{{ item }}" provider: "{{ connection }}" state: absent with_items: "{{ vrfs }}" register: result - assert: *true - name: "Remove Idempotence" nxos_static_route: *remove_static with_items: "{{ vrfs }}" register: result - assert: *false - name: configure static route(aggregate) nxos_static_route: &conf_agg aggregate: - { prefix: "192.168.22.64/24", next_hop: "192.0.2.3" } - { prefix: "192.168.24.64/24", next_hop: "192.0.2.3" } provider: "{{ connection }}" register: result - assert: *true - name: configure static route aggregate(Idempotence) nxos_static_route: *conf_agg register: result - assert: *false - name: remove static route aggregate nxos_static_route: &remove_agg aggregate: - { prefix: "192.168.22.64/24", next_hop: "192.0.2.3" } - { prefix: "192.168.24.64/24", next_hop: "192.0.2.3" } provider: "{{ connection }}" state: absent register: result - assert: *true - name: remove static route aggregate(Idempotence) nxos_static_route: *remove_agg register: result - assert: *false always: - name: remove track nxos_config: lines: - no track 1 provider: "{{ connection }}" ignore_errors: yes - name: remove static route nxos_static_route: prefix: "192.168.20.64/24" next_hop: "192.0.2.3" route_name: testing pref: 100 tag: 5500 vrf: "{{ item }}" provider: "{{ connection }}" state: absent with_items: "{{ vrfs }}" ignore_errors: yes - name: remove static route aggregate nxos_static_route: aggregate: - { prefix: "192.168.22.64/24", next_hop: "192.0.2.3" } - { prefix: "192.168.24.64/24", next_hop: "192.0.2.3" } provider: "{{ connection }}" state: absent ignore_errors: yes - debug: msg="END connection={{ ansible_connection }} nxos_static_route sanity test"