dellemc.enterprise_sonic.sonic_sflow module – configure sflow settings on SONiC

Note

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

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_sflow.

New in dellemc.enterprise_sonic 2.5.0

Synopsis

  • This module provides configuration for sflow sampling on devices running SONiC

Parameters

Parameter

Comments

config

dictionary

Defines configuration and operational state data related to data plane traffic sampling based on sflow.

agent

string

The Agent interface

collectors

list / elements=dictionary

Configuration data for sflow collectors.

address

string / required

IP address of the sflow collector.

network_instance

string

name of the network instance containing the sflow collector

Default: "default"

port

integer

UDP port number for the sflow collector.

Default: 6343

enabled

boolean

Enables or disables sflow sampling for the device.

Choices:

  • false

  • true

interfaces

list / elements=dictionary

Configuration data for sflow data on interfaces.

enabled

boolean

If sflow is globally enabled, enables or disables sflow on the interface

Choices:

  • false

  • true

name

string / required

Name of the interface

sampling_rate

integer

Override the global sampling rate for this interface

polling_interval

integer

sflow polling interval (in seconds).

must be 0 or in range 5-300

sampling_rate

integer

Sets global packet sampling rate.

Sample 1 packet for every sampling_rate number of packets flowing through the interface

state

string

Specifies the type of configuration update to be performed on the device.

Choices:

  • "merged" ← (default)

  • "replaced"

  • "overridden"

  • "deleted"

Examples

# Using deleted to clear all configuration
  # Before state:
  # config:
  #   enabled: False
  #   polling_interval: 40
  #   collectors:
  #     - address: 1.1.1.1
  #       port: 6343
  #       network_instance: default
  #   interfaces:
  #     - name: Ethernet0
  #       sampling_rate: 400000

  # Example
    - name: "clear all sflow config and disable"
      sonic_sflow:
        config: {}
        state: deleted

  # After state:
  # Note, "enabled" can't be deleted. It's just set to default. All values that can be cleared are deleted.
  # config:
  #   enabled: False
  #   (no other recorded config)
  # ------

# Using deleted to clear just the interfaces and collectors
  # Before state:
  # config:
  #   enabled: True
  #   polling_interval: 40
  #   collectors:
  #     - address: 1.1.1.1
  #       port: 6343
  #       network_instance: default
  #   interfaces:
  #     - name: Ethernet0
  #       sampling_rate: 400000

  # Example
    - name: "clear all sflow interfaces and collectors"
      sonic_sflow:
        config:
          interfaces: []
          collectors: []
        state: deleted

  # After state:
  # config:
  #   enabled: True
  #   polling_interval: 40
  # Note: deletes list of items if empty list is provided. Otherwise must specify key and have values match to delete, see other Example
  # ------

# Using deleted to delete individual interfaces
  # Before state:
  # config:
  #   enabled: False
  #   polling_interval: 40
  #   collectors:
  #     - address: 1.1.1.1
  #       port: 6343
  #       network_instance: default
  #   interfaces:
  #     - name: Ethernet0
  #       sampling_rate: 400000
  #     - name: Ethernet8
  #       enabled: False
  #     - name: Ethernet16
  #       sampling_rate: 400000

  # Example
  # note: to delete the whole interface, just the name needs to specify the name, nothing else
    - name: "delete individual interfaces"
      sonic_sflow:
        config:
          interfaces:
            - name: Ethernet8
            - name: Ethernet16
      state: deleted

  # After state:
  # All configuration deleted for the listed interfaces
  # config:
  #   enabled: False
  #   polling_interval: 40
  #   collectors:
  #     - address: 1.1.1.1
  #       port: 6343
  #       network_instance: default
  #   interfaces:
  #     - name: Ethernet0
  #       sampling_rate: 400000
  # ------

# Using deleted to delete collectors
  # Before state:
  # config:
  #   enabled: False
  #   polling_interval: 40
  #   collectors:
  #     - address: 1.1.1.1
  #       port: 6343
  #       network_instance: default
  #     - address: 1.1.1.2
  #       port: 6000
  #       network_instance: "vrf_1"
  #   interfaces:
  #     - name: Ethernet0
  #       sampling_rate: 400000

  # Example:
  # Note: The values of all three fields must be known to identify a collector, but
  # the "port" and "network instance" attributes have default values. These default
  # values do not need to be explicitly specified in a playbook for deletion of a
  # collector having default values configured for these attributes.
    - name: "delete individual collectors"
      sonic_sflow:
        config:
          collectors:
            - address: 1.1.1.2
              port: 6000
              network_instance: "vrf_1"
            - address: 1.1.1.1
      state: deleted

  # After state:
  # config:
  #   enabled: False
  #   polling_interval: 40
  #   interfaces:
  #     - name: Ethernet0
  #       sampling_rate: 400000
  # ------

# Using deleted to clear individual values
  # Before state:
  # config:
  #   enabled: True
  #   polling_interval: 30
  #   sampling_rate: 400000
  #   collectors:
  #     - address: 1.1.1.1
  #       port: 6343
  #       network_instance: default
  #   interfaces:
  #     - name: Ethernet0
  #       enabled: True
  #       sampling_rate: 400000
  #     - name: Ethernet4
  #       enabled: True
  #       sampling_rate: 400002

  # Example
    - name: "clear specific config attributes if values match"
      sonic_sflow:
        config:
          enabled: False
          polling_interval: 30
          sampling_rate: 400000
          interfaces:
            - name: Ethernet0
              sampling_rate: 400000
      state: deleted

  # After state:
  # config:
  #   enabled: True
  #   collectors:
  #     - address: 1.1.1.1
  #       port: 6343
  #       network_instance: default
  #   interfaces:
  #     - name: Ethernet0
  #       enabled: True
  #     - name: Ethernet4
  #       enabled: True
  #       sampling_rate: 400002

