mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 21:00:22 -07:00
Add net_interface declarative module (#25766)
* Add net_interface declartive module * Add net_interface module * Add junos_interface implementation module * Other minor changes * Add integration test * Integration test for net_interface * Integration test for junos_interface * Fix CI failures * Documentation changes
This commit is contained in:
parent
e7deb07a87
commit
2ff464c949
24 changed files with 751 additions and 16 deletions
1
test/integration/targets/junos_interface/aliases
Normal file
1
test/integration/targets/junos_interface/aliases
Normal file
|
@ -0,0 +1 @@
|
|||
network/ci
|
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
testcase: "*"
|
2
test/integration/targets/junos_interface/tasks/main.yaml
Normal file
2
test/integration/targets/junos_interface/tasks/main.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
- { include: netconf.yaml, tags: ['netconf'] }
|
16
test/integration/targets/junos_interface/tasks/netconf.yaml
Normal file
16
test/integration/targets/junos_interface/tasks/netconf.yaml
Normal file
|
@ -0,0 +1,16 @@
|
|||
---
|
||||
- name: collect all netconf test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/netconf"
|
||||
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
|
|
@ -0,0 +1,130 @@
|
|||
---
|
||||
- debug: msg="START junos_interface netconf/basic.yaml"
|
||||
|
||||
- name: setup - remove interface
|
||||
junos_interface:
|
||||
name: ge-0/0/1
|
||||
description: test-interface
|
||||
state: absent
|
||||
provider: "{{ netconf }}"
|
||||
|
||||
- name: Create interface
|
||||
junos_interface:
|
||||
name: ge-0/0/1
|
||||
description: test-interface
|
||||
state: present
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- debug:
|
||||
msg: "{{ result }}"
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'<name>ge-0/0/1</name>' in result.rpc"
|
||||
- "'<description>test-interface</description>' in result.rpc"
|
||||
|
||||
- name: Create interface (idempotent)
|
||||
junos_interface:
|
||||
name: ge-0/0/1
|
||||
description: test-interface
|
||||
state: present
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: Deactivate interface configuration
|
||||
junos_interface:
|
||||
name: ge-0/0/1
|
||||
description: test-interface
|
||||
state: suspend
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'<interface inactive=\"inactive\">' in result.rpc"
|
||||
- "'<name>ge-0/0/1</name>' in result.rpc"
|
||||
|
||||
- name: Activate interface configuration
|
||||
junos_interface:
|
||||
name: ge-0/0/1
|
||||
description: test-interface
|
||||
state: active
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'<interface active=\"active\">' in result.rpc"
|
||||
- "'<name>ge-0/0/1</name>' in result.rpc"
|
||||
|
||||
- name: Configure interface attributes
|
||||
junos_interface:
|
||||
name: ge-0/0/1
|
||||
description: test-interface
|
||||
state: present
|
||||
speed: 1g
|
||||
mtu: 256
|
||||
duplex: full
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'<name>ge-0/0/1</name>' in result.rpc"
|
||||
- "'<link-mode>full-duplex</link-mode>' in result.rpc"
|
||||
- "'<mtu>256</mtu>' in result.rpc"
|
||||
- "'<speed>1g</speed>' in result.rpc"
|
||||
- "'<description>test-interface</description>' in result.rpc"
|
||||
|
||||
- name: Disable interface
|
||||
junos_interface:
|
||||
name: ge-0/0/1
|
||||
description: test-interface
|
||||
state: present
|
||||
enabled: False
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'<disable />' in result.rpc"
|
||||
- "'<name>ge-0/0/1</name>' in result.rpc"
|
||||
|
||||
- name: Enable interface
|
||||
junos_interface:
|
||||
name: ge-0/0/1
|
||||
description: test-interface
|
||||
state: present
|
||||
enabled: True
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'<disable delete=\"delete\" />' in result.rpc"
|
||||
- "'<name>ge-0/0/1</name>' in result.rpc"
|
||||
|
||||
- name: Delete interface
|
||||
junos_interface:
|
||||
name: ge-0/0/1
|
||||
description: test-interface
|
||||
state: absent
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'<interface operation=\"delete\">' in result.rpc"
|
||||
- "'<name>ge-0/0/1</name>' in result.rpc"
|
Loading…
Add table
Add a link
Reference in a new issue