mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
c8ba8bdd6d
* Add ios_static_route module * Add ios_static_route integration tests * Add platform agnostic integration tests for IOS * Replace unicode function to ansible module_utils to_text * Add collections handling logic * Add integration tests for collections * Make collections and prefix mutually exclusive * Add net_static_route integration tests for collections * Do not store load_config return value, as it returns nothing
138 lines
3.5 KiB
YAML
138 lines
3.5 KiB
YAML
---
|
|
- 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
|
|
authorize: yes
|
|
provider: "{{ cli }}"
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- 'result.changed == true'
|
|
- 'result.commands == ["ip route 172.16.31.0 255.255.255.0 10.0.0.8 1"]'
|
|
|
|
- name: create static route again (idempotent)
|
|
ios_static_route:
|
|
prefix: 172.16.31.0
|
|
mask: 255.255.255.0
|
|
next_hop: 10.0.0.8
|
|
state: present
|
|
authorize: yes
|
|
provider: "{{ cli }}"
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- 'result.changed == false'
|
|
|
|
- name: modify admin distance of static route
|
|
ios_static_route:
|
|
prefix: 172.16.31.0
|
|
mask: 255.255.255.0
|
|
next_hop: 10.0.0.8
|
|
admin_distance: 2
|
|
state: present
|
|
authorize: yes
|
|
provider: "{{ cli }}"
|
|
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)
|
|
ios_static_route:
|
|
prefix: 172.16.31.0
|
|
mask: 255.255.255.0
|
|
next_hop: 10.0.0.8
|
|
admin_distance: 2
|
|
state: present
|
|
authorize: yes
|
|
provider: "{{ cli }}"
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- 'result.changed == false'
|
|
|
|
- name: delete static route
|
|
ios_static_route:
|
|
prefix: 172.16.31.0
|
|
mask: 255.255.255.0
|
|
next_hop: 10.0.0.8
|
|
admin_distance: 2
|
|
state: absent
|
|
authorize: yes
|
|
provider: "{{ cli }}"
|
|
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)
|
|
ios_static_route:
|
|
prefix: 172.16.31.0
|
|
mask: 255.255.255.0
|
|
next_hop: 10.0.0.8
|
|
admin_distance: 2
|
|
state: absent
|
|
authorize: yes
|
|
provider: "{{ cli }}"
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- 'result.changed == false'
|
|
|
|
- name: Add static route collections
|
|
ios_static_route:
|
|
collection:
|
|
- { prefix: 172.16.32.0, mask: 255.255.255.0, next_hop: 10.0.0.8 }
|
|
- { prefix: 172.16.33.0, mask: 255.255.255.0, next_hop: 10.0.0.8 }
|
|
state: present
|
|
authorize: yes
|
|
provider: "{{ cli }}"
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- 'result.changed == true'
|
|
- 'result.commands == ["ip route 172.16.32.0 255.255.255.0 10.0.0.8 1", "ip route 172.16.33.0 255.255.255.0 10.0.0.8 1"]'
|
|
|
|
- name: Add and remove static route collections with overrides
|
|
ios_static_route:
|
|
collection:
|
|
- { prefix: 172.16.32.0, mask: 255.255.255.0, next_hop: 10.0.0.8 }
|
|
- { prefix: 172.16.33.0, mask: 255.255.255.0, next_hop: 10.0.0.8, state: absent }
|
|
- { prefix: 172.16.34.0, mask: 255.255.255.0, next_hop: 10.0.0.8 }
|
|
state: present
|
|
authorize: yes
|
|
provider: "{{ cli }}"
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- 'result.changed == true'
|
|
- '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 1"]'
|
|
|
|
- name: Remove static route collections
|
|
ios_static_route:
|
|
collection:
|
|
- { prefix: 172.16.32.0, mask: 255.255.255.0, next_hop: 10.0.0.8 }
|
|
- { prefix: 172.16.33.0, mask: 255.255.255.0, next_hop: 10.0.0.8 }
|
|
- { prefix: 172.16.34.0, mask: 255.255.255.0, next_hop: 10.0.0.8 }
|
|
state: absent
|
|
authorize: yes
|
|
provider: "{{ cli }}"
|
|
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"]'
|