2017-07-03 12:01:59 +02:00
|
|
|
---
|
|
|
|
- debug: msg="START net_logging junos/basic.yaml"
|
|
|
|
|
2017-10-31 10:51:27 +01:00
|
|
|
- name: setup - remove file logging
|
2017-07-03 12:01:59 +02:00
|
|
|
net_logging:
|
2017-10-31 10:51:27 +01:00
|
|
|
dest: file
|
|
|
|
name: test
|
2017-07-03 12:01:59 +02:00
|
|
|
facility: pfe
|
2017-10-31 10:51:27 +01:00
|
|
|
level: error
|
2017-07-03 12:01:59 +02:00
|
|
|
state: absent
|
|
|
|
provider: "{{ netconf }}"
|
|
|
|
|
|
|
|
- name: Create file logging
|
|
|
|
net_logging:
|
2017-10-31 10:51:27 +01:00
|
|
|
dest: file
|
|
|
|
name: test_file
|
2017-07-03 12:01:59 +02:00
|
|
|
facility: pfe
|
2017-10-31 10:51:27 +01:00
|
|
|
level: error
|
2017-07-03 12:01:59 +02:00
|
|
|
state: present
|
|
|
|
provider: "{{ netconf }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- name: Get running configuration
|
|
|
|
junos_rpc:
|
|
|
|
rpc: get-configuration
|
|
|
|
provider: "{{ netconf }}"
|
|
|
|
register: config
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == true"
|
2017-10-31 10:51:27 +01:00
|
|
|
- "'<name>test_file</name>' in config.xml"
|
2017-07-03 12:01:59 +02:00
|
|
|
- "'<name>pfe</name>' in config.xml"
|
2017-10-31 10:51:27 +01:00
|
|
|
- "'<error/>' in config.xml"
|
2017-07-03 12:01:59 +02:00
|
|
|
|
|
|
|
- name: Create file logging (idempotent)
|
|
|
|
net_logging:
|
2017-10-31 10:51:27 +01:00
|
|
|
dest: file
|
|
|
|
name: test_file
|
2017-07-03 12:01:59 +02:00
|
|
|
facility: pfe
|
2017-10-31 10:51:27 +01:00
|
|
|
level: error
|
2017-07-03 12:01:59 +02:00
|
|
|
state: present
|
|
|
|
provider: "{{ netconf }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == false"
|
|
|
|
|
2017-10-31 10:51:27 +01:00
|
|
|
- name: Deactivate logging configuration
|
|
|
|
net_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
|
|
|
|
net_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"
|
|
|
|
|
2017-07-03 12:01:59 +02:00
|
|
|
- name: Delete logging configuration
|
|
|
|
net_logging:
|
2017-10-31 10:51:27 +01:00
|
|
|
dest: file
|
|
|
|
name: test_file
|
2017-07-03 12:01:59 +02:00
|
|
|
facility: pfe
|
2017-10-31 10:51:27 +01:00
|
|
|
level: error
|
2017-07-03 12:01:59 +02:00
|
|
|
state: absent
|
|
|
|
provider: "{{ netconf }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- name: Get running configuration
|
|
|
|
junos_rpc:
|
|
|
|
rpc: get-configuration
|
|
|
|
provider: "{{ netconf }}"
|
|
|
|
register: config
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == true"
|
2017-10-31 10:51:27 +01:00
|
|
|
- "'<name>test_file</name>' not in config.xml"
|
2017-07-03 12:01:59 +02:00
|
|
|
|
|
|
|
- name: Configure console logging
|
|
|
|
net_logging:
|
|
|
|
dest: console
|
|
|
|
facility: kernel
|
|
|
|
level: emergency
|
|
|
|
state: present
|
2017-10-31 10:51:27 +01:00
|
|
|
active: True
|
2017-07-03 12:01:59 +02:00
|
|
|
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)
|
2017-10-31 10:51:27 +01:00
|
|
|
net_logging:
|
2017-07-03 12:01:59 +02:00
|
|
|
dest: console
|
|
|
|
facility: kernel
|
|
|
|
level: emergency
|
|
|
|
state: present
|
2017-10-31 10:51:27 +01:00
|
|
|
active: True
|
2017-07-03 12:01:59 +02:00
|
|
|
provider: "{{ netconf }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == false"
|
|
|
|
|
2017-10-31 10:51:27 +01:00
|
|
|
- name: Disable console logging
|
|
|
|
net_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"
|
|
|
|
|
2017-07-03 12:01:59 +02:00
|
|
|
- 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"
|
2017-08-04 11:25:58 +02:00
|
|
|
|
2017-10-31 10:51:27 +01:00
|
|
|
- name: Configure logging parameters
|
|
|
|
net_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)
|
|
|
|
net_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
|
|
|
|
net_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
|
|
|
|
net_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
|
|
|
|
net_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"
|
|
|
|
|
|
|
|
- name: Seup file logging using aggregate
|
|
|
|
net_logging:
|
|
|
|
aggregate:
|
|
|
|
- {dest: file, name: test-1, facility: pfe, level: critical, state: absent}
|
|
|
|
- {dest: file, name: test-2, facility: kernel, level: emergency, state: absent}
|
|
|
|
provider: "{{ netconf }}"
|
|
|
|
register: result
|
|
|
|
|
2017-08-04 11:25:58 +02:00
|
|
|
- name: Configure file logging using aggregate
|
|
|
|
net_logging:
|
|
|
|
aggregate:
|
2017-10-31 10:51:27 +01:00
|
|
|
- {dest: file, name: test-1, facility: pfe, level: critical, active: True}
|
|
|
|
- {dest: file, name: test-2, facility: kernel, level: emergency, active: True}
|
2017-08-04 11:25:58 +02:00
|
|
|
provider: "{{ netconf }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == true'
|
2017-11-27 23:58:08 +01:00
|
|
|
- result.diff.prepared is search("\+ *file test-1")
|
|
|
|
- result.diff.prepared is search("\+ *pfe critical")
|
|
|
|
- result.diff.prepared is search("\+ *file test-2")
|
|
|
|
- result.diff.prepared is search("\+ *kernel emergency")
|
2017-08-04 11:25:58 +02:00
|
|
|
|
2017-10-31 10:51:27 +01:00
|
|
|
- name: Deactivate file logging configuration using aggregate
|
2017-08-04 11:25:58 +02:00
|
|
|
net_logging:
|
|
|
|
aggregate:
|
2017-08-14 06:47:03 +02:00
|
|
|
- dest: file
|
|
|
|
name: test-1
|
|
|
|
facility: pfe
|
|
|
|
level: critical
|
|
|
|
- dest: file
|
|
|
|
name: test-2
|
|
|
|
facility: kernel
|
|
|
|
level: emergency
|
2017-10-31 10:51:27 +01:00
|
|
|
active: False
|
|
|
|
provider: "{{ netconf }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == true'
|
2017-11-27 23:58:08 +01:00
|
|
|
- result.diff.prepared is search("! *inactive[:] file test-1")
|
|
|
|
- result.diff.prepared is search("! *inactive[:] pfe")
|
|
|
|
- result.diff.prepared is search("! *inactive[:] file test-2")
|
|
|
|
- result.diff.prepared is search("! *inactive[:] kernel")
|
2017-10-31 10:51:27 +01:00
|
|
|
|
|
|
|
- name: activate file logging configuration using aggregate
|
|
|
|
net_logging:
|
|
|
|
aggregate:
|
|
|
|
- { dest: file, name: test-1, facility: pfe, level: critical }
|
|
|
|
- { dest: file, name: test-2, facility: kernel, level: emergency }
|
|
|
|
active: True
|
|
|
|
provider: "{{ netconf }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == true'
|
2017-11-27 23:58:08 +01:00
|
|
|
- result.diff.prepared is search("! *active[:] file test-1")
|
|
|
|
- result.diff.prepared is search("! *active[:] pfe")
|
|
|
|
- result.diff.prepared is search("! *active[:] file test-2")
|
|
|
|
- result.diff.prepared is search("! *active[:] kernel")
|
2017-10-31 10:51:27 +01:00
|
|
|
|
|
|
|
- name: Delete file logging using aggregate
|
|
|
|
net_logging:
|
|
|
|
aggregate:
|
|
|
|
- { dest: file, name: test-1, facility: pfe, level: critical }
|
|
|
|
- { dest: file, name: test-2, facility: kernel, level: emergency }
|
2017-08-14 06:47:03 +02:00
|
|
|
state: absent
|
2017-08-04 11:25:58 +02:00
|
|
|
provider: "{{ netconf }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == true'
|
2017-11-27 23:58:08 +01:00
|
|
|
- result.diff.prepared is search("\- *file test-1")
|
|
|
|
- result.diff.prepared is search("\- *pfe critical")
|
|
|
|
- result.diff.prepared is search("\- *file test-2")
|
|
|
|
- result.diff.prepared is search("\- *kernel emergency")
|
2017-08-14 06:47:03 +02:00
|
|
|
|
|
|
|
- name: Delete file logging using aggregate (idempotent)
|
|
|
|
net_logging:
|
|
|
|
aggregate:
|
2017-10-31 10:51:27 +01:00
|
|
|
- { dest: file, name: test-1, facility: pfe, level: critical }
|
|
|
|
- { dest: file, name: test-2, facility: kernel, level: emergency }
|
2017-08-14 06:47:03 +02:00
|
|
|
state: absent
|
|
|
|
provider: "{{ netconf }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
2017-10-31 10:51:27 +01:00
|
|
|
- "result.changed == false"
|