.. _cisco.nxos.nxos_vrf_address_family_module: ********************************** cisco.nxos.nxos_vrf_address_family ********************************** **Resource module to configure VRF address family definitions.** Version added: 9.3.0 .. contents:: :local: :depth: 1 Synopsis -------- - This module provides declarative management of VRF definitions on Cisco NXOS. Parameters ---------- .. raw:: html
Parameter Choices/Defaults Comments
config
list / elements=dictionary
A list of device configurations for VRF address family.
address_families
list / elements=dictionary
Enable address family and enter its config mode - AFI/SAFI configuration
afi
string
    Choices:
  • ipv4
  • ipv6
Address Family Identifier (AFI)
export
list / elements=dictionary
VRF export
map
string
Route-map based VRF export
vrf
dictionary
Virtual Router Context
allow_vpn
boolean
    Choices:
  • no
  • yes
Allow re-importation of VPN imported routes
map_import
string
Route-map based VRF import
max_prefix
integer
Maximum prefix limit
import
list / elements=dictionary
VRF import
map
string
Route-map based VRF export
vrf
dictionary
Virtual Router Context
advertise_vpn
boolean
    Choices:
  • no
  • yes
Allow leaked routes to be advertised to VPN
map_import
string
Route-map based VRF import
max_prefix
integer
Maximum prefix limit
maximum
dictionary
Set a limit of routes
max_route_options
dictionary
Configure the options for maximum routes
threshold
dictionary
Configure threshold & its options
reinstall_threshold
integer
Threshold value (%) at which to reinstall routes back to VRF
threshold_value
integer
Threshold value (%) at which to generate a warning msg
warning_only
boolean
    Choices:
  • no
  • yes
Configure only give a warning message if limit is exceeded
max_routes
integer
Maximum number of routes allowed
route_target
list / elements=dictionary
Specify Target VPN Extended Communities
export
string
Export Target-VPN community
import
string
Import Target-VPN community
safi
string
    Choices:
  • multicast
  • unicast
Address Family modifier
name
string / required
Name of the VRF.
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 | section ^vrf.
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
    Choices:
  • parsed
  • gathered
  • deleted
  • purged
  • merged ←
  • replaced
  • rendered
  • overridden
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 ^vrf. connection to remote host is not required.

Notes ----- .. note:: - Tested against NX-OS 9.3.6. - This module works with connection ``network_cli`` and ``httpapi``. See https://docs.ansible.com/ansible/latest/network/user_guide/platform_nxos.html Examples -------- .. code-block:: yaml # Using merged # Before state: # ------------- # # nxos#show running-config | section ^vrf - name: Merge provided configuration with device configuration register: result cisco.nxos.nxos_vrf_address_family: config: - name: VRF1 address_families: - afi: ipv4 safi: unicast route_target: - export: "65512:200" maximum: max_routes: 500 max_route_options: threshold: threshold_value: 60 reinstall_threshold: 80 export: - map: "22" - vrf: allow_vpn: true map_import: "44" - vrf: allow_vpn: true - afi: ipv6 safi: unicast maximum: max_routes: 1000 route_target: - import: "65512:200" import: - map: "22" - vrf: advertise_vpn: true map_import: "44" - vrf: advertise_vpn: true state: merged # Task Output: # ------------ # before: {} # commands: # - vrf context VRF1 # - address-family ipv4 unicast # - maximum routes 500 60 reinstall 80 # - route-target export 65512:200 # - export map 22 # - export vrf default map 44 allow-vpn # - export vrf allow-vpn # - address-family ipv6 unicast # - maximum routes 1000 # - route-target import 65512:200 # - import map 22 # - import vrf default map 44 advertise-vpn # - import vrf advertise-vpn # after: # - address_families: # - afi: ipv4 # export: # - map: "22" # - vrf: # allow_vpn: true # map_import: "44" # - vrf: # allow_vpn: true # maximum: # max_route_options: # threshold: # reinstall_threshold: 80 # threshold_value: 60 # max_routes: 500 # route_target: # - export: 65512:200 # safi: unicast # - afi: ipv6 # import: # - map: "22" # - vrf: # advertise_vpn: true # map_import: "44" # - vrf: # advertise_vpn: true # maximum: # max_routes: 1000 # route_target: # - import: 65512:200 # safi: unicast # name: VRF1 # After state: # ------------ # # nxos#show running-config | section ^vrf # vrf context VRF1 # address-family ipv4 unicast # route-target export 65512:200 # export map 22 # export vrf default map 44 allow-vpn # export vrf allow-vpn # maximum routes 500 60 reinstall 80 # address-family ipv6 unicast # route-target import 65512:200 # import map 22 # import vrf default map 44 advertise-vpn # import vrf advertise-vpn # maximum routes 1000 # Using deleted # Before state: # ------------- # # nxos#show running-config | section ^vrf # vrf context VRF1 # address-family ipv4 unicast # route-target import 64512:200 # route-target export 64512:200 # export map 22 # export vrf default map 44 allow-vpn # export vrf allow-vpn # maximum routes 900 22 reinstall 44 - name: Delete given vrf address family configuration register: result cisco.nxos.nxos_vrf_address_family: config: - name: VRF1 address_families: - afi: ipv4 safi: unicast route_target: - import: 64512:200 export: - map: "22" maximum: max_routes: 900 max_route_options: threshold: threshold_value: 22 reinstall_threshold: 44 state: deleted # Task Output: # ------------ # # before: # - address_families: # - afi: ipv4 # export: # - map: "22" # - vrf: # allow_vpn: true # map_import: "44" # - vrf: # allow_vpn: true # maximum: # max_route_options: # threshold: # reinstall_threshold: 44 # threshold_value: 22 # max_routes: 900 # route_target: # - import: "64512:200" # - export: "64512:200" # safi: unicast # name: VRF1 # commands: # - vrf context VRF1 # - address-family ipv4 unicast # - no maximum routes 900 22 reinstall 44 # - no route-target import 64512:200 # - no export map 22 # after: # - address_families: # - afi: ipv4 # export: # - vrf: # allow_vpn: true # map_import: "44" # - vrf: # allow_vpn: true # route_target: # - export: "64512:200" # safi: unicast # name: VRF1 # Using purged # Before state: # ------------- # # nxos#show running-config | section ^vrf # vrf context VRF1 # address-family ipv4 unicast # route-target export 65512:200 # export map 22 # export vrf default map 44 allow-vpn # export vrf allow-vpn # maximum routes 500 60 reinstall 80 # address-family ipv6 unicast # route-target import 65512:200 # import map 22 # import vrf default map 44 advertise-vpn # import vrf advertise-vpn # maximum routes 1000 - name: Purge the configuration of VRF address family register: result cisco.nxos.nxos_vrf_address_family: config: - name: VRF1 address_families: - afi: ipv4 safi: unicast - afi: ipv6 safi: unicast state: purged # Task Output: # ------------ # # before: # - address_families: # - afi: ipv4 # export: # - map: "22" # - vrf: # allow_vpn: true # map_import: "44" # - vrf: # allow_vpn: true # maximum: # max_route_options: # threshold: # reinstall_threshold: 80 # threshold_value: 60 # max_routes: 500 # route_target: # - export: 65512:200 # safi: unicast # - afi: ipv6 # import: # - map: "22" # - vrf: # advertise_vpn: true # map_import: "44" # - vrf: # advertise_vpn: true # maximum: # max_routes: 1000 # route_target: # - import: 65512:200 # safi: unicast # name: VRF1 # commands: # - vrf context VRF1 # - no address-family ipv4 unicast # - no address-family ipv6 unicast # after: {} # Using overridden # Before state: # ------------- # # nxos#show running-config | section ^vrf # vrf context VRF1 # address-family ipv4 unicast # route-target import 64512:200 # address-family ipv6 unicast # route-target import 554832:500 - name: Override the provided configuration with the existing running configuration cisco.nxos.nxos_vrf_address_family: config: - name: VRF1 address_families: - afi: ipv6 safi: unicast route_target: - export: 65512:200 maximum: max_routes: 500 max_route_options: threshold: threshold_value: 60 reinstall_threshold: 80 export: - map: "22" - vrf: allow_vpn: true map_import: "44" - vrf: allow_vpn: true - name: temp address_families: - afi: ipv4 safi: unicast route_target: - import: 65512:200 maximum: max_routes: 1000 export: - map: "26" - vrf: allow_vpn: true map_import: "46" state: overridden # Task Output: # ------------ # # before: # - address_families: # - afi: ipv4 # route_target: # - import: 64512:200 # safi: unicast # - afi: ipv6 # route_target: # - import: 554832:500 # safi: unicast # name: VRF1 # # commands: # - vrf context VRF1 # - address-family ipv4 unicast # - no route-target import 64512:200 # - address-family ipv6 unicast # - maximum routes 500 60 reinstall 80 # - no route-target import 554832:500 # - route-target export 65512:200 # - export map 22 # - export vrf default map 44 allow-vpn # - export vrf allow-vpn # - vrf context temp # - address-family ipv4 unicast # - maximum routes 1000 # - route-target import 65512:200 # - export map 26 # - export vrf default map 46 allow-vpn # after: # - address_families: # - afi: ipv4 # safi: unicast # - afi: ipv6 # export: # - map: "22" # - vrf: # allow_vpn: true # map_import: "44" # - vrf: # allow_vpn: true # maximum: # max_route_options: # threshold: # reinstall_threshold: 80 # threshold_value: 60 # max_routes: 500 # route_target: # - export: 65512:200 # safi: unicast # name: VRF1 # - address_families: # - afi: ipv4 # export: # - map: "26" # - vrf: # allow_vpn: true # map_import: "46" # maximum: # max_routes: 1000 # route_target: # - import: 65512:200 # safi: unicast # name: temp # Using replaced # Before state: # ------------- # # nxos# show running-config | section ^vrf # vrf context VRF1 # address-family ipv4 unicast # route-target import 64512:200 # address-family ipv6 unicast # route-target import 554832:500 - name: Replaced state for VRF configuration cisco.nxos.nxos_vrf_global: config: vrfs: - ip: name_server: address_list: - 192.168.255.1 route: - destination: 192.168.255.1 source: 0.0.0.0/0 name: management - name: temp description: Test ip: auto_discard: true domain_list: - invalid.com - example.com domain_name: test.org state: replaced # Task Output: # ------------ # # before: # - address_families: # - afi: ipv4 # route_target: # - import: 64512:200 # safi: unicast # - afi: ipv6 # route_target: # - import: 554832:500 # safi: unicast # name: VRF1 # commands: # - vrf context VRF1 # - address-family ipv4 unicast # - no route-target import 64512:200 # - address-family ipv6 unicast # - maximum routes 500 60 reinstall 80 # - no route-target import 554832:500 # - route-target export 65512:200 # - export map 22 # - export vrf default map 44 allow-vpn # - export vrf allow-vpn # - vrf context temp # - address-family ipv4 unicast # - maximum routes 1000 # - route-target import 65512:200 # - export map 26 # - export vrf default map 46 allow-vpn # after: # - address_families: # - afi: ipv4 # safi: unicast # - afi: ipv6 # export: # - map: "22" # - vrf: # allow_vpn: true # map_import: "44" # - vrf: # allow_vpn: true # maximum: # max_route_options: # threshold: # reinstall_threshold: 80 # threshold_value: 60 # max_routes: 500 # route_target: # - export: 65512:200 # safi: unicast # name: VRF1 # - address_families: # - afi: ipv4 # export: # - map: "26" # - vrf: # allow_vpn: true # map_import: "46" # maximum: # max_routes: 1000 # route_target: # - import: 65512:200 # safi: unicast # name: temp # # After state: # ------------ # router-ios#show running-config | section ^vrf # vrf context VRF1 # address-family ipv6 unicast # route-target export 65512:200 # export map 22 # export vrf default map 44 allow-vpn # export vrf allow-vpn # vrf context temp # address-family ipv4 unicast # route-target import 65512:200 # export map 26 # export vrf default map 46 allow-vpn # maximum routes 1000 # Using gathered # Before state: # ------------- # # nxos#show running-config | section ^vrf # vrf context VRF1 # address-family ipv4 unicast # route-target export 65512:200 # export map 22 # export vrf default map 44 allow-vpn # export vrf allow-vpn # maximum routes 500 60 reinstall 80 # address-family ipv6 unicast # route-target import 65512:200 # import map 22 # import vrf default map 44 advertise-vpn # import vrf advertise-vpn # maximum routes 1000 - name: Gathered state for VRF configuration cisco.nxos.nxos_vrf_global: config: state: gathered # Task Output: # ------------ # # gathered: # - address_families: # - afi: ipv4 # export: # - map: "22" # - vrf: # allow_vpn: true # map_import: "44" # - vrf: # allow_vpn: true # maximum: # max_route_options: # threshold: # reinstall_threshold: 80 # threshold_value: 60 # max_routes: 500 # route_target: # - export: 65512:200 # safi: unicast # - afi: ipv6 # import: # - map: "22" # - vrf: # advertise_vpn: true # map_import: "44" # - vrf: # advertise_vpn: true # maximum: # max_routes: 1000 # route_target: # - import: 65512:200 # safi: unicast # name: VRF1 # Using rendered - name: Render provided configuration with device configuration register: result cisco.nxos.nxos_vrf_address_family: config: - name: VRF1 address_families: - afi: ipv6 safi: unicast route_target: - export: 65512:200 maximum: max_routes: 500 max_route_options: threshold: threshold_value: 60 reinstall_threshold: 80 export: - map: "22" - vrf: allow_vpn: true map_import: "44" - vrf: allow_vpn: true - name: temp address_families: - afi: ipv4 safi: unicast route_target: - import: 65512:200 maximum: max_routes: 1000 export: - map: "26" - vrf: allow_vpn: true map_import: "46" state: rendered # Task Output: # ------------ # # commands: # - vrf context VRF1 # - address-family ipv6 unicast # - maximum routes 500 60 reinstall 80 # - route-target export 65512:200 # - export map 22 # - export vrf default map 44 allow-vpn # - export vrf allow-vpn # - vrf context temp # - address-family ipv4 unicast # - maximum routes 1000 # - route-target import 65512:200 # - export map 26 # - export vrf default map 46 allow-vpn # Using Parsed # Parsed Config: # ------------- # vrf context VRF1 # address-family ipv4 unicast # route-target import 64512:200 # route-target export 64512:200 # export map 22 # export vrf default map 44 allow-vpn # export vrf allow-vpn # maximum routes 900 22 reinstall 44 # address-family ipv6 unicast # route-target import 554832:500 - name: Parse the commands for provided configuration register: result cisco.nxos.nxos_vrf_address_family: running_config: "{{ lookup('file', '_parsed.cfg') }}" state: parsed # Task Output: # ------------ # parsed: # - name: VRF1 # address_families: # - afi: ipv4 # safi: unicast # route_target: # - import: 64512:200 # - export: 64512:200 # export: # - map: "22" # - vrf: # allow_vpn: true # map_import: "44" # - vrf: # allow_vpn: true # maximum: # max_routes: 900 # max_route_options: # threshold: # threshold_value: 22 # reinstall_threshold: 44 # - afi: ipv6 # safi: unicast # route_target: # - import: 554832:500 Return Values ------------- Common return values are documented `here `_, the following are the fields unique to this module: .. raw:: html
Key Returned Description
after
list
when changed
The resulting configuration after module execution.

Sample:
This output will always be in the same format as the module argspec.
before
list
when state is merged, replaced, overridden, deleted or purged
The configuration prior to the module execution.

Sample:
This output will always be in the same format as the module argspec.
commands
list
when state is merged, replaced, overridden, deleted or purged
The set of commands pushed to the remote device.

Sample:
['vrf context management', 'address-family ipv4 unicast', 'maximum routes 500 60 reinstall 80']
gathered
list
when state is gathered
Facts about the network resource gathered from the remote device as structured data.

Sample:
This output will always be in the same format as the module argspec.
parsed
list
when state is parsed
The device native config provided in running_config option parsed into structured data as per module argspec.

Sample:
This output will always be in the same format as the module argspec.
rendered
list
when state is rendered
The provided configuration in the task rendered in device-native format (offline).

Sample:
['vrf context test1', 'address-family ipv6 unicast', 'route-target export 65512:200']


Status ------ Authors ~~~~~~~ - Vinay Mulugund (@roverflow)