cisco.ios.ios_bfd_templates module – Bidirectional Forwarding Detection (BFD) templates configurations

Note

This module is part of the cisco.ios collection (version 11.3.0).

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

New in cisco.ios 11.3.0

Synopsis

  • Manages Bidirectional Forwarding Detection (BFD) templates configurations

Parameters

Parameter

Comments

config

list / elements=dictionary

A dictionary of bfd template options

authentication

dictionary

Configure authentication for the BFD template

keychain

string

Name of the key chain to use for authentication

type

string

Authentication type to use for BFD sessions

Choices:

  • "sha_1"

  • "md5"

  • "meticulous_md5"

  • "meticulous_sha_1"

dampening

dictionary

enables session dampening

half_life_period

integer

half-life period for the exponential decay algorithm, in minutes.

max_suppress_time

integer

The maximum amount of time a session can be suppressed, in minutes.

reuse_threshold

integer

The threshold at which a dampened session is allowed to be reused (taken out of dampening), in milliseconds.

suppress_threshold

integer

The threshold at which a session is suppressed (put into dampening), in milliseconds.

echo

boolean

enables the BFD echo function for all interfaces which uses this specific template.

Choices:

  • false

  • true

hop

string / required

type of template to be used

Choices:

  • "single_hop"

  • "multi_hop"

interval

dictionary

defines transmit interval between BFD packets

min_rx

integer

The minimum interval in milliseconds that the local system is capable of supporting between received BFD control packets

min_tx

integer

The minimum interval in milliseconds that the local system desires for transmitting BFD control packets

multiplier

integer

Specifies the number of consecutive BFD control packets that must be missed from a BFD peer before BFD declares that the peer is unavailable and the Layer 3 BFD peer is informed of the failure.

name

string / required

name of the BFD template to be used

running_config

string

This option is used only with state parsed.

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

The state parsed reads the configuration from running_config option and transforms it into Ansible structured data as per the resource module’s argspec and the value is then returned in the parsed key within the result.

state

string

The state the configuration should be left in

The states rendered, gathered and parsed does not perform any change on the device.

The state rendered will transform the configuration in config option to platform specific CLI commands which will be returned in the rendered key within the result. For state rendered active connection to remote host is not required.

The state gathered will fetch the running configuration from device and transform it into structured data in the format as per the resource module argspec and the value is returned in the gathered key within the result.

The state parsed reads the configuration from running_config option and transforms it into JSON format as per the resource module parameters and the value is returned in the parsed key within the result. The value of running_config option should be the same format as the output of command show running-config | section ^bfd-template executed on device. For state parsed active connection to remote host is not required.

The state deleted does not support or guarantee granular deletion of configuration the playbook should act as source of truth, and the desired state of the resouce is what the playbook should reflect. Use overridden or replaced to get extra configuration removed.

The state purged removes BFD templates completely using a single top-level no bfd-template command, which removes the entire template definition at once.

Choices:

  • "merged" ← (default)

  • "replaced"

  • "overridden"

  • "deleted"

  • "rendered"

  • "gathered"

  • "purged"

  • "parsed"

Notes

Note

  • Tested against Cisco IOS XE Software, Version 17.13.01a on CML

  • This module works with connection network_cli

  • For more information on using Ansible to manage network devices see the :ref:`Ansible Network Guide <network_guide>`

  • For more information on using Ansible to manage Cisco devices see the `Cisco integration page <https://www.ansible.com/integrations/networks/cisco>`_.

Examples

# Using merged
# Before state:
# -------------
# router-ios#show running-config | section ^bfd-template
# (no BFD templates configured)

- name: Merge provided configuration with device configuration
  cisco.ios.ios_bfd_templates:
    config:
      - name: template1
        hop: single_hop
        interval:
          min_tx: 200
          min_rx: 200
          multiplier: 3
        authentication:
          type: sha_1
          keychain: bfd_keychain
        echo: true
      - name: template2
        hop: multi_hop
        interval:
          min_tx: 500
          min_rx: 500
          multiplier: 5
        dampening:
          half_life_period: 30
          reuse_threshold: 2000
          suppress_threshold: 5000
          max_suppress_time: 120
    state: merged

# Commands Fired:
# ---------------
# bfd-template single-hop template1
#  interval min-tx 200 min-rx 200 multiplier 3
#  authentication sha-1 keychain bfd_keychain
#  echo
# bfd-template multi-hop template2
#  interval min-tx 500 min-rx 500 multiplier 5
#  dampening 30 2000 5000 120

# After state:
# ------------
# router-ios#show running-config | section ^bfd-template
# bfd-template single-hop template1
#  interval min-tx 200 min-rx 200 multiplier 3
#  authentication sha-1 keychain bfd_keychain
#  echo
# bfd-template multi-hop template2
#  interval min-tx 500 min-rx 500 multiplier 5
#  dampening 30 2000 5000 120

# Using replaced
# Before state:
# -------------
# router-ios#show running-config | section ^bfd-template
# bfd-template single-hop template1
#  interval min-tx 200 min-rx 200 multiplier 3
#  authentication sha-1 keychain bfd_keychain
#  echo
# bfd-template multi-hop template2
#  interval min-tx 500 min-rx 500 multiplier 5

- name: Replace device configuration of specified BFD templates with provided configuration
  cisco.ios.ios_bfd_templates:
    config:
      - name: template1
        hop: single_hop
        interval:
          min_tx: 300
          min_rx: 300
          multiplier: 4
        authentication:
          type: sha_1
          keychain: new_keychain
    state: replaced

# Commands Fired:
# ---------------
# bfd-template single-hop template1
#  no echo
#  interval min-tx 300 min-rx 300 multiplier 4
#  no authentication sha-1 keychain bfd_keychain
#  authentication sha-1 keychain new_keychain

# After state:
# ------------
# router-ios#show running-config | section ^bfd-template
# bfd-template single-hop template1
#  interval min-tx 300 min-rx 300 multiplier 4
#  authentication sha-1 keychain new_keychain
# bfd-template multi-hop template2
#  interval min-tx 500 min-rx 500 multiplier 5

# Using overridden
# Before state:
# -------------
# router-ios#show running-config | section ^bfd-template
# bfd-template single-hop template1
#  interval min-tx 200 min-rx 200 multiplier 3
# bfd-template multi-hop template2
#  interval min-tx 500 min-rx 500 multiplier 5
# bfd-template single-hop template3
#  echo

- name: Override device configuration with provided configuration
  cisco.ios.ios_bfd_templates:
    config:
      - name: template1
        hop: single_hop
        interval:
          min_tx: 300
          min_rx: 300
          multiplier: 5
        authentication:
          type: md5
          keychain: secure_key
    state: overridden

# Commands Fired:
# ---------------
# no bfd-template multi-hop template2
# no bfd-template single-hop template3
# bfd-template single-hop template1
#  interval min-tx 300 min-rx 300 multiplier 5
#  authentication md5 keychain secure_key

# After state:
# ------------
# router-ios#show running-config | section ^bfd-template
# bfd-template single-hop template1
#  interval min-tx 300 min-rx 300 multiplier 5
#  authentication md5 keychain secure_key

# Using deleted
# Before state:
# -------------
# router-ios#show running-config | section ^bfd-template
# bfd-template single-hop template1
#  interval min-tx 200 min-rx 200 multiplier 3
#  authentication sha-1 keychain bfd_keychain
#  echo
# bfd-template multi-hop template2
#  interval min-tx 500 min-rx 500 multiplier 5

- name: Delete specified BFD template
  cisco.ios.ios_bfd_templates:
    config:
      - name: template1
        hop: single_hop
    state: deleted

# Commands Fired:
# ---------------
# bfd-template single-hop template1
#  no echo
#  no interval min-tx 200 min-rx 200 multiplier 3
#  no authentication sha-1 keychain bfd_keychain

# After state:
# ------------
# router-ios#show running-config | section ^bfd-template
# bfd-template single-hop template1
# bfd-template multi-hop template2
#  interval min-tx 500 min-rx 500 multiplier 5

# Using deleted (to delete all BFD templates )
# Before state:
# -------------
# router-ios#show running-config | section ^bfd-template
# bfd-template single-hop template1
#  interval min-tx 200 min-rx 200 multiplier 3
# bfd-template multi-hop template2
#  interval min-tx 500 min-rx 500 multiplier 5

- name: Delete all BFD template configurations
  cisco.ios.ios_bfd_templates:
    state: deleted

# Commands Fired:
# ---------------
# bfd-template single-hop template1
#  no interval min-tx 200 min-rx 200 multiplier 3
# bfd-template multi-hop template2
#  no interval min-tx 500 min-rx 500 multiplier 5

# After state:
# ------------
# router-ios#show running-config | section ^bfd-template
# bfd-template single-hop template1
# bfd-template multi-hop template2

# Using purged
# Before state:
# -------------
# router-ios#show running-config | section ^bfd-template
# bfd-template single-hop template1
#  interval min-tx 200 min-rx 200 multiplier 3
# bfd-template multi-hop template2
#  interval min-tx 500 min-rx 500 multiplier 5

- name: Purge specified BFD template configurations (complete removal)
  cisco.ios.ios_bfd_templates:
    config:
      - name: template1
        hop: single_hop
    state: purged

# Commands Fired:
# ---------------
# no bfd-template single-hop template1

# After state:
# ------------
# router-ios#show running-config | section ^bfd-template
# bfd-template multi-hop template2
#  interval min-tx 500 min-rx 500 multiplier 5

# Using purged (to remove all BFD templates)
# Before state:
# -------------
# router-ios#show running-config | section ^bfd-template
# bfd-template single-hop template1
#  interval min-tx 200 min-rx 200 multiplier 3
#  authentication sha-1 keychain bfd_keychain
# bfd-template multi-hop template2
#  interval min-tx 500 min-rx 500 multiplier 5
# bfd-template single-hop template3
#  echo

- name: Purge all BFD template configurations (complete removal)
  cisco.ios.ios_bfd_templates:
    config: []
    state: purged

# Commands Fired:
# ---------------
# no bfd-template single-hop template1
# no bfd-template multi-hop template2
# no bfd-template single-hop template3

# After state:
# ------------
# router-ios#show running-config | section ^bfd-template
# (no BFD templates configured)

# Using rendered
- name: Render platform specific commands from task input using rendered state
  cisco.ios.ios_bfd_templates:
    config:
      - name: template1
        hop: single_hop
        interval:
          min_tx: 200
          min_rx: 200
          multiplier: 3
        authentication:
          type: meticulous_sha_1
          keychain: secure_chain
        echo: true
    state: rendered

# Module Execution Result:
# ------------------------
# "rendered": [
#     "bfd-template single-hop template1",
#     "interval min-tx 200 min-rx 200 multiplier 3",
#     "authentication meticulous-sha-1 keychain secure_chain",
#     "echo"
# ]

# Using gathered
- name: Gather BFD template configuration from the device
  cisco.ios.ios_bfd_templates:
    state: gathered

# Module Execution Result:
# ------------------------
# "gathered": [
#     {
#         "name": "template1",
#         "hop": "single_hop",
#         "interval": {
#             "min_tx": 200,
#             "min_rx": 200,
#             "multiplier": 3
#         },
#         "authentication": {
#             "type": "sha_1",
#             "keychain": "bfd_keychain"
#         },
#         "echo": true
#     }
# ]

# Using parsed
- name: Parse the provided configuration to structured format
  cisco.ios.ios_bfd_templates:
    running_config: |
      bfd-template single-hop template1
       interval min-tx 200 min-rx 200 multiplier 3
       authentication sha-1 keychain bfd_keychain
       echo
      bfd-template multi-hop template2
       dampening 30 2000 5000 120
    state: parsed

# Module Execution Result:
# ------------------------
# "parsed": [
#     {
#         "name": "template1",
#         "hop": "single_hop",
#         "interval": {
#             "min_tx": 200,
#             "min_rx": 200,
#             "multiplier": 3
#         },
#         "authentication": {
#             "type": "sha_1",
#             "keychain": "bfd_keychain"
#         },
#         "echo": true
#     },
#     {
#         "name": "template2",
#         "hop": "multi_hop",
#         "dampening": {
#             "half_life_period": 30,
#             "reuse_threshold": 2000,
#             "suppress_threshold": 5000,
#             "max_suppress_time": 120
#         }
#     }
# ]

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 after module execution.

Returned: when changed

Sample: ["This output will always be in the same format as the module argspec.\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: ["bfd-template single-hop template1", "interval min-tx 200 min-rx 200 multiplier 3", "authentication sha-1 keychain bfd_keychain", "echo"]

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 as per module argspec.

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 provided configuration in the task rendered in device native format (offline).

Returned: when state is rendered

Sample: ["bfd-template single-hop template1", "interval min-tx 200 min-rx 200 multiplier 3", "authentication sha-1 keychain bfd_keychain", "echo"]

Authors

  • Komal Desai (@komaldesai13)