mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-23 12:33:59 -07:00
Platform agnostic module for VRFs (#25383)
* WIP VRF platform agnostic module * Fixed examples refering vlans instead of vrfs * Add integration tests
This commit is contained in:
parent
d83f254bb6
commit
72e65e4290
9 changed files with 246 additions and 0 deletions
1
test/integration/targets/net_vrf/aliases
Normal file
1
test/integration/targets/net_vrf/aliases
Normal file
|
@ -0,0 +1 @@
|
|||
network/ci
|
2
test/integration/targets/net_vrf/defaults/main.yaml
Normal file
2
test/integration/targets/net_vrf/defaults/main.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
testcase: "*"
|
16
test/integration/targets/net_vrf/tasks/cli.yaml
Normal file
16
test/integration/targets/net_vrf/tasks/cli.yaml
Normal file
|
@ -0,0 +1,16 @@
|
|||
---
|
||||
- name: collect all cli test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/cli"
|
||||
patterns: "{{ testcase }}.yaml"
|
||||
register: test_cases
|
||||
delegate_to: localhost
|
||||
|
||||
- name: set test_items
|
||||
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
|
||||
|
||||
- name: run test case
|
||||
include: "{{ test_case_to_run }}"
|
||||
with_items: "{{ test_items }}"
|
||||
loop_control:
|
||||
loop_var: test_case_to_run
|
2
test/integration/targets/net_vrf/tasks/main.yaml
Normal file
2
test/integration/targets/net_vrf/tasks/main.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
- { include: cli.yaml, tags: ['cli'] }
|
7
test/integration/targets/net_vrf/tests/cli/basic.yaml
Normal file
7
test/integration/targets/net_vrf/tests/cli/basic.yaml
Normal file
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
- debug: msg="START cli/set_name_servers.yaml"
|
||||
|
||||
- include: "{{ role_path }}/tests/eos/basic.yaml"
|
||||
when: hostvars[inventory_hostname]['ansible_network_os'] == 'eos'
|
||||
|
||||
- debug: msg="END cli/set_name_servers.yaml"
|
116
test/integration/targets/net_vrf/tests/eos/basic.yaml
Normal file
116
test/integration/targets/net_vrf/tests/eos/basic.yaml
Normal file
|
@ -0,0 +1,116 @@
|
|||
---
|
||||
|
||||
- name: setup - remove vrf
|
||||
eos_vrf:
|
||||
name: test
|
||||
state: absent
|
||||
authorize: yes
|
||||
provider: "{{ cli }}"
|
||||
|
||||
- name: Create vrf
|
||||
net_vrf:
|
||||
name: test
|
||||
rd: 1:200
|
||||
state: present
|
||||
authorize: yes
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'vrf definition test' in result.commands"
|
||||
- "'rd 1:200' in result.commands"
|
||||
# Ensure sessions contains epoc. Will fail after 18th May 2033
|
||||
- "'ansible_1' in result.session_name"
|
||||
|
||||
- name: Create vrf again (idempotent)
|
||||
net_vrf:
|
||||
name: test
|
||||
rd: 1:200
|
||||
state: present
|
||||
authorize: yes
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.commands | length == 0"
|
||||
# Ensure sessions contains epoc. Will fail after 18th May 2033
|
||||
- "result.session_name is not defined"
|
||||
|
||||
- name: Modify rd
|
||||
net_vrf:
|
||||
name: test
|
||||
rd: 1:201
|
||||
state: present
|
||||
authorize: yes
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'vrf definition test' in result.commands"
|
||||
- "'rd 1:201' in result.commands"
|
||||
# Ensure sessions contains epoc. Will fail after 18th May 2033
|
||||
- "'ansible_1' in result.session_name"
|
||||
|
||||
- name: Modify rd again (idempotent)
|
||||
net_vrf:
|
||||
name: test
|
||||
rd: 1:201
|
||||
state: present
|
||||
authorize: yes
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.commands | length == 0"
|
||||
# Ensure sessions contains epoc. Will fail after 18th May 2033
|
||||
- "result.session_name is not defined"
|
||||
|
||||
- name: Add Ethernet2 to vrf
|
||||
net_vrf:
|
||||
name: test
|
||||
rd: 1:201
|
||||
state: present
|
||||
authorize: yes
|
||||
interfaces:
|
||||
- Ethernet2
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'interface Ethernet2' in result.commands"
|
||||
- "'vrf forwarding test' in result.commands"
|
||||
# Ensure sessions contains epoc. Will fail after 18th May 2033
|
||||
- "'ansible_1' in result.session_name"
|
||||
|
||||
- name: Add Ethernet2 to vrf again (idempotent)
|
||||
net_vrf:
|
||||
name: test
|
||||
rd: 1:201
|
||||
state: present
|
||||
authorize: yes
|
||||
interfaces:
|
||||
- Ethernet2
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.commands | length == 0"
|
||||
# Ensure sessions contains epoc. Will fail after 18th May 2033
|
||||
- "result.session_name is not defined"
|
||||
|
||||
|
||||
# FIXME add in tests for everything defined in docs
|
||||
# FIXME Test state:absent + test:
|
||||
# FIXME Without powers ensure "privileged mode required"
|
Loading…
Add table
Add a link
Reference in a new issue