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 monitorconfiguration 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 |
|---|---|
A list of interfaces with flow monitor assignments. |
|
List of flow monitor assignments on this interface. |
|
Traffic direction to monitor. Choices:
|
|
Name of the flow monitor to apply. |
|
IP protocol family for the flow monitor assignment. Use Defaults to Choices:
|
|
Name of the sampler to use with this monitor. Optional, an unsampled monitor can be assigned without a sampler. |
|
Name of the interface, e.g. GigabitEthernet0/1, Port-channel21.800. Short interface names like Gi0/1 are normalized to the full name. |
|
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 |
|
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:
|
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.htmlShort interface names (e.g. Gi1/0/1) are normalized and are compared with the full names on the device.
A
protocol=ipv6assignment needs IPv6 routing enabled (ipv6 unicast-routing) and a flow monitor whose record matches IPv6 fields. Otherwise IOS XE drops theipv6 flow monitorline 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 foripand another foripv6on 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 |
|---|---|
The resulting configuration module invocation. Returned: when changed Sample: |
|
The configuration prior to the module invocation. Returned: always Sample: |
|
The set of commands pushed to the remote device. Returned: always Sample: |
|
Facts about the network resource gathered from the remote device as structured data. Returned: when state is Sample: |
|
The device native config provided in running_config option, parsed into structured data. Returned: when state is Sample: |
|
The set of CLI commands generated from the value of state=rendered option. Returned: when state is Sample: |