mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 06:12:51 +00:00
Add net_logging platform agnostic module and junos implementation (#26316)
* Add net_logging platform agnostic module and junos implemenatation * net_logging platform agnostic module * junos implemenatation of logging module * net_logging integration test * junos_logging integration test
This commit is contained in:
@@ -18,3 +18,4 @@
|
||||
- { role: junos_interface, when: "limit_to in ['*', 'junos_interface']" }
|
||||
- { role: junos_banner, when: "limit_to in ['*', 'junos_banner']" }
|
||||
- { role: junos_system, when: "limit_to in ['*', 'junos_system']" }
|
||||
- { role: junos_logging, when: "limit_to in ['*', 'junos_logging']" }
|
||||
|
||||
@@ -16,3 +16,4 @@
|
||||
- { role: net_vrf, when: "limit_to in ['*', 'net_vrf']" }
|
||||
- { role: net_interface, when: "limit_to in ['*', 'net_interface']" }
|
||||
- { role: net_static_route, when: "limit_to in ['*', 'net_static_route']" }
|
||||
- { role: net_logging, when: "limit_to in ['*', 'net_logging']" }
|
||||
|
||||
0
test/integration/targets/junos_logging/aliases
Normal file
0
test/integration/targets/junos_logging/aliases
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
testcase: "*"
|
||||
2
test/integration/targets/junos_logging/tasks/main.yaml
Normal file
2
test/integration/targets/junos_logging/tasks/main.yaml
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
- { include: netconf.yaml, tags: ['netconf'] }
|
||||
16
test/integration/targets/junos_logging/tasks/netconf.yaml
Normal file
16
test/integration/targets/junos_logging/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
|
||||
298
test/integration/targets/junos_logging/tests/netconf/basic.yaml
Normal file
298
test/integration/targets/junos_logging/tests/netconf/basic.yaml
Normal file
@@ -0,0 +1,298 @@
|
||||
---
|
||||
- debug: msg="START junos_logging netconf/basic.yaml"
|
||||
|
||||
- name: setup - remove file logging
|
||||
junos_logging:
|
||||
dest: file
|
||||
name: test
|
||||
facility: pfe
|
||||
level: error
|
||||
state: absent
|
||||
provider: "{{ netconf }}"
|
||||
|
||||
- name: Create file logging
|
||||
junos_logging:
|
||||
dest: file
|
||||
name: test_file
|
||||
facility: pfe
|
||||
level: error
|
||||
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>test_file</name>' in config.xml"
|
||||
- "'<name>pfe</name>' in config.xml"
|
||||
- "'<error/>' in config.xml"
|
||||
|
||||
- name: Create file logging (idempotent)
|
||||
junos_logging:
|
||||
dest: file
|
||||
name: test_file
|
||||
facility: pfe
|
||||
level: error
|
||||
state: present
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: Deactivate logging configuration
|
||||
junos_logging:
|
||||
dest: file
|
||||
name: test_file
|
||||
facility: pfe
|
||||
level: error
|
||||
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"
|
||||
- "'<file inactive=\"inactive\">' in config.xml"
|
||||
- "'<contents inactive=\"inactive\">' in config.xml"
|
||||
|
||||
- name: Activate logging configuration
|
||||
junos_logging:
|
||||
dest: file
|
||||
name: test_file
|
||||
facility: pfe
|
||||
level: error
|
||||
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>test_file</name>' in config.xml"
|
||||
- "'<name>pfe</name>' in config.xml"
|
||||
- "'<error/>' in config.xml"
|
||||
|
||||
- name: Delete logging configuration
|
||||
junos_logging:
|
||||
dest: file
|
||||
name: test_file
|
||||
facility: pfe
|
||||
level: error
|
||||
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>test_file</name>' not in config.xml"
|
||||
|
||||
- name: Configure console logging
|
||||
junos_logging:
|
||||
dest: console
|
||||
facility: kernel
|
||||
level: emergency
|
||||
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"
|
||||
- "'<console>' in config.xml"
|
||||
- "'<name>kernel</name>' in config.xml"
|
||||
- "'<emergency/>' in config.xml"
|
||||
|
||||
- name: Configure console logging (idempotent)
|
||||
junos_logging:
|
||||
dest: console
|
||||
facility: kernel
|
||||
level: emergency
|
||||
state: present
|
||||
active: True
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: Disable console logging
|
||||
junos_logging:
|
||||
dest: console
|
||||
facility: kernel
|
||||
level: emergency
|
||||
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"
|
||||
- "'<console inactive=\"inactive\">' in config.xml"
|
||||
|
||||
- name: Delete console logging
|
||||
junos_logging:
|
||||
dest: console
|
||||
facility: kernel
|
||||
level: emergency
|
||||
state: absent
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- name: Get running configuration
|
||||
junos_rpc:
|
||||
rpc: get-configuration
|
||||
provider: "{{ netconf }}"
|
||||
register: config
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'<console>' not in config.xml"
|
||||
|
||||
- name: Configure logging parameters
|
||||
junos_logging:
|
||||
size: 65536
|
||||
files: 40
|
||||
rotate_frequency: 20
|
||||
state: present
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- name: Get running configuration
|
||||
junos_rpc:
|
||||
rpc: get-configuration
|
||||
provider: "{{ netconf }}"
|
||||
register: config
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'<size>64k</size>' in config.xml"
|
||||
- "'<files>40</files>' in config.xml"
|
||||
- "'<log-rotate-frequency>20</log-rotate-frequency>' in config.xml"
|
||||
|
||||
- name: Configure logging parameters (idempotent)
|
||||
junos_logging:
|
||||
size: 65536
|
||||
files: 40
|
||||
rotate_frequency: 20
|
||||
state: present
|
||||
active: True
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: Disable logging parameters
|
||||
junos_logging:
|
||||
size: 65536
|
||||
files: 40
|
||||
rotate_frequency: 20
|
||||
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"
|
||||
- "'<size inactive=\"inactive\">64k</size>' in config.xml"
|
||||
- "'<files inactive=\"inactive\">40</files>' in config.xml"
|
||||
- "'<log-rotate-frequency inactive=\"inactive\">20</log-rotate-frequency>' in config.xml"
|
||||
|
||||
- name: Activate logging parameters
|
||||
junos_logging:
|
||||
size: 65536
|
||||
files: 40
|
||||
rotate_frequency: 20
|
||||
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"
|
||||
- "'<size>64k</size>' in config.xml"
|
||||
- "'<files>40</files>' in config.xml"
|
||||
- "'<log-rotate-frequency>20</log-rotate-frequency>' in config.xml"
|
||||
|
||||
- name: Delete logging parameters
|
||||
junos_logging:
|
||||
size: 65536
|
||||
files: 40
|
||||
rotate_frequency: 20
|
||||
state: absent
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- name: Get running configuration
|
||||
junos_rpc:
|
||||
rpc: get-configuration
|
||||
provider: "{{ netconf }}"
|
||||
register: config
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'<size>64k</size>' not in config.xml"
|
||||
- "'<files>40</files>' not in config.xml"
|
||||
- "'<log-rotate-frequency>20</log-rotate-frequency>' not in config.xml"
|
||||
2
test/integration/targets/net_logging/defaults/main.yaml
Normal file
2
test/integration/targets/net_logging/defaults/main.yaml
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
testcase: "*"
|
||||
16
test/integration/targets/net_logging/tasks/cli.yaml
Normal file
16
test/integration/targets/net_logging/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
|
||||
3
test/integration/targets/net_logging/tasks/main.yaml
Normal file
3
test/integration/targets/net_logging/tasks/main.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
---
|
||||
- { include: cli.yaml, tags: ['cli'] }
|
||||
- { include: netconf.yaml, tags: ['netconf'] }
|
||||
16
test/integration/targets/net_logging/tasks/netconf.yaml
Normal file
16
test/integration/targets/net_logging/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_logging eos/basic.yaml"
|
||||
124
test/integration/targets/net_logging/tests/junos/basic.yaml
Normal file
124
test/integration/targets/net_logging/tests/junos/basic.yaml
Normal file
@@ -0,0 +1,124 @@
|
||||
---
|
||||
- debug: msg="START net_logging junos/basic.yaml"
|
||||
|
||||
- name: setup - remove host logging
|
||||
net_logging:
|
||||
dest: host
|
||||
name: 1.1.1.1
|
||||
facility: pfe
|
||||
level: critical
|
||||
state: absent
|
||||
provider: "{{ netconf }}"
|
||||
|
||||
- name: Create file logging
|
||||
net_logging:
|
||||
dest: host
|
||||
name: 1.1.1.1
|
||||
facility: pfe
|
||||
level: critical
|
||||
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</name>' in config.xml"
|
||||
- "'<name>pfe</name>' in config.xml"
|
||||
- "'<critical/>' in config.xml"
|
||||
|
||||
- name: Create file logging (idempotent)
|
||||
net_logging:
|
||||
dest: host
|
||||
name: 1.1.1.1
|
||||
facility: pfe
|
||||
level: critical
|
||||
state: present
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: Delete logging configuration
|
||||
net_logging:
|
||||
dest: host
|
||||
name: 1.1.1.1
|
||||
facility: pfe
|
||||
level: critical
|
||||
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</name>' not in config.xml"
|
||||
|
||||
- name: Configure console logging
|
||||
net_logging:
|
||||
dest: console
|
||||
facility: kernel
|
||||
level: emergency
|
||||
state: present
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- name: Get running configuration
|
||||
junos_rpc:
|
||||
rpc: get-configuration
|
||||
provider: "{{ netconf }}"
|
||||
register: config
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'<console>' in config.xml"
|
||||
- "'<name>kernel</name>' in config.xml"
|
||||
- "'<emergency/>' in config.xml"
|
||||
|
||||
- name: Configure console logging (idempotent)
|
||||
junos_logging:
|
||||
dest: console
|
||||
facility: kernel
|
||||
level: emergency
|
||||
state: present
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: Delete console logging
|
||||
net_logging:
|
||||
dest: console
|
||||
facility: kernel
|
||||
level: emergency
|
||||
state: absent
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- name: Get running configuration
|
||||
junos_rpc:
|
||||
rpc: get-configuration
|
||||
provider: "{{ netconf }}"
|
||||
register: config
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'<console>' not in config.xml"
|
||||
@@ -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