# ------------


# Using merged to add sflow collector
  # Before state:
  # config:
  #   enabled: False

  # Example:
    - name: "Add an sflow collector with default values for 'port' and 'network_instance"
      sonic_sflow:
        config:
          collectors:
            - address: 1.1.1.2
        state: merged
  # note: There can only be two collectors configured at a time.
  # note: Only "port" and and "network_instance" have default values.

  # After state:
  # config:
  #   enabled: False
  #   collectors:
  #     - address: 1.1.1.2
  #       port: 6343
  #       network_instance: default
  # ------

# Using merged to add and modify interface configuration
  # Before state:
  # config:
  #   enabled: False
  #   interfaces:
  #     - name: Ethernet0
  #       sampling_rate: 400002
  #     - name: Ethernet8
  #       enabled: True
  #       sampling_rate: 400001

  # Example
    - name: "Add/modify interface settings"
      sonic_sflow:
        config:
          interfaces:
            - name: Ethernet0
              enabled: True
            - name: Ethernet8
              enabled: False
              sampling_rate: 400003
            - name: Ethernet16
            - name: Ethernet32
              sampling_rate: 400001
        state: merged
  # Note: must set at least one of enabled or sampling_rate for interface to be added

  # After state
  # config:
  #   enabled: False
  #   interfaces:
  #     - name: Ethernet0
  #       sampling_rate: 400002
  #       enabled: True
  #     - name: Ethernet8
  #       enabled: False
  #       sampling_rate: 400003
  #     - name: Ethernet32
  #       sampling_rate: 400001
  # ------

# Using merged to add/modify global settings
  # Before state:
  # config:
  #   enabled: False
  #   polling_interval: 40

  # Example
    - name: "Adding/modifying other settings using 'merged'"
      sonic_sflow:
        config:
          polling_interval: 50
          enabled: True
          agent: Ethernet0
        state: merged

  # After state
  # config:
  #   enabled: True
  #   polling_interval: 50
  #   agent: Ethernet0

# -----------


# using overridden to override all existing sflow config with the given settings
  # Before state:
  # config:
  #   enabled: False
  #   polling_interval: 50
  #   collectors:
  #     - address: 1.1.1.1
  #       port: 6343
  #       network_instance: default
  #   interfaces:
  #     - name: Ethernet0
  #       enabled: False
  #     - name: Ethernet8
  #       enabled: False
  #     - name: Ethernet16
  #       enabled: False
  #     - name: Ethernet24
  #       enabled: False

  # Example:
    - name: "override all existing sflow config with input config from a playbook task"
      sonic_sflow:
        config:
          enabled: True
          agent: Ethernet0
          interfaces:
            - name: Ethernet0
              enabled: True
        state: overridden

  # After state:
  # config:
  #   enabled: True
  #   agent: Ethernet0
  #   interfaces:
  #     - name: Ethernet0
  #       enabled: True
# ------------


# Using replaced to replace specific interface settings
  # Before state:
  # config:
  #   enabled: False
  #   polling_interval: 50
  #   collectors:
  #     - address: 1.1.1.1
  #       port: 6343
  #       network_instance: default
  #   interfaces:
  #     - name: Ethernet0
  #       enabled: True
  #       sampling_rate: 400002
  #     - name: Ethernet4
  #       enabled: False
  #     - name: Ethernet8
  #       enabled: False
  #       sampling_rate: 400010
  #     - name: Ethernet24
  #       enabled: False

  # Example:
    - name: "only add or substitute certain interfaces"
      sonic_sflow:
        config:
          enabled: False
          polling_interval: 50
          interfaces:
            - name: Ethernet0
              sampling_rate: 400010
            - name: Ethernet4
              sampling_rate: 400010
            - name: Ethernet16
              enabled: False
        state: replaced

  # After state:
  # config:
  #   enabled: False
  #   polling_interval: 50
  #   collectors:
  #     - address: 1.1.1.1
  #       port: 6343
  #       network_instance: default
  #   interfaces:
  #     - name: Ethernet0
  #       sampling_rate: 400010
  #     - name: Ethernet4
  #       sampling_rate: 400010
  #     - name: Ethernet8
  #       enabled: False
  #       sampling_rate: 400010
  #     - name: Ethernet16
  #       enabled: False
  #     - name: Ethernet24
  #       enabled: False
  # ------

  # Using "replaced" with different top level values replaces nested components.
  # Before state:
  # config:
  #   enabled: False
  #   polling_interval: 50
  #   collectors:
  #     - address: 1.1.1.1
  #       port: 6343
  #       network_instance: default
  #   interfaces:
  #     - name: Ethernet0
  #       enabled: False
  #     - name: Ethernet8
  #       enabled: False
  #     - name: Ethernet16
  #       enabled: False
  #     - name: Ethernet24
  #       enabled: False

  # Example:
    - name: "replaces everything"
      sonic_sflow:
        config:
          enabled: False
          polling_interval: 30
        state: replaced

  # After state:
  # config:
  #   enabled: False
  #   polling_interval: 30
  # -----------

Return Values

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

Key

Description

after

dictionary

The resulting configuration module invocation.

Returned: when changed

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

before

dictionary

The configuration prior to the module invocation.

Returned: always

Sample: "The configuration returned will always be in the same format\n 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

  • Xiao Han (@Xiao_Han2)