mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-23 04:24:00 -07:00
Update netconf_config module (#44379)
Fixes #40650 Fixes #40245 Fixes #41541 * Refactor netconf_config module as per proposal #104 * Update netconf_config module metadata to core network supported * Refactor local connection to use persistent connection framework for backward compatibility * Update netconf connection plugin configuration varaibles (Fixes #40245) * Add support for optional lock feature to Fixes #41541 * Add integration test for netconf_config module * Documentation update * Move deprecated options in netconf_config module
This commit is contained in:
parent
4632ae4b28
commit
ce541454e9
22 changed files with 805 additions and 268 deletions
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
testcase: "*"
|
4
test/integration/targets/netconf_config/meta/main.yml
Normal file
4
test/integration/targets/netconf_config/meta/main.yml
Normal file
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
dependencies:
|
||||
- { role: prepare_junos_tests, when: ansible_network_os == 'junos' }
|
||||
- { role: prepare_iosxr_tests, when: ansible_network_os == 'iosxr' }
|
16
test/integration/targets/netconf_config/tasks/iosxr.yaml
Normal file
16
test/integration/targets/netconf_config/tasks/iosxr.yaml
Normal file
|
@ -0,0 +1,16 @@
|
|||
---
|
||||
- name: collect all netconf test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/iosxr"
|
||||
patterns: "{{ testcase }}.yaml"
|
||||
register: test_cases
|
||||
connection: local
|
||||
|
||||
- name: set test_items
|
||||
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
|
||||
|
||||
- name: run test case (connection=netconf)
|
||||
include: "{{ test_case_to_run }}"
|
||||
with_items: "{{ test_items }}"
|
||||
loop_control:
|
||||
loop_var: test_case_to_run
|
16
test/integration/targets/netconf_config/tasks/junos.yaml
Normal file
16
test/integration/targets/netconf_config/tasks/junos.yaml
Normal file
|
@ -0,0 +1,16 @@
|
|||
---
|
||||
- name: collect all netconf test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/junos"
|
||||
patterns: "{{ testcase }}.yaml"
|
||||
register: test_cases
|
||||
connection: local
|
||||
|
||||
- name: set test_items
|
||||
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
|
||||
|
||||
- name: run test case (connection=netconf)
|
||||
include: "{{ test_case_to_run }} ansible_connection=netconf"
|
||||
with_items: "{{ test_items }}"
|
||||
loop_control:
|
||||
loop_var: test_case_to_run
|
3
test/integration/targets/netconf_config/tasks/main.yaml
Normal file
3
test/integration/targets/netconf_config/tasks/main.yaml
Normal file
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
- { include: junos.yaml, when: ansible_network_os == 'junos', tags: ['netconf'] }
|
||||
- { include: iosxr.yaml, when: ansible_network_os == 'iosxr', tags: ['netconf'] }
|
|
@ -0,0 +1,55 @@
|
|||
---
|
||||
- debug: msg="START netconf_config junos/basic.yaml on connection={{ ansible_connection }}"
|
||||
|
||||
- include_vars: "{{playbook_dir }}/targets/netconf_config/tests/junos/fixtures/config.yml"
|
||||
|
||||
- name: syslog file config- setup
|
||||
junos_config:
|
||||
lines:
|
||||
- delete system syslog file test_netconf_config
|
||||
|
||||
- name: configure syslog file
|
||||
netconf_config:
|
||||
content: "{{ syslog_config }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'<name>test_netconf_config</name>' in result.diff.after"
|
||||
|
||||
- name: configure syslog file (idempotent)
|
||||
netconf_config:
|
||||
content: "{{ syslog_config }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: configure syslog file replace
|
||||
netconf_config:
|
||||
content: "{{ syslog_config_replace }}"
|
||||
default_operation: 'replace'
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
|
||||
- name: test backup
|
||||
netconf_config:
|
||||
content: "{{ syslog_config }}"
|
||||
backup: True
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "'backup_path' in result"
|
||||
|
||||
- name: syslog file config- teardown
|
||||
junos_config:
|
||||
lines:
|
||||
- delete system syslog file test_netconf_config
|
||||
|
||||
- debug: msg="END netconf_config junos/basic.yaml on connection={{ ansible_connection }}"
|
|
@ -0,0 +1,38 @@
|
|||
---
|
||||
syslog_config: |
|
||||
<config xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0">
|
||||
<configuration>
|
||||
<system>
|
||||
<syslog>
|
||||
<file>
|
||||
<name>test_netconf_config</name>
|
||||
<contents>
|
||||
<name>any</name>
|
||||
<any/>
|
||||
</contents>
|
||||
<contents>
|
||||
<name>kernel</name>
|
||||
<critical/>
|
||||
</contents>
|
||||
</file>
|
||||
</syslog>
|
||||
</system>
|
||||
</configuration>
|
||||
</config>
|
||||
|
||||
syslog_config_replace: |
|
||||
<config xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0">
|
||||
<configuration>
|
||||
<system>
|
||||
<syslog>
|
||||
<file>
|
||||
<name>test_netconf_config</name>
|
||||
<contents>
|
||||
<name>any</name>
|
||||
<any/>
|
||||
</contents>
|
||||
</file>
|
||||
</syslog>
|
||||
</system>
|
||||
</configuration>
|
||||
</config>
|
Loading…
Add table
Add a link
Reference in a new issue