cisco.ios.ios_flow_monitor_interfaces module – Resource module to configure per-interface flow monitor assignments on Cisco IOS XE.

Note

This module is part of the cisco.ios collection (version 11.7.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 cisco.ios.

To use it in a playbook, specify: cisco.ios.ios_flow_monitor_interfaces.

New in cisco.ios 11.7.0

Synopsis

  • This module manages the per-interface ip flow monitor configuration on Cisco IOS XE devices.

  • It assigns flow monitors (with a sampler and direction) to interfaces.

  • Flow monitor and sampler names referenced here must already exist on the device; use cisco.ios.ios_flow_monitor_global to create them.

Aliases: flow_monitor_interfaces

Parameters

Parameter

Comments

config

list / elements=dictionary

A list of interfaces with flow monitor assignments.

flow_monitors

list / elements=dictionary

List of flow monitor assignments on this interface.

direction

string / required

Traffic direction to monitor.

Choices:

  • "input"

  • "output"

monitor

string / required

Name of the flow monitor to apply.

protocol

string

IP protocol family for the flow monitor assignment.

Use ipv6 to assign the monitor to IPv6 traffic (ipv6 flow monitor ...).

Defaults to ip for standard IPv4 monitoring.

Choices:

  • "ip" ← (default)

  • "ipv6"

sampler

string

Name of the sampler to use with this monitor.

Optional, an unsampled monitor can be assigned without a sampler.

name

string / required

Name of the interface, e.g. GigabitEthernet0/1, Port-channel21.800.

Short interface names like Gi0/1 are normalized to the full name.

running_config

string

This option is used only with state parsed.

The value of this option should be the output received from the IOS XE device by executing the command show running-config | section ^interface.

The state parsed reads the configuration from running_config option and transforms it into Ansible structured data as per the resource module’s argspec.

state

string

The state the configuration should be left in.

State merged merges the provided flow monitor assignments into existing interface config.

State replaced replaces the flow monitor assignments for specified interfaces only.

State overridden replaces flow monitor assignments across all interfaces.

State deleted removes the specified (or all) flow monitor assignments.

State rendered, gathered and parsed do not perform any change on the device.

Choices:

  • "merged" ← (default)

  • "replaced"

  • "overridden"

  • "deleted"

  • "rendered"

  • "gathered"

  • "parsed"

Notes

Note

  • Tested against Cisco IOS XE.

  • This module works with connection network_cli. See https://docs.ansible.com/ansible/latest/network/user_guide/platform_ios.html

  • Short interface names (e.g. Gi1/0/1) are normalized and are compared with the full names on the device.

  • A protocol=ipv6 assignment needs IPv6 routing enabled (ipv6 unicast-routing) and a flow monitor whose record matches IPv6 fields. Otherwise IOS XE drops the ipv6 flow monitor line without an error and the module reports the assignment as changed on every run.

  • A flow record that matches both IPv4 and IPv6 fields cannot be attached to an interface, IOS XE refuses it with Unsupported key field. Use one flow monitor for ip and another for ipv6 on the same interface.

  • The module examples use callback plugin (stdout_callback = yaml) to generate task output in yaml format.

Examples

# Using state: merged

# Before state:
# router# show running-config | section ^interface
# interface GigabitEthernet1
#  ip address 192.0.2.10 255.255.255.0

- name: Assign flow monitors to interfaces
  cisco.ios.ios_flow_monitor_interfaces:
    config:
      - name: GigabitEthernet1
        flow_monitors:
          - monitor: FLOW_MONITOR_IN
            sampler: FLOW_SAMPLER
            direction: input
          - monitor: FLOW_MONITOR_OUT
            sampler: FLOW_SAMPLER
            direction: output
    state: merged

# Commands fired:
# interface GigabitEthernet1
#  ip flow monitor FLOW_MONITOR_IN sampler FLOW_SAMPLER input
#  ip flow monitor FLOW_MONITOR_OUT sampler FLOW_SAMPLER output

# Using state: deleted

- name: Remove flow monitors from specific interfaces
  cisco.ios.ios_flow_monitor_interfaces:
    config:
      - name: GigabitEthernet1
    state: deleted

# Using state: deleted — remove all

- name: Remove all interface flow monitor assignments
  cisco.ios.ios_flow_monitor_interfaces:
    state: deleted

# Using state: replaced

# Before state:
# interface GigabitEthernet1
#  ip flow monitor OLD_MONITOR sampler FLOW_SAMPLER input
#  ip flow monitor OLD_MONITOR sampler FLOW_SAMPLER output

- name: Replace flow monitors on GigabitEthernet1
  cisco.ios.ios_flow_monitor_interfaces:
    config:
      - name: GigabitEthernet1
        flow_monitors:
          - monitor: FLOW_MONITOR_IN
            sampler: FLOW_SAMPLER
            direction: input
          - monitor: FLOW_MONITOR_OUT
            sampler: FLOW_SAMPLER
            direction: output
    state: replaced

# Commands fired:
# interface GigabitEthernet1
#  no ip flow monitor OLD_MONITOR sampler FLOW_SAMPLER input
#  no ip flow monitor OLD_MONITOR sampler FLOW_SAMPLER output
#  ip flow monitor FLOW_MONITOR_IN sampler FLOW_SAMPLER input
#  ip flow monitor FLOW_MONITOR_OUT sampler FLOW_SAMPLER output

# Using state: parsed

- name: Parse interface config into structured data
  cisco.ios.ios_flow_monitor_interfaces:
    running_config: |
      interface GigabitEthernet1
       ip address 192.0.2.10 255.255.255.0
       ip flow monitor FLOW_MONITOR_IN sampler FLOW_SAMPLER input
       ip flow monitor FLOW_MONITOR_OUT sampler FLOW_SAMPLER output
    state: parsed

# Using state: merged — with IPv6 monitor

- name: Assign IPv6 flow monitor to interface
  cisco.ios.ios_flow_monitor_interfaces:
    config:
      - name: GigabitEthernet1
        flow_monitors:
          - monitor: FLOW_MONITOR_V6
            sampler: FLOW_SAMPLER
            direction: input
            protocol: ipv6
    state: merged

# Commands fired:
# interface GigabitEthernet1
#  ipv6 flow monitor FLOW_MONITOR_V6 sampler FLOW_SAMPLER input

# Using state: gathered

- name: Gather flow monitor interface assignments
  cisco.ios.ios_flow_monitor_interfaces:
    state: gathered

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 of the parameters above.\n"]

before

list / elements=string

The configuration prior to the module invocation.

Returned: always

Sample: ["This output will always be in the same format as the module argspec.\n"]

commands

list / elements=string

The set of commands pushed to the remote device.

Returned: always

Sample: ["interface GigabitEthernet1", "ip flow monitor FLOW_MONITOR_IN sampler FLOW_SAMPLER input", "ip flow monitor FLOW_MONITOR_OUT sampler FLOW_SAMPLER output"]

gathered

list / elements=string

Facts about the network resource gathered from the remote device as structured data.

Returned: when state is gathered

Sample: ["This output will always be in the same format as the module argspec.\n"]

parsed

list / elements=string

The device native config provided in running_config option, parsed into structured data.

Returned: when state is parsed

Sample: ["This output will always be in the same format as the module argspec.\n"]

rendered

list / elements=string

The set of CLI commands generated from the value of state=rendered option.

Returned: when state is rendered

Sample: ["interface GigabitEthernet1", "ip flow monitor FLOW_MONITOR_IN sampler FLOW_SAMPLER input"]

Authors

  • Jørgen Spange (@jorgenspange)