mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-25 07:56:38 +00:00
junos implementation of net_lldp (#26872)
* junos_lldp module * junos_lldp integration test * net_lldp integration test for junos * Other minor changes
This commit is contained in:
@@ -120,6 +120,13 @@
|
||||
rescue:
|
||||
- set_fact: test_failed=true
|
||||
|
||||
- block:
|
||||
- include_role:
|
||||
name: junos_lldp
|
||||
when: "limit_to in ['*', 'junos_lldp']"
|
||||
rescue:
|
||||
- set_fact: test_failed=true
|
||||
|
||||
###########
|
||||
- name: Has any previous test failed?
|
||||
fail:
|
||||
|
||||
@@ -145,7 +145,7 @@
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'<disable/>' not in config.xml"
|
||||
- "'[edit interfaces ge-0/0/1]\n- disable;' in result.diff.prepared"
|
||||
- "'<name>ge-0/0/1</name>' in config.xml"
|
||||
|
||||
- name: Delete interface
|
||||
|
||||
2
test/integration/targets/junos_lldp/defaults/main.yaml
Normal file
2
test/integration/targets/junos_lldp/defaults/main.yaml
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
testcase: "*"
|
||||
2
test/integration/targets/junos_lldp/tasks/main.yaml
Normal file
2
test/integration/targets/junos_lldp/tasks/main.yaml
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
- { include: netconf.yaml, tags: ['netconf'] }
|
||||
16
test/integration/targets/junos_lldp/tasks/netconf.yaml
Normal file
16
test/integration/targets/junos_lldp/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
|
||||
49
test/integration/targets/junos_lldp/tests/netconf/basic.yaml
Normal file
49
test/integration/targets/junos_lldp/tests/netconf/basic.yaml
Normal file
@@ -0,0 +1,49 @@
|
||||
---
|
||||
- debug: msg="START junos_lldp netconf/basic.yaml"
|
||||
|
||||
- name: setup - remove lldp
|
||||
junos_lldp:
|
||||
state: absent
|
||||
provider: "{{ netconf }}"
|
||||
|
||||
- name: configure lldp
|
||||
junos_lldp:
|
||||
state: present
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'[edit]\n- protocols {\n- lldp {\n- disable;\n- }\n- }' in result.diff.prepared"
|
||||
|
||||
- name: configure lldp (idempotent)
|
||||
junos_lldp:
|
||||
state: present
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: Disable lldp
|
||||
junos_lldp:
|
||||
state: absent
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'[edit]\n+ protocols {\n+ lldp {\n+ disable;\n+ }\n+ }' in result.diff.prepared"
|
||||
|
||||
- name: Disable lldp (idempotent)
|
||||
junos_lldp:
|
||||
state: absent
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
50
test/integration/targets/net_lldp/tests/junos/basic.yaml
Normal file
50
test/integration/targets/net_lldp/tests/junos/basic.yaml
Normal file
@@ -0,0 +1,50 @@
|
||||
---
|
||||
- debug: msg="START net_lldp junos/basic.yaml"
|
||||
|
||||
|
||||
- name: setup - remove lldp
|
||||
net_lldp:
|
||||
state: absent
|
||||
provider: "{{ netconf }}"
|
||||
|
||||
- name: configure lldp
|
||||
net_lldp:
|
||||
state: present
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'[edit]\n- protocols {\n- lldp {\n- disable;\n- }\n- }' in result.diff.prepared"
|
||||
|
||||
- name: configure lldp (idempotent)
|
||||
net_lldp:
|
||||
state: present
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: Disable lldp
|
||||
net_lldp:
|
||||
state: absent
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'[edit]\n+ protocols {\n+ lldp {\n+ disable;\n+ }\n+ }' in result.diff.prepared"
|
||||
|
||||
- name: Disable lldp (idempotent)
|
||||
net_lldp:
|
||||
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