mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 14:22:46 +00:00
junos implementation for net_l3_interface module (#26829)
* junos implementation for net_l3_interface module * junos_l3_interface implementation * junos_l3_interface integration test * net_l3_interface integration test for junos * Fix module name typo
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
---
|
||||
testcase: "*"
|
||||
@@ -0,0 +1,2 @@
|
||||
---
|
||||
- { include: netconf.yaml, tags: ['netconf'] }
|
||||
@@ -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,129 @@
|
||||
---
|
||||
- debug: msg="START junos_l3_interface netconf/basic.yaml"
|
||||
|
||||
- name: setup - remove interface address
|
||||
junos_l3_interface:
|
||||
name: ge-0/0/1
|
||||
ipv4: 1.1.1.1
|
||||
ipv6: fd5d:12c9:2201:1::1
|
||||
state: absent
|
||||
provider: "{{ netconf }}"
|
||||
|
||||
- name: Configure interface address
|
||||
junos_l3_interface:
|
||||
name: ge-0/0/1
|
||||
ipv4: 1.1.1.1
|
||||
ipv6: fd5d:12c9:2201:1::1
|
||||
state: present
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- name: Get running configuration
|
||||
junos_rpc:
|
||||
rpc: get-configuration
|
||||
provider: "{{ netconf }}"
|
||||
register: config
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'<name>1.1.1.1/32</name>' in config.xml"
|
||||
- "'<name>fd5d:12c9:2201:1::1/128</name>' in config.xml"
|
||||
- "'+ address 1.1.1.1/32;' in result.diff.prepared"
|
||||
- "'+ address fd5d:12c9:2201:1::1/128;' in result.diff.prepared"
|
||||
|
||||
- name: Configure interface address (idempotent)
|
||||
junos_l3_interface:
|
||||
name: ge-0/0/1
|
||||
ipv4: 1.1.1.1
|
||||
ipv6: fd5d:12c9:2201:1::1
|
||||
state: present
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: Deactivate interface address
|
||||
junos_l3_interface:
|
||||
name: ge-0/0/1
|
||||
ipv4: 1.1.1.1
|
||||
ipv6: fd5d:12c9:2201:1::1
|
||||
state: present
|
||||
active: False
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- name: Get running configuration
|
||||
junos_rpc:
|
||||
rpc: get-configuration
|
||||
provider: "{{ netconf }}"
|
||||
register: config
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'<address inactive=\"inactive\">' in config.xml"
|
||||
- "'! inactive: address 1.1.1.1/32' in result.diff.prepared"
|
||||
- "'! inactive: address fd5d:12c9:2201:1::1/128' in result.diff.prepared"
|
||||
|
||||
- name: Activate interface address
|
||||
junos_l3_interface:
|
||||
name: ge-0/0/1
|
||||
ipv4: 1.1.1.1
|
||||
ipv6: fd5d:12c9:2201:1::1
|
||||
state: present
|
||||
active: True
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- name: Get running configuration
|
||||
junos_rpc:
|
||||
rpc: get-configuration
|
||||
provider: "{{ netconf }}"
|
||||
register: config
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'<name>1.1.1.1/32</name>' in config.xml"
|
||||
- "'<name>fd5d:12c9:2201:1::1/128</name>' in config.xml"
|
||||
- "'! active: address 1.1.1.1/32' in result.diff.prepared"
|
||||
- "'! active: address fd5d:12c9:2201:1::1/128' in result.diff.prepared"
|
||||
|
||||
- name: Delete interface address
|
||||
junos_l3_interface:
|
||||
name: ge-0/0/1
|
||||
ipv4: 1.1.1.1
|
||||
ipv6: fd5d:12c9:2201:1::1
|
||||
state: absent
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- name: Get running configuration
|
||||
junos_rpc:
|
||||
rpc: get-configuration
|
||||
provider: "{{ netconf }}"
|
||||
register: config
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'<name>1.1.1.1/32</name>' not in config.xml"
|
||||
- "'<name>fd5d:12c9:2201:1::1/128</name>' not in config.xml"
|
||||
- "'- address 1.1.1.1/32;' in result.diff.prepared"
|
||||
- "'- address fd5d:12c9:2201:1::1/128;' in result.diff.prepared"
|
||||
|
||||
- name: Delete interface address (idempotent)
|
||||
junos_l3_interface:
|
||||
name: ge-0/0/1
|
||||
ipv4: 1.1.1.1
|
||||
ipv6: fd5d:12c9:2201:1::1
|
||||
state: absent
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
@@ -0,0 +1,2 @@
|
||||
---
|
||||
testcase: "*"
|
||||
16
test/integration/targets/net_l3_interface/tasks/cli.yaml
Normal file
16
test/integration/targets/net_l3_interface/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
|
||||
@@ -0,0 +1,3 @@
|
||||
---
|
||||
- { include: cli.yaml, tags: ['cli'] }
|
||||
- { include: netconf.yaml, tags: ['netconf'] }
|
||||
16
test/integration/targets/net_l3_interface/tasks/netconf.yaml
Normal file
16
test/integration/targets/net_l3_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,4 @@
|
||||
---
|
||||
|
||||
- include: "{{ role_path }}/tests/eos/basic.yaml"
|
||||
when: hostvars[inventory_hostname]['ansible_network_os'] == 'eos'
|
||||
@@ -0,0 +1,2 @@
|
||||
---
|
||||
- debug: msg="START net_l3_interface eos/basic.yaml"
|
||||
@@ -0,0 +1,82 @@
|
||||
---
|
||||
- debug: msg="START net_l3_interface junos/basic.yaml"
|
||||
|
||||
- name: setup - remove interface address
|
||||
net_l3_interface:
|
||||
name: ge-0/0/1
|
||||
ipv4: 1.1.1.1
|
||||
ipv6: fd5d:12c9:2201:1::1
|
||||
state: absent
|
||||
provider: "{{ netconf }}"
|
||||
|
||||
- name: Configure interface address
|
||||
net_l3_interface:
|
||||
name: ge-0/0/1
|
||||
ipv4: 1.1.1.1
|
||||
ipv6: fd5d:12c9:2201:1::1
|
||||
state: present
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- name: Get running configuration
|
||||
junos_rpc:
|
||||
rpc: get-configuration
|
||||
provider: "{{ netconf }}"
|
||||
register: config
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'<name>1.1.1.1/32</name>' in config.xml"
|
||||
- "'<name>fd5d:12c9:2201:1::1/128</name>' in config.xml"
|
||||
- "'+ address 1.1.1.1/32;' in result.diff.prepared"
|
||||
- "'+ address fd5d:12c9:2201:1::1/128;' in result.diff.prepared"
|
||||
|
||||
- name: Configure interface address (idempotent)
|
||||
net_l3_interface:
|
||||
name: ge-0/0/1
|
||||
ipv4: 1.1.1.1
|
||||
ipv6: fd5d:12c9:2201:1::1
|
||||
state: present
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: Delete interface address
|
||||
net_l3_interface:
|
||||
name: ge-0/0/1
|
||||
ipv4: 1.1.1.1
|
||||
ipv6: fd5d:12c9:2201:1::1
|
||||
state: absent
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- name: Get running configuration
|
||||
junos_rpc:
|
||||
rpc: get-configuration
|
||||
provider: "{{ netconf }}"
|
||||
register: config
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'<name>1.1.1.1/32</name>' not in config.xml"
|
||||
- "'<name>fd5d:12c9:2201:1::1/128</name>' not in config.xml"
|
||||
- "'- address 1.1.1.1/32;' in result.diff.prepared"
|
||||
- "'- address fd5d:12c9:2201:1::1/128;' in result.diff.prepared"
|
||||
|
||||
- name: Delete interface address (idempotent)
|
||||
net_l3_interface:
|
||||
name: ge-0/0/1
|
||||
ipv4: 1.1.1.1
|
||||
ipv6: fd5d:12c9:2201:1::1
|
||||
state: absent
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
@@ -0,0 +1,3 @@
|
||||
---
|
||||
- include: "{{ role_path }}/tests/junos/basic.yaml"
|
||||
when: hostvars[inventory_hostname]['ansible_network_os'] == 'junos'
|
||||
Reference in New Issue
Block a user