Skip to content

Commit

Permalink
Remote Audit LOG (#424)
Browse files Browse the repository at this point in the history
* Update sonic_logging.py

* Update logging.py

* Update main.yml

* Update sonic_logging.yaml

* Update sonic_logging.py

* Create 424-remote-audit-log.yaml

* Update sonic_logging.py

Addressed review comments
  • Loading branch information
arulkumar9690 authored Sep 18, 2024
1 parent 077e63a commit 4fb4351
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/424-remote-audit-log.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- sonic_logging - Add audit message-type in sonic_logging module(https://github.com/ansible-collections/dellemc.enterprise_sonic/pull/424)
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(self, **kwargs):
'options': {
'host': {'required': True,
'type': 'str'},
'message_type': {'choices': ['log', 'event'],
'message_type': {'choices': ['log', 'event', 'audit'],
'type': 'str'},
'remote_port': {'type': 'int'},
'source_interface': {'type': 'str'},
Expand Down
15 changes: 9 additions & 6 deletions plugins/modules/sonic_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
choices:
- log
- event
- audit
protocol:
type: str
description:
Expand Down Expand Up @@ -110,8 +111,8 @@
#---------------------------------------------------------------------------------------
#10.11.0.2 5 Ethernet24 - event udp
#10.11.1.1 616 Ethernet8 - log tcp
#log1.dell.com 6 Ethernet28 - audit udp
#10.11.1.2 116 Ethernet6 - log tls
#log1.dell.com 6 Ethernet28 - log udp
#
- name: Delete logging server configuration
sonic_logging:
Expand Down Expand Up @@ -160,6 +161,7 @@
remote_port: 6
protocol: udp
source_interface: Ethernet28
message_type: audit
state: merged
# After state:
Expand All @@ -172,7 +174,7 @@
#10.11.0.2 5 Ethernet24 - event udp
#10.11.0.1 4 Ethernet2 - log tls
#10.11.1.1 616 Ethernet8 - log tcp
#log1.dell.com 6 Ethernet28 - log udp
#log1.dell.com 6 Ethernet28 - audit udp
#
#
# Using overridden
Expand All @@ -188,15 +190,15 @@
#10.11.1.2 626 Ethernet16 - event udp
#10.11.1.3 626 Ethernet14 - log tls
#
- name: Replace logging server configuration
- name: Override logging server configuration
sonic_logging:
config:
remote_servers:
- host: 10.11.1.2
remote_port: 622
protocol: TCP
source_interface: Ethernet24
message_type: event
message_type: audit
state: overridden
#
# After state:
Expand All @@ -206,7 +208,7 @@
#--------------------------------------------------------------------------------------
#HOST PORT SOURCE-INTERFACE VRF MESSAGE-TYPE PROTOCOL
#--------------------------------------------------------------------------------------
#10.11.1.2 622 Ethernet24 - event tcp
#10.11.1.2 622 Ethernet24 - audit tcp
#
# Using replaced
#
Expand All @@ -227,6 +229,7 @@
- host: 10.11.1.2
remote_port: 622
protocol: UDP
message_type: audit
state: replaced
#
# After state:
Expand All @@ -239,7 +242,7 @@
#HOST PORT SOURCE-INTERFACE VRF MESSAGE-TYPE PROTOCOL
#--------------------------------------------------------------------------------------
#10.11.1.1 616 Ethernet8 - log tcp
#10.11.1.2 622 - - log udp
#10.11.1.2 622 - - audit udp
#
"""
RETURN = """
Expand Down
4 changes: 2 additions & 2 deletions tests/regression/roles/sonic_logging/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ tests:
message_type: event
- host: "{{ logging_ip_server_4 }}"
source_interface: "{{ mgmt }}"
message_type: event
message_type: audit
protocol: UDP
vrf: Vrf_logging_1
- host: "{{ logging_host_server }}"
Expand Down Expand Up @@ -120,7 +120,7 @@ tests:
source_interface: "{{ vlan1 }}"
remote_port: 818
protocol: UDP
message_type: event
message_type: audit
vrf: Vrf_logging_2
- host: "{{ logging_host_server }}"
source_interface: "{{ lo1 }}"
Expand Down
6 changes: 4 additions & 2 deletions tests/unit/modules/network/sonic/fixtures/sonic_logging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ merged_01:
remote_port: 6
protocol: UDP
source_interface: Eth1/28
message_type: audit
existing_logging_config:
- path: "data/openconfig-system:system/logging"
response:
Expand Down Expand Up @@ -45,6 +46,7 @@ merged_01:
config:
host: log1.dell.com
source-interface: Eth1/28
message-type: audit
remote-port: 6
protocol: UDP

Expand Down Expand Up @@ -179,7 +181,7 @@ overridden_01:
- host: 10.11.0.10
remote_port: 10
source_interface: Eth1/26
message_type: log
message_type: audit
protocol: TCP
existing_logging_config:
- path: "data/openconfig-system:system/logging"
Expand Down Expand Up @@ -215,7 +217,7 @@ overridden_01:
config:
host: 10.11.0.10
source-interface: Eth1/26
message-type: log
message-type: audit
remote-port: 10
protocol: TCP
vrf-name:

0 comments on commit 4fb4351

Please sign in to comment.