mirror of https://github.com/ansible/ansible.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
137 lines
3.6 KiB
YAML
137 lines
3.6 KiB
YAML
6 years ago
|
---
|
||
|
#- debug: msg="START cnos cli/cnos_static_route.yaml on connection={{ ansible_connection }}"
|
||
|
|
||
|
- name: Clear all static routes
|
||
|
cnos_static_route: &delete_all
|
||
|
aggregate:
|
||
|
- { prefix: 10.241.107.0 }
|
||
|
- { prefix: 10.241.106.0 }
|
||
|
- { prefix: 10.241.105.0 }
|
||
|
- { prefix: 10.241.108.0 }
|
||
|
mask: 255.255.255.0
|
||
|
next_hop: 10.241.100.100
|
||
|
state: absent
|
||
|
|
||
|
- name: create static route
|
||
|
cnos_static_route:
|
||
|
prefix: 10.241.107.0
|
||
|
mask: 255.255.255.0
|
||
|
next_hop: 10.241.100.100
|
||
|
state: present
|
||
|
register: result
|
||
|
|
||
|
- assert:
|
||
|
that:
|
||
|
- 'result.changed == true'
|
||
|
- 'result.commands == ["ip route 10.241.107.0 255.255.255.0 10.241.100.100 1"]'
|
||
|
|
||
|
- name: Verify idempotence with default admin_distance
|
||
|
cnos_static_route:
|
||
|
prefix: 10.241.107.0
|
||
|
mask: 255.255.255.0
|
||
|
next_hop: 10.241.100.100
|
||
|
admin_distance: 1
|
||
|
state: present
|
||
|
register: result
|
||
|
|
||
|
- assert:
|
||
|
that:
|
||
|
- 'result.changed == true'
|
||
|
|
||
|
- name: modify admin distance of static route
|
||
|
cnos_static_route: &admin2
|
||
|
prefix: 10.241.107.0
|
||
|
mask: 255.255.255.0
|
||
|
next_hop: 10.241.100.100
|
||
|
admin_distance: 2
|
||
|
state: present
|
||
|
register: result
|
||
|
|
||
|
- assert:
|
||
|
that:
|
||
|
- 'result.changed == true'
|
||
|
- 'result.commands == ["ip route 10.241.107.0 255.255.255.0 10.241.100.100 2"]'
|
||
|
|
||
|
- name: modify admin distance of static route again (idempotent)
|
||
|
cnos_static_route: *admin2
|
||
|
register: result
|
||
|
|
||
|
- assert:
|
||
|
that:
|
||
|
- 'result.changed == true'
|
||
|
|
||
|
- name: Verify idempotence with unspecified admin_distance
|
||
|
cnos_static_route:
|
||
|
prefix: 10.241.107.0
|
||
|
mask: 255.255.255.0
|
||
|
next_hop: 10.241.100.100
|
||
|
state: present
|
||
|
register: result
|
||
|
|
||
|
- assert:
|
||
|
that:
|
||
|
- 'result.changed == true'
|
||
|
|
||
|
- name: delete static route
|
||
|
cnos_static_route: &delete
|
||
|
prefix: 10.241.107.0
|
||
|
mask: 255.255.255.0
|
||
|
next_hop: 10.241.100.100
|
||
|
state: absent
|
||
|
register: result
|
||
|
|
||
|
- assert:
|
||
|
that:
|
||
|
- 'result.changed == true'
|
||
|
- 'result.commands == ["no ip route 10.241.107.0 255.255.255.0 10.241.100.100 1"]'
|
||
|
|
||
|
- name: delete static route again (idempotent)
|
||
|
cnos_static_route: *delete
|
||
|
register: result
|
||
|
|
||
|
- assert:
|
||
|
that:
|
||
|
- 'result.changed == true'
|
||
|
|
||
|
- name: Add static route aggregates
|
||
|
cnos_static_route:
|
||
|
aggregate:
|
||
|
- { prefix: 10.241.106.0 }
|
||
|
- { prefix: 10.241.105.0 }
|
||
|
mask: 255.255.255.0
|
||
|
next_hop: 10.241.100.100
|
||
|
state: present
|
||
|
register: result
|
||
|
|
||
|
- assert:
|
||
|
that:
|
||
|
- 'result.changed == true'
|
||
|
- 'result.commands == ["ip route 10.241.106.0 255.255.255.0 10.241.100.100 1", "ip route 10.241.105.0 255.255.255.0 10.241.100.100 1"]'
|
||
|
|
||
|
- name: Add and remove static route aggregates with overrides
|
||
|
cnos_static_route:
|
||
|
aggregate:
|
||
|
- { prefix: 10.241.106.0 }
|
||
|
- { prefix: 10.241.105.0, state: absent }
|
||
|
- { prefix: 10.241.108.0 }
|
||
|
mask: 255.255.255.0
|
||
|
next_hop: 10.241.100.100
|
||
|
state: present
|
||
|
register: result
|
||
|
|
||
|
- assert:
|
||
|
that:
|
||
|
- 'result.changed == true'
|
||
|
- 'result.commands == ["ip route 10.241.106.0 255.255.255.0 10.241.100.100 1", "no ip route 10.241.105.0 255.255.255.0 10.241.100.100 1", "ip route 10.241.108.0 255.255.255.0 10.241.100.100 1"]'
|
||
|
|
||
|
- name: Remove static route aggregates
|
||
|
cnos_static_route: *delete_all
|
||
|
register: result
|
||
|
|
||
|
- assert:
|
||
|
that:
|
||
|
- 'result.changed == true'
|
||
|
- 'result.commands == ["no ip route 10.241.107.0 255.255.255.0 10.241.100.100 1","no ip route 10.241.106.0 255.255.255.0 10.241.100.100 1","no ip route 10.241.105.0 255.255.255.0 10.241.100.100 1" ,"no ip route 10.241.108.0 255.255.255.0 10.241.100.100 1"]'
|
||
|
|
||
|
#- debug: msg="END cnos cli/cnos_static_route.yaml on connection={{ ansible_connection }}"
|