cisco.nxos.nxos_bgp_templates module – BGP Templates resource module.

Note

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

To use it in a playbook, specify: cisco.nxos.nxos_bgp_templates.

New in cisco.nxos 4.2.0

Synopsis

  • This module manages BGP templates on devices running Cisco NX-OS.

Parameters

Parameter

Comments

config

dictionary

A list of BGP templates.

as_number

string

Autonomous System Number of the router.

neighbor

list / elements=dictionary

Configure BGP peer templates.

address_family

list / elements=dictionary

Configure an address-family for peer.

advertise_map

dictionary

Specify route-map for conditional advertisement.

exist_map

string

Condition route-map to advertise only when prefix in condition exists.

non_exist_map

string

Condition route-map to advertise only when prefix in condition does not exist.

route_map

string / required

Route-map name.

advertisement_interval

integer

Minimum interval between sending BGP routing updates.

afi

string / required

Address Family indicator.

Choices:

  • "ipv4"

  • "ipv6"

  • "link-state"

  • "l2vpn"

allowas_in

dictionary

Accept as-path with my AS present in it.

max_occurences

integer

Number of occurrences of AS number, default is 3.

set

boolean

Activate allowas-in property.

Choices:

  • false

  • true

as_override

boolean

Override matching AS-number while sending update.

Choices:

  • false

  • true

capability

dictionary

Advertise capability to the peer.

additional_paths

dictionary

Additional paths capability.

receive

string

Additional paths Receive capability.

Choices:

  • "enable"

  • "disable"

send

string

Additional paths Send capability.

Choices:

  • "enable"

  • "disable"

default_originate

dictionary

Originate a default toward this peer.

route_map

string

Route-map to specify criteria for originating default.

set

boolean

Set default-originate attribute.

Choices:

  • false

  • true

disable_peer_as_check

boolean

Disable checking of peer AS-number while advertising.

Choices:

  • false

  • true

filter_list

dictionary

Name of filter-list.

inbound

string

Apply policy to incoming routes.

outbound

string

Apply policy to outgoing routes.

inherit

dictionary

Inherit a peer-policy template.

peer_policy

string

Peer-policy template to inherit.

maximum_prefix

dictionary

Maximum number of prefixes from this neighbor.

generate_warning_threshold

integer

Threshold percentage at which to generate a warning.

max_prefix_limit

integer

Maximum prefix limit.

restart_interval

integer

Restart bgp connection after limit is exceeded.

warning_only

boolean

Only give a warning message when limit is exceeded.

Choices:

  • false

  • true

next_hop_self

dictionary

Set our address as nexthop (non-reflected).

all_routes

boolean

Set our address as nexthop for all routes.

Choices:

  • false

  • true

set

boolean

Set next-hop-self attribute.

Choices:

  • false

  • true

next_hop_third_party

boolean

Compute a third-party nexthop if possible.

Choices:

  • false

  • true

prefix_list

dictionary

Apply prefix-list.

inbound

string

Apply policy to incoming routes.

outbound

string

Apply policy to outgoing routes.

route_map

dictionary

Apply route-map to neighbor.

inbound

string

Name of policy to apply to incoming routes.

outbound

string

Name of policy to apply to outgoing routes.

route_reflector_client

boolean

Configure a neighbor as Route reflector client.

Choices:

  • false

  • true

safi

string

Sub Address Family indicator.

Choices:

  • "unicast"

  • "multicast"

  • "mvpn"

  • "evpn"

send_community

string

Send Community attribute to this neighbor.

Choices:

  • "standard"

  • "extended"

  • "both"

soft_reconfiguration_inbound

dictionary

Soft reconfiguration.

always

boolean

Always perform inbound soft reconfiguration.

Choices:

  • false

  • true

set

boolean

Set soft-reconfiguration inbound attribute.

Choices:

  • false

  • true

soo

string

Specify Site-of-origin extcommunity.

suppress_inactive

boolean

Advertise only active routes to peer.

Choices:

  • false

  • true

unsuppress_map

string

Route-map to selectively unsuppress suppressed routes.

weight

integer

Set default weight for routes from this neighbor.

bfd

dictionary

Bidirectional Fast Detection for the neighbor.

multihop

dictionary

Multihop session.

interval

dictionary

Configure BFD session interval parameters.

min_rx_interval

integer / required

Minimum RX interval.

multiplier

integer / required

Detect Multiplier.

tx_interval

integer / required

TX interval in milliseconds.

set

boolean

Set BFD multihop.

Choices:

  • false

  • true

set

boolean

Set BFD for this neighbor.

Choices:

  • false

  • true

singlehop

boolean

Single-hop session.

Choices:

  • false

  • true

bmp_activate_server

integer

Specify server ID for activating BMP monitoring for the peer.

capability

dictionary

Capability.

suppress_4_byte_as

boolean

Suppress 4-byte AS Capability.

Choices:

  • false

  • true

description

string

Neighbor specific descripion.

disable_connected_check

boolean

Disable check for directly connected peer.

Choices:

  • false

  • true

dont_capability_negotiate

boolean

Don’t negotiate capability with this neighbor.

Choices:

  • false

  • true

dscp

string

Set dscp value for tcp transport.

dynamic_capability

boolean

Dynamic Capability

Choices:

  • false

  • true

ebgp_multihop

integer

Specify multihop TTL for remote peer.

graceful_shutdown

dictionary

Graceful-shutdown for this neighbor.

activate

dictionary

Send graceful-shutdown community.

route_map

string

Apply route-map to modify attributes for outbound.

set

boolean

Set activate.

Choices:

  • false

  • true

inherit

dictionary

Inherit a template.

peer_session

string

Peer-session template to inherit.

local_as

string

Specify the local-as number for the eBGP neighbor.

log_neighbor_changes

dictionary

Log message for neighbor up/down event.

disable

boolean

Disable logging of neighbor up/down event.

Choices:

  • false

  • true

set

boolean

Set log-neighbor-changes.

Choices:

  • false

  • true

low_memory

dictionary

Behaviour in low memory situations.

exempt

boolean

Do not shutdown this peer when under memory pressure.

Choices:

  • false

  • true

name

string

Name of the BGP peer template.

password

dictionary

Configure a password for neighbor.

encryption

integer

0 specifies an UNENCRYPTED neighbor password.

3 specifies an 3DES ENCRYPTED neighbor password will follow.

7 specifies a Cisco type 7 ENCRYPTED neighbor password will follow.

key

string

Authentication password.

path_attribute

list / elements=dictionary

BGP path attribute optional filtering.

action

string

Action.

Choices:

  • "discard"

  • "treat-as-withdraw"

range

dictionary

Path attribute range.

end

integer

Path attribute range end value.

start

integer

Path attribute range start value.

type

integer

Path attribute type

remote_as

string

Specify Autonomous System Number of the neighbor.

remove_private_as

dictionary

Remove private AS number from outbound updates.

all

boolean

All.

Choices:

  • false

  • true

replace_as

boolean

Replace.

Choices:

  • false

  • true

set

boolean

Remove private AS.

Choices:

  • false

  • true

shutdown

boolean

Administratively shutdown this neighbor.

Choices:

  • false

  • true

timers

dictionary

Configure keepalive and hold timers.

holdtime

integer

Holdtime (seconds).

keepalive

integer

Keepalive interval (seconds).

transport

dictionary

BGP transport connection.

connection_mode

dictionary

Specify type of connection.

passive

boolean

Allow passive connection setup only.

Choices:

  • false

  • true

ttl_security

dictionary

Enable TTL Security Mechanism.

hops

integer

Specify hop count for remote peer.

update_source

string

Specify source of BGP session and updates.

running_config

string

This option is used only with state parsed.

The value of this option should be the output received from the NX-OS device by executing the command show running-config bgp | section ‘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.

Refer to examples for more details.

Choices:

  • "merged" ← (default)

  • "replaced"

  • "overridden"

  • "deleted"

  • "parsed"

  • "gathered"

  • "rendered"

Notes

Note

  • Tested against NX-OS 9.3.6.

  • Unsupported for Cisco MDS

  • This module works with connection network_cli and httpapi.

Examples

# Using merged

# Before state:
# --------------
#
# nxos9k# show running-config | section "^router bgp"
# nxos9k#

- name: Merge the provided configuration with the existing running configuration
  cisco.nxos.nxos_bgp_templates:
    config:
      as_number: 65536
      neighbor:
        - name: neighbor_tmplt_1
          address_family:
            - afi: ipv4
              safi: unicast
              advertise_map:
                route_map: rmap1
                non_exist_map: nemap1
              advertisement_interval: 60
              disable_peer_as_check: true
          bmp_activate_server: 2
          capability:
            suppress_4_byte_as: true
          description: Test_BGP_PEER_TEMPLATE_1
          local_as: 65536
          remote_as: 65001

        - name: neighbor_tmplt_2
          description: Test_BGP_PEER_TEMPLATE_2
          address_family:
            - afi: ipv4
              safi: multicast
              advertise_map:
                route_map: rmap1
                exist_map: emap1
              as_override: true
              filter_list:
                inbound: flist1
                outbound: flist2
          inherit:
            peer_session: psession1
          timers:
            holdtime: 100
            keepalive: 45
# Task Output:
# ------------
# before: {}
#
# commands:
#   - router bgp 65536
#   - template peer neighbor_tmplt_1
#   - bmp-activate-server 2
#   - capability suppress 4-byte-as
#   - description Test_BGP_PEER_TEMPLATE_1
#   - local-as 65536
#   - remote-as 65001
#   - address-family ipv4 unicast
#   - advertise-map rmap1 non-exist-map nemap1
#   - advertisement-interval 60
#   - disable-peer-as-check
#   - template peer neighbor_tmplt_2
#   - description Test_BGP_PEER_TEMPLATE_2
#   - inherit peer-session psession1
#   - timers 45 100
#   - address-family ipv4 multicast
#   - advertise-map rmap1 exist-map emap1
#   - as-override
#   - filter-list flist1 in
#   - filter-list flist2 out
#
# after:
#   as_number: "65536"
#   neighbor:
#     - name: neighbor_tmplt_1
#       address_family:
#         - afi: ipv4
#           safi: unicast
#           advertise_map:
#             non_exist_map: nemap1
#             route_map: rmap1
#           advertisement_interval: 60
#           disable_peer_as_check: true
#       bmp_activate_server: 2
#       capability:
#         suppress_4_byte_as: true
#       description: Test_BGP_PEER_TEMPLATE_1
#       local_as: "65536"
#       remote_as: "65001"
#
#     - name: neighbor_tmplt_2
#       description: Test_BGP_PEER_TEMPLATE_2
#       address_family:
#         - afi: ipv4
#           safi: multicast
#           advertise_map:
#             exist_map: emap1
#             route_map: rmap1
#           as_override: true
#           filter_list:
#             inbound: flist1
#             outbound: flist2
#       inherit:
#         peer_session: psession1
#       timers:
#         holdtime: 100
#         keepalive: 45

# After state:
# --------------
#
# nxos9k# show running-config | section "^router bgp"
# router bgp 65536
#   template peer neighbor_tmplt_1
#     capability suppress 4-byte-as
#     bmp-activate-server 2
#     description Test_BGP_PEER_TEMPLATE_1
#     local-as 65536
#     remote-as 65001
#     address-family ipv4 unicast
#      advertise-map rmap1 non-exist-map nemap1
#      advertisement-interval 60
#      disable-peer-as-check
#   template peer neighbor_tmplt_2
#     description Test_BGP_PEER_TEMPLATE_2
#     inherit peer-session psession1
#     timers 45 100
#     address-family ipv4 multicast
#      advertise-map rmap1 exist-map emap1
#      as-override
#      filter-list flist1 in
#      filter-list flist2 out

# Using replaced

# Before state:
# -------------
#
# nxos9k# show running-config | section "^router bgp"
# router bgp 65536
#   template peer neighbor_tmplt_1
#     capability suppress 4-byte-as
#     description Test_BGP_PEER_TEMPLATE_1
#     bmp-activate-server 2
#     local-as 65536
#     remote-as 65001
#     address-family ipv4 unicast
#      advertise-map rmap1 non-exist-map nemap1
#      advertisement-interval 60
#      disable-peer-as-check
#   template peer neighbor_tmplt_2
#     description Test_BGP_PEER_TEMPLATE_2
#     inherit peer-session psession1
#     timers 45 100
#     address-family ipv4 multicast
#      advertise-map rmap1 exist-map emap1
#      as-override
#      filter-list flist1 in
#      filter-list flist2 out

- name: Replace BGP templates configuration with provided configuration
  cisco.nxos.nxos_bgp_templates:
    config:
      as_number: 65536
      neighbor:
        - name: neighbor_tmplt_1
          address_family:
            - afi: ipv4
              safi: unicast
              advertise_map:
                route_map: rmap1
                non_exist_map: nemap1
              advertisement_interval: 60
              disable_peer_as_check: true
          inherit:
            peer_session: psession1
          description: Test_BGP_PEER_TEMPLATE_1
          local_as: 65537
    state: replaced

# Task output:
# ------------
#
# before:
#   as_number: "65536"
#   neighbor:
#     - name: neighbor_tmplt_1
#       address_family:
#         - afi: ipv4
#           safi: unicast
#           advertise_map:
#             non_exist_map: nemap1
#             route_map: rmap1
#           advertisement_interval: 60
#           disable_peer_as_check: true
#       bmp_activate_server: 2
#       capability:
#         suppress_4_byte_as: true
#       description: Test_BGP_PEER_TEMPLATE_1
#       local_as: "65536"
#       remote_as: "65001"
#
#     - name: neighbor_tmplt_2
#       description: Test_BGP_PEER_TEMPLATE_2
#       address_family:
#         - afi: ipv4
#           safi: multicast
#           advertise_map:
#             exist_map: emap1
#             route_map: rmap1
#           as_override: true
#           filter_list:
#             inbound: flist1
#             outbound: flist2
#       inherit:
#         peer_session: psession1
#       timers:
#         holdtime: 100
#         keepalive: 45
#
# commands:
#   - router bgp 65536
#   - template peer neighbor_tmplt_1
#   - no bmp-activate-server 2
#   - no capability suppress 4-byte-as
#   - inherit peer-session psession1
#   - local-as 65537
#   - no remote-as 65001
#
# after:
#   as_number: "65536"
#   neighbor:
#     - name: neighbor_tmplt_1
#       address_family:
#         - afi: ipv4
#           safi: unicast
#           advertise_map:
#             non_exist_map: nemap1
#             route_map: rmap1
#           advertisement_interval: 60
#           disable_peer_as_check: true
#       description: Test_BGP_PEER_TEMPLATE_1
#       inherit:
#         peer_session: psession1
#       local_as: "65537"
#
#     - name: neighbor_tmplt_2
#       description: Test_BGP_PEER_TEMPLATE_2
#       address_family:
#         - afi: ipv4
#           safi: multicast
#           advertise_map:
#             exist_map: emap1
#             route_map: rmap1
#           as_override: true
#           filter_list:
#             inbound: flist1
#             outbound: flist2
#       inherit:
#         peer_session: psession1
#       timers:
#         holdtime: 100
#         keepalive: 45

# After state:
# ------------
#
# nxos9k# show running-config | section "^router bgp"
# router bgp 65536
#   template peer neighbor_tmplt_1
#     inherit peer-session psession1
#     description Test_BGP_PEER_TEMPLATE_1
#     local-as 65537
#     address-family ipv4 unicast
#      advertise-map rmap1 non-exist-map nemap1
#      advertisement-interval 60
#      disable-peer-as-check
#   template peer neighbor_tmplt_2
#     description Test_BGP_PEER_TEMPLATE_2
#     inherit peer-session psession1
#     bmp-activate-server 2
#     timers 45 100
#     address-family ipv4 multicast
#      advertise-map rmap1 exist-map emap1
#      as-override
#      filter-list flist1 in
#      filter-list flist2 out

# Using overridden
#
# Before state:
# -------------
#
# nxos9k# show running-config | section "^router bgp"
# router bgp 65536
#   template peer neighbor_tmplt_1
#     capability suppress 4-byte-as
#     description Test_BGP_PEER_TEMPLATE_1
#     bmp-activate-server 2
#     local-as 65536
#     remote-as 65001
#     address-family ipv4 unicast
#      advertise-map rmap1 non-exist-map nemap1
#      advertisement-interval 60
#      disable-peer-as-check
#   template peer neighbor_tmplt_2
#     description Test_BGP_PEER_TEMPLATE_2
#     inherit peer-session psession1
#     timers 45 100
#     address-family ipv4 multicast
#      advertise-map rmap1 exist-map emap1
#      as-override
#      filter-list flist1 in
#      filter-list flist2 out

- name: Override BGP templates configuration with provided configuration
  cisco.nxos.nxos_bgp_templates:
    config:
      as_number: 65536
      neighbor:
        - name: neighbor_tmplt_1
          address_family:
            - afi: ipv4
              safi: unicast
              advertise_map:
                route_map: rmap1
                non_exist_map: nemap1
              advertisement_interval: 60
              disable_peer_as_check: true
          inherit:
            peer_session: psession1
          description: Test_BGP_PEER_TEMPLATE_1
          local_as: 65537
    state: overridden

# Task output:
# ------------
#
# before:
#   as_number: "65536"
#   neighbor:
#     - name: neighbor_tmplt_1
#       address_family:
#         - afi: ipv4
#           safi: unicast
#           advertise_map:
#             non_exist_map: nemap1
#             route_map: rmap1
#           advertisement_interval: 60
#           disable_peer_as_check: true
#       bmp_activate_server: 2
#       capability:
#         suppress_4_byte_as: true
#       description: Test_BGP_PEER_TEMPLATE_1
#       local_as: "65536"
#       remote_as: "65001"
#
#     - name: neighbor_tmplt_2
#       description: Test_BGP_PEER_TEMPLATE_2
#       address_family:
#         - afi: ipv4
#           safi: multicast
#           advertise_map:
#             exist_map: emap1
#             route_map: rmap1
#           as_override: true
#           filter_list:
#             inbound: flist1
#             outbound: flist2
#       inherit:
#         peer_session: psession1
#       timers:
#         holdtime: 100
#         keepalive: 45
#
# commands:
#   - router bgp 65536
#   - template peer neighbor_tmplt_1
#   - no bmp-activate-server 2
#   - no capability suppress 4-byte-as
#   - inherit peer-session psession1
#   - local-as 65537
#   - no remote-as 65001
#   - no template peer neighbor_tmplt_2
#
# after:
#   as_number: "65536"
#   neighbor:
#     - name: neighbor_tmplt_1
#       address_family:
#         - afi: ipv4
#           safi: unicast
#           advertise_map:
#             non_exist_map: nemap1
#             route_map: rmap1
#           advertisement_interval: 60
#           disable_peer_as_check: true
#       description: Test_BGP_PEER_TEMPLATE_1
#       inherit:
#         peer_session: psession1
#       local_as: "65537"

# After state:
# ------------
#
# nxos9k# show running-config | section "^router bgp"
# router bgp 65536
#   template peer neighbor_tmplt_1
#     inherit peer-session psession1
#     description Test_BGP_PEER_TEMPLATE_1
#     local-as 65537
#     address-family ipv4 unicast
#      advertise-map rmap1 non-exist-map nemap1
#      advertisement-interval 60
#      disable-peer-as-check

# Using deleted

# Before state:
# --------------
#
# nxos9k# show running-config | section "^router bgp"
# router bgp 65536
#   template peer neighbor_tmplt_1
#     capability suppress 4-byte-as
#     description Test_BGP_PEER_TEMPLATE_1
#     bmp-activate-server 2
#     local-as 65536
#     remote-as 65001
#     address-family ipv4 unicast
#      advertise-map rmap1 non-exist-map nemap1
#      advertisement-interval 60
#      disable-peer-as-check
#   template peer neighbor_tmplt_2
#     description Test_BGP_PEER_TEMPLATE_2
#     inherit peer-session psession1
#     timers 45 100
#     address-family ipv4 multicast
#      advertise-map rmap1 exist-map emap1
#      as-override
#      filter-list flist1 in
#      filter-list flist2 out

- name: Delete BGP configs handled by this module
  cisco.nxos.nxos_bgp_templates:
    state: deleted

# Task output:
# ------------
#
# before:
#   as_number: "65536"
#   neighbor:
#     - name: neighbor_tmplt_1
#       address_family:
#         - afi: ipv4
#           safi: unicast
#           advertise_map:
#             non_exist_map: nemap1
#             route_map: rmap1
#           advertisement_interval: 60
#           disable_peer_as_check: true
#       bmp_activate_server: 2
#       capability:
#         suppress_4_byte_as: true
#       description: Test_BGP_PEER_TEMPLATE_1
#       local_as: "65536"
#       remote_as: "65001"
#
#     - name: neighbor_tmplt_2
#       description: Test_BGP_PEER_TEMPLATE_2
#       address_family:
#         - afi: ipv4
#           safi: multicast
#           advertise_map:
#             exist_map: emap1
#             route_map: rmap1
#           as_override: true
#           filter_list:
#             inbound: flist1
#             outbound: flist2
#       inherit:
#         peer_session: psession1
#       timers:
#         holdtime: 100
#         keepalive: 45
#
# commands:
#   - router bgp 65536
#   - no template peer neighbor_tmplt_1
#   - no template peer neighbor_tmplt_2
#
# after: {}

# After state:
# -------------
# nxos9k# show running-config | section "^router bgp"
# nxos9k#

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

after

dictionary

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

dictionary

The configuration prior to the module execution.

Returned: when state is merged, replaced, overridden, deleted or purged

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: when state is merged, replaced, overridden, deleted or purged

Sample: ["router bgp 65536", "template peer neighbor_tmplt_1", "no bmp-activate-server 2", "no capability suppress 4-byte-as", "inherit peer-session psession1", "local-as 65537", "no remote-as 65001", "no template peer neighbor_tmplt_2"]

gathered

dictionary

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

dictionary

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: ["router bgp 65536", "template peer neighbor_tmplt_1", "bmp-activate-server 2", "no capability suppress 4-byte-as", "no template peer neighbor_tmplt_2"]

Authors

  • Nilashish Chakraborty (@NilashishC)