dellemc.enterprise_sonic.sonic_logging module – Manage logging configuration on SONiC.

Note

This module is part of the dellemc.enterprise_sonic collection (version 3.0.0).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install dellemc.enterprise_sonic.

To use it in a playbook, specify: dellemc.enterprise_sonic.sonic_logging.

New in dellemc.enterprise_sonic 2.1.0

Synopsis

  • This module provides configuration management of logging for devices running SONiC.

Parameters

Parameter

Comments

config

dictionary

Specifies logging related configurations.

remote_servers

list / elements=dictionary

Remote logging sever configuration.

host

string / required

IPv4/IPv6 address or host name of the remote logging server.

message_type

string

Type of messages that remote server receives.

message_type can not be deleted.

Choices:

  • "log"

  • "event"

  • "audit"

  • "auditd-system"

protocol

string

Type of the protocol for sending the messages.

Choices:

  • "TCP"

  • "TLS"

  • "UDP"

remote_port

integer

Destination port number for logging messages sent to the server.

remote_port can not be deleted.

severity

string

added in dellemc.enterprise_sonic 3.1.0

The log severity filter for remote syslog server.

Choices:

  • "debug"

  • "info"

  • "notice"

  • "warning"

  • "error"

  • "critical"

  • "alert"

  • "emergency"

source_interface

string

Source interface used as source ip for sending logging packets.

source_interface can not be deleted.

vrf

string

VRF name used by remote logging server.

state

string

The state of the configuration after module completion.

Choices:

  • "merged" ← (default)

  • "replaced"

  • "overridden"

  • "deleted"

Notes

Note

  • Supports check_mode.

Examples

# Using deleted
#
# Before state:
# -------------
#
#sonic# show logging servers
#---------------------------------------------------------------------------------------
#HOST            PORT      SOURCE-INTERFACE    VRF            MESSAGE-TYPE     PROTOCOL
#---------------------------------------------------------------------------------------
#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
#
- name: Delete logging server configuration
  sonic_logging:
    config:
      remote_servers:
        - host: 10.11.0.2
        - host: log1.dell.com
    state: deleted

# After state:
# ------------
#
#sonic# show logging servers
#---------------------------------------------------------------------------------------
#HOST            PORT      SOURCE-INTERFACE    VRF            MESSAGE-TYPE     PROTOCOL
#---------------------------------------------------------------------------------------
#10.11.1.1       616       Ethernet8           -              log               tcp
#10.11.1.2       116       Ethernet6           -              log                tls
#
#
# Using merged
#
# Before state:
# -------------
#
#sonic# show logging servers
#--------------------------------------------------------------------------------------
#HOST            PORT      SOURCE-INTERFACE    VRF            MESSAGE-TYPE    PROTOCOL
#--------------------------------------------------------------------------------------
#10.11.1.1       616       Ethernet8           -              log              tcp
#
- name: Merge logging server configuration
  sonic_logging:
    config:
      remote_servers:
        - host: 10.11.0.2
          remote_port: 5
          protocol: TCP
          source_interface: Ethernet24
          message_type: event
        - host: 10.11.0.1
          remote_port: 4
          protocol: TLS
          source_interface: Ethernet2
        - host: log1.dell.com
          remote_port: 6
          protocol: udp
          source_interface: Ethernet28
          message_type: audit
    state: merged

# After state:
# ------------
#
#sonic# show logging servers
#-------------------------------------------------------------------------------------
#HOST            PORT      SOURCE-INTERFACE    VRF            MESSAGE-TYPE   PROTOCOL
#-------------------------------------------------------------------------------------
#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          -              audit           udp
#
#
# Using overridden
#
# Before state:
# -------------
#
#sonic# show logging servers
#--------------------------------------------------------------------------------------
#HOST            PORT      SOURCE-INTERFACE    VRF            MESSAGE-TYPE    PROTOCOL
#--------------------------------------------------------------------------------------
#10.11.1.1       616       Ethernet8           -              log              tcp
#10.11.1.2       626       Ethernet16          -              event            udp
#10.11.1.3       626       Ethernet14          -              log              tls
#
- 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: auditd-system
    state: overridden
#
# After state:
# ------------
#
#sonic# show logging servers
#--------------------------------------------------------------------------------------
#HOST            PORT      SOURCE-INTERFACE    VRF            MESSAGE-TYPE    PROTOCOL
#--------------------------------------------------------------------------------------
#10.11.1.2       622       Ethernet24          -              auditd-system      tcp
#
# Using replaced
#
# Before state:
# -------------
#
#sonic# show logging servers
#--------------------------------------------------------------------------------------
#HOST            PORT      SOURCE-INTERFACE    VRF            MESSAGE-TYPE    PROTOCOL
#--------------------------------------------------------------------------------------
#10.11.1.1       616       Ethernet8           -              log              tcp
#10.11.1.2       626       Ethernet16          -              event            udp
#
- name: Replace logging server configuration
  sonic_logging:
    config:
      remote_servers:
        - host: 10.11.1.2
          remote_port: 622
          protocol: UDP
          message_type: audit
    state: replaced
#
# After state:
# ------------
#
# "MESSAGE-TYPE" has default value of "log"
#
#sonic# show logging servers
#--------------------------------------------------------------------------------------
#HOST            PORT      SOURCE-INTERFACE    VRF            MESSAGE-TYPE    PROTOCOL
#--------------------------------------------------------------------------------------
#10.11.1.1       616       Ethernet8           -              log              tcp
#10.11.1.2       622       -                   -              audit            udp
#

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

after

list / elements=string

The resulting configuration module invocation.

Returned: when changed

Sample: ["The configuration returned will always be in the same format as the parameters above.\n"]

after(generated)

list / elements=string

The generated configuration module invocation.

Returned: when check_mode

Sample: ["The configuration returned will always be in the same format as the parameters above.\n"]

before

list / elements=string

The configuration prior to the module invocation.

Returned: always

Sample: ["The configuration returned will always be in the same format as the parameters above.\n"]

commands

list / elements=string

The set of commands pushed to the remote device.

Returned: always

Sample: ["command 1", "command 2", "command 3"]

Authors

    1. Zhang (@mingjunzhang2019)