1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Fix issues related to track feature (#49454)

This commit is contained in:
Mike Wiebe 2018-12-03 23:27:35 -05:00 committed by Trishna Guha
parent d20d66dc2f
commit dd984709f5
2 changed files with 28 additions and 8 deletions

View file

@ -153,7 +153,7 @@ def get_configured_track(module, ctrack):
track_exists = False track_exists = False
command = 'show track' command = 'show track'
try: try:
body = run_commands(module, [command]) body = run_commands(module, {'command': command, 'output': 'text'})
match = re.findall(r'Track\s+(\d+)', body[0]) match = re.findall(r'Track\s+(\d+)', body[0])
except IndexError: except IndexError:
return None return None

View file

@ -3,13 +3,26 @@
- debug: msg="Using provider={{ connection.transport }}" - debug: msg="Using provider={{ connection.transport }}"
when: ansible_connection == "local" when: ansible_connection == "local"
- block: # Flag used to test the track feature. Some platforms
- name: configure track # don't support it so this flag will be toggled accordingly.
nxos_config: - set_fact: test_track_feature="true"
lines:
- track 1 ip sla 1
provider: "{{ connection }}"
- 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 }}"
- set_fact: test_track_feature="false"
when: cmd_result.failed
- debug: msg="Test Track Feature {{ test_track_feature }}"
- block:
- name: create static route - name: create static route
nxos_static_route: &configure_static nxos_static_route: &configure_static
prefix: "192.168.20.64/24" prefix: "192.168.20.64/24"
@ -68,18 +81,22 @@
provider: "{{ connection }}" provider: "{{ connection }}"
with_items: "{{ vrfs }}" with_items: "{{ vrfs }}"
register: result register: result
when: test_track_feature
- assert: *true - assert: *true
when: test_track_feature
- name: "Config track Idempotence" - name: "Config track Idempotence"
nxos_static_route: *config_static_track nxos_static_route: *config_static_track
with_items: "{{ vrfs }}" with_items: "{{ vrfs }}"
register: result register: result
when: test_track_feature
- assert: *false - assert: *false
when: test_track_feature
- name: configure static route with not configured track - name: configure static route with not configured track
nxos_static_route: &config_static_track nxos_static_route:
prefix: "192.168.20.64/24" prefix: "192.168.20.64/24"
next_hop: "192.0.2.3" next_hop: "192.0.2.3"
route_name: default route_name: default
@ -91,10 +108,12 @@
with_items: "{{ vrfs }}" with_items: "{{ vrfs }}"
register: result register: result
ignore_errors: yes ignore_errors: yes
when: test_track_feature
- assert: - assert:
that: that:
- "result.failed == True" - "result.failed == True"
when: test_track_feature
- name: remove static route - name: remove static route
nxos_static_route: &remove_static nxos_static_route: &remove_static
@ -157,6 +176,7 @@
- no track 1 - no track 1
provider: "{{ connection }}" provider: "{{ connection }}"
ignore_errors: yes ignore_errors: yes
when: test_track_feature
- name: remove static route - name: remove static route
nxos_static_route: nxos_static_route: