ansible.builtin.ce_sflow (v2.4.2.0-1) — module

Manages sFlow configuration on HUAWEI CloudEngine switches.

| "added in version" 2.4 of ansible.builtin"

Authors: QijunPan (@CloudEngine-Ansible)

preview | supported by community

Install Ansible via pip

Install with pip install ansible==2.4.2.0.post1

Description

Configure Sampled Flow (sFlow) to monitor traffic on an interface in real time, detect abnormal traffic, and locate the source of attack traffic, ensuring stable running of the network.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
---

- name: sflow module test
  hosts: ce128
  connection: local
  gather_facts: no
  vars:
    cli:
      host: "{{ inventory_hostname }}"
      port: "{{ ansible_ssh_port }}"
      username: "{{ username }}"
      password: "{{ password }}"
      transport: cli

  tasks:
  - name: Configuring sFlow Agent
    ce_sflow:
      agent_ip: 6.6.6.6
      provider: '{{ cli }}'

  - name: Configuring sFlow Collector
    ce_sflow:
      collector_id: 1
      collector_ip: 7.7.7.7
      collector_ip_vpn: vpn1
      collector_description: Collector1
      provider: '{{ cli }}'

  - name: Configure flow sampling.
    ce_sflow:
      sflow_interface: 10GE2/0/2
      sample_collector: 1
      sample_direction: inbound
      provider: '{{ cli }}'

  - name: Configure counter sampling.
    ce_sflow:
      sflow_interface: 10GE2/0/2
      counter_collector: 1
      counter_interval: 1000
      provider: '{{ cli }}'

Inputs

    
state:
    choices:
    - present
    - absent
    default: present
    description:
    - Determines whether the config should be present or not on the device.
    required: false

agent_ip:
    default: null
    description:
    - Specifies the IPv4/IPv6 address of an sFlow agent.
    required: false

source_ip:
    default: null
    description:
    - Specifies the source IPv4/IPv6 address of sFlow packets.
    required: false

rate_limit:
    default: null
    description:
    - Specifies the rate of sFlow packets sent from a card to the control plane. The value
      is an integer that ranges from 100 to 1500, in pps.
    required: false

sample_rate:
    default: null
    description:
    - Specifies the flow sampling rate in the format 1/rate. The value is an integer and
      ranges from 1 to 4294967295. The default value is 8192.
    required: false

collector_id:
    choices:
    - '1'
    - '2'
    default: null
    description:
    - Specifies the ID of an sFlow collector. This ID is used when you specify the collector
      in subsequent sFlow configuration.
    required: false

collector_ip:
    default: null
    description:
    - Specifies the IPv4/IPv6 address of the sFlow collector.
    required: false

export_route:
    choices:
    - enable
    - disable
    default: null
    description:
    - Configures the sFlow packets sent by the switch not to carry routing information.
    required: false

sample_length:
    default: null
    description:
    - Specifies the maximum length of sampled packets. The value is an integer and ranges
      from 18 to 512, in bytes. The default value is 128.
    required: false

collector_meth:
    choices:
    - meth
    - enhanced
    default: null
    description:
    - Configures the device to send sFlow packets through service interfaces, enhancing
      the sFlow packet forwarding capability. The enhanced parameter is optional. No matter
      whether you configure the enhanced mode, the switch determines to send sFlow packets
      through service cards or management port based on the routing information on the
      collector. When the value is meth, the device forwards sFlow packets at the control
      plane. When the value is enhanced, the device forwards sFlow packets at the forwarding
      plane to enhance the sFlow packet forwarding capacity.
    required: false

rate_limit_slot:
    default: null
    description:
    - Specifies the slot where the rate of output sFlow packets is limited. If this parameter
      is not specified, the rate of sFlow packets sent from all cards to the control plane
      is limited. The value is an integer or a string of characters.
    required: false

sflow_interface:
    default: null
    description:
    - Full name of interface for Flow Sampling or Counter. It must be a physical interface,
      Eth-Trunk, or Layer 2 subinterface.
    required: false

collector_ip_vpn:
    default: null
    description:
    - Specifies the name of a VPN instance. The value is a string of 1 to 31 case-sensitive
      characters, spaces not supported. When double quotation marks are used around the
      string, spaces are allowed in the string. The value C(_public_) is reserved and
      cannot be used as the VPN instance name.
    required: false

counter_interval:
    default: null
    description:
    - Indicates the counter sampling interval. The value is an integer that ranges from
      10 to 4294967295, in seconds. The default value is 20.
    required: false

forward_enp_slot:
    default: null
    description:
    - Enable the Embedded Network Processor (ENP) chip function. The switch uses the ENP
      chip to perform sFlow sampling, and the maximum sFlow sampling interval is 65535.
      If you set the sampling interval to be larger than 65535, the switch automatically
      restores it to 65535. The value is an integer or 'all'.
    required: false

sample_collector:
    default: null
    description:
    - Indicates the ID list of the collector.
    required: false

sample_direction:
    choices:
    - inbound
    - outbound
    - both
    default: null
    description:
    - Enables flow sampling in the inbound or outbound direction.
    required: false

counter_collector:
    default: null
    description:
    - Indicates the ID list of the counter collector.
    required: false

collector_udp_port:
    default: null
    description:
    - Specifies the UDP destination port number of sFlow packets. The value is an integer
      that ranges from 1 to 65535. The default value is 6343.
    required: false

collector_description:
    default: null
    description:
    - Specifies the description of an sFlow collector. The value is a string of 1 to 255
      case-sensitive characters without spaces.
    required: false

collector_datagram_size:
    default: null
    description:
    - Specifies the maximum length of sFlow packets sent from an sFlow agent to an sFlow
      collector. The value is an integer, in bytes. It ranges from 1024 to 8100. The default
      value is 1400.
    required: false

Outputs

changed:
  description: check to see if a change was made on the device
  returned: always
  sample: true
  type: boolean
end_state:
  description: k/v pairs of configuration after module execution
  returned: verbose mode
  sample:
    agent:
      family: ipv4
      ipv4Addr: 1.2.3.4
      ipv6Addr: null
  type: dict
existing:
  description: k/v pairs of existing configuration
  returned: verbose mode
  sample:
    agent: {}
  type: dict
proposed:
  description: k/v pairs of parameters passed into module
  returned: verbose mode
  sample:
    agent_ip: 6.6.6.6
    state: present
  type: dict
updates:
  description: commands sent to the device
  returned: always
  sample:
  - sflow agent ip 6.6.6.6
  type: list