2017-06-29 12:05:20 +02:00
|
|
|
---
|
2018-01-25 07:56:17 +01:00
|
|
|
- debug: msg="START ios cli/ios_static_route.yaml on connection={{ ansible_connection }}"
|
|
|
|
|
2018-03-05 15:28:37 +01:00
|
|
|
- name: Clear all static routes
|
|
|
|
ios_static_route: &delete_all
|
|
|
|
aggregate:
|
|
|
|
- { prefix: 172.16.31.0 }
|
|
|
|
- { prefix: 172.16.32.0 }
|
|
|
|
- { prefix: 172.16.33.0 }
|
|
|
|
- { prefix: 172.16.34.0 }
|
2018-01-25 07:56:17 +01:00
|
|
|
mask: 255.255.255.0
|
|
|
|
next_hop: 10.0.0.8
|
|
|
|
state: absent
|
2018-02-02 15:50:15 +01:00
|
|
|
provider: "{{ cli }}"
|
2018-01-25 07:56:17 +01:00
|
|
|
|
2017-06-29 12:05:20 +02:00
|
|
|
- name: create static route
|
|
|
|
ios_static_route:
|
|
|
|
prefix: 172.16.31.0
|
|
|
|
mask: 255.255.255.0
|
|
|
|
next_hop: 10.0.0.8
|
|
|
|
state: present
|
2018-02-02 15:50:15 +01:00
|
|
|
provider: "{{ cli }}"
|
2017-06-29 12:05:20 +02:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == true'
|
2018-03-05 15:28:37 +01:00
|
|
|
- 'result.commands == ["ip route 172.16.31.0 255.255.255.0 10.0.0.8"]'
|
2017-06-29 12:05:20 +02:00
|
|
|
|
2018-03-05 15:28:37 +01:00
|
|
|
- name: Verify idempotence with default admin_distance
|
2017-06-29 12:05:20 +02:00
|
|
|
ios_static_route:
|
|
|
|
prefix: 172.16.31.0
|
|
|
|
mask: 255.255.255.0
|
|
|
|
next_hop: 10.0.0.8
|
2018-03-05 15:28:37 +01:00
|
|
|
admin_distance: 1
|
2017-06-29 12:05:20 +02:00
|
|
|
state: present
|
2018-02-02 15:50:15 +01:00
|
|
|
provider: "{{ cli }}"
|
2017-06-29 12:05:20 +02:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == false'
|
|
|
|
|
|
|
|
- name: modify admin distance of static route
|
2018-03-05 15:28:37 +01:00
|
|
|
ios_static_route: &admin2
|
2017-06-29 12:05:20 +02:00
|
|
|
prefix: 172.16.31.0
|
|
|
|
mask: 255.255.255.0
|
|
|
|
next_hop: 10.0.0.8
|
|
|
|
admin_distance: 2
|
|
|
|
state: present
|
2018-02-02 15:50:15 +01:00
|
|
|
provider: "{{ cli }}"
|
2017-06-29 12:05:20 +02:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == true'
|
|
|
|
- 'result.commands == ["ip route 172.16.31.0 255.255.255.0 10.0.0.8 2"]'
|
|
|
|
|
|
|
|
- name: modify admin distance of static route again (idempotent)
|
2018-03-05 15:28:37 +01:00
|
|
|
ios_static_route: *admin2
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == false'
|
|
|
|
|
|
|
|
- name: Verify idempotence with unspecified admin_distance
|
2017-06-29 12:05:20 +02:00
|
|
|
ios_static_route:
|
|
|
|
prefix: 172.16.31.0
|
|
|
|
mask: 255.255.255.0
|
|
|
|
next_hop: 10.0.0.8
|
|
|
|
state: present
|
2018-02-02 15:50:15 +01:00
|
|
|
provider: "{{ cli }}"
|
2017-06-29 12:05:20 +02:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == false'
|
|
|
|
|
|
|
|
- name: delete static route
|
2018-03-05 15:28:37 +01:00
|
|
|
ios_static_route: &delete
|
2017-06-29 12:05:20 +02:00
|
|
|
prefix: 172.16.31.0
|
|
|
|
mask: 255.255.255.0
|
|
|
|
next_hop: 10.0.0.8
|
|
|
|
state: absent
|
2018-02-02 15:50:15 +01:00
|
|
|
provider: "{{ cli }}"
|
2017-06-29 12:05:20 +02:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == true'
|
|
|
|
- 'result.commands == ["no ip route 172.16.31.0 255.255.255.0 10.0.0.8"]'
|
|
|
|
|
|
|
|
- name: delete static route again (idempotent)
|
2018-03-05 15:28:37 +01:00
|
|
|
ios_static_route: *delete
|
2017-06-29 12:05:20 +02:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == false'
|
|
|
|
|
2017-07-26 16:09:17 +02:00
|
|
|
- name: Add static route aggregates
|
2017-06-29 12:05:20 +02:00
|
|
|
ios_static_route:
|
2017-07-26 16:09:17 +02:00
|
|
|
aggregate:
|
2018-03-05 15:28:37 +01:00
|
|
|
- { prefix: 172.16.32.0 }
|
|
|
|
- { prefix: 172.16.33.0 }
|
|
|
|
mask: 255.255.255.0
|
|
|
|
next_hop: 10.0.0.8
|
2017-06-29 12:05:20 +02:00
|
|
|
state: present
|
2018-02-02 15:50:15 +01:00
|
|
|
provider: "{{ cli }}"
|
2017-06-29 12:05:20 +02:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == true'
|
2018-03-05 15:28:37 +01:00
|
|
|
- 'result.commands == ["ip route 172.16.32.0 255.255.255.0 10.0.0.8", "ip route 172.16.33.0 255.255.255.0 10.0.0.8"]'
|
2017-06-29 12:05:20 +02:00
|
|
|
|
2017-07-26 16:09:17 +02:00
|
|
|
- name: Add and remove static route aggregates with overrides
|
2017-06-29 12:05:20 +02:00
|
|
|
ios_static_route:
|
2017-07-26 16:09:17 +02:00
|
|
|
aggregate:
|
2018-03-05 15:28:37 +01:00
|
|
|
- { prefix: 172.16.32.0 }
|
|
|
|
- { prefix: 172.16.33.0, state: absent }
|
|
|
|
- { prefix: 172.16.34.0 }
|
|
|
|
mask: 255.255.255.0
|
|
|
|
next_hop: 10.0.0.8
|
2017-06-29 12:05:20 +02:00
|
|
|
state: present
|
2018-02-02 15:50:15 +01:00
|
|
|
provider: "{{ cli }}"
|
2017-06-29 12:05:20 +02:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == true'
|
2018-03-05 15:28:37 +01:00
|
|
|
- 'result.commands == ["no ip route 172.16.33.0 255.255.255.0 10.0.0.8", "ip route 172.16.34.0 255.255.255.0 10.0.0.8"]'
|
2017-06-29 12:05:20 +02:00
|
|
|
|
2017-07-26 16:09:17 +02:00
|
|
|
- name: Remove static route aggregates
|
2018-03-05 15:28:37 +01:00
|
|
|
ios_static_route: *delete_all
|
2017-06-29 12:05:20 +02:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == true'
|
|
|
|
- 'result.commands == ["no ip route 172.16.32.0 255.255.255.0 10.0.0.8", "no ip route 172.16.34.0 255.255.255.0 10.0.0.8"]'
|
2018-01-25 07:56:17 +01:00
|
|
|
|
|
|
|
- debug: msg="END ios cli/ios_static_route.yaml on connection={{ ansible_connection }}"
|