dellemc.enterprise_sonic.sonic_sflow 模块 – 在 SONiC 上配置 sflow 设置

注意

此模块是 dellemc.enterprise_sonic 集合 (版本 2.5.1) 的一部分。

如果您正在使用 ansible 软件包,则可能已安装此集合。它不包含在 ansible-core 中。要检查它是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用: ansible-galaxy collection install dellemc.enterprise_sonic

要在 playbook 中使用它,请指定: dellemc.enterprise_sonic.sonic_sflow

dellemc.enterprise_sonic 2.5.0 中的新增功能

概要

  • 此模块提供运行 SONiC 的设备上 sflow 采样的配置。

参数

参数

注释

config

字典

定义与基于 sflow 的数据平面流量采样相关的配置和运行状态数据。

agent

字符串

代理接口

collectors

列表 / 元素=字典

sflow 收集器的配置数据。

address

字符串 / 必需

sflow 收集器的 IP 地址。

network_instance

字符串

包含 sflow 收集器的网络实例的名称

默认值: "default"

port

整数

sflow 收集器的 UDP 端口号。

默认值: 6343

enabled

布尔值

启用或禁用设备的 sflow 采样。

选项

  • false

  • true

interfaces

列表 / 元素=字典

接口上 sflow 数据的配置数据。

enabled

布尔值

如果全局启用了 sflow,则启用或禁用接口上的 sflow

选项

  • false

  • true

name

字符串 / 必需

接口名称

sampling_rate

整数

覆盖此接口的全局采样率

polling_interval

整数

sflow 轮询间隔(以秒为单位)。

必须为 0 或在 5-300 范围内

sampling_rate

整数

设置全局数据包采样率。

为流经接口的每 sampling_rate 个数据包采样 1 个数据包

state

字符串

指定要在设备上执行的配置更新类型。

选项

  • "merged" ← (默认)

  • "replaced"

  • "overridden"

  • "deleted"

示例

# 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
  # -----------

返回值

常见的返回值在此处记录,以下是此模块特有的字段

描述

after

字典

模块调用后的结果配置。

返回:发生更改时

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

before

字典

模块调用之前的配置。

返回:始终返回

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

commands

列表 / 元素=字符串

推送到远程设备的命令集。

返回:始终返回

示例: ["command 1", "command 2", "command 3"]

作者

  • 韩肖 (@Xiao_Han2)