Skip to content

eos_bgp_address_family

Collection Note

This module is part of the arista.eos collection. To install the collection, use:

ansible-galaxy collection install arista.eos
Added in version 1.4.0.

Synopsis

  • This module configures and manages the attributes of BGP AF on Arista EOS platforms.

Parameters

Parameter Defaults / Choices Comments
config
dict
Configurations for BGP address family.
config.address_family Enable address family and enter its config mode
config.as_number Autonomous system number.
running_config
str
This option is used only with state I(parsed).
The value of this option should be the output received from the EOS device by executing the command B(show running-config | section bgp).
The state I(parsed) reads the configuration from C(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 I(parsed) key within the result.
state
str
Default: merged
Choices: deleted, merged, overridden, replaced, gathered, rendered, parsed
The state the configuration should be left in.

Notes

Note

  • Tested against Arista EOS 4.24.6F
  • This module works with connection C(network_cli). See the L(EOS Platform Options,eos_platform_options).

Examples

# Using Merged

# Before state:
# -------------
# veos(config)#show running-config | section bgp
# veos(config)#

- name: Merge provided configuration with device configuration
  arista.eos.eos_bgp_address_family:
    config:
      as_number: "10"
      address_family:
        - afi: "ipv4"
          redistribute:
            - protocol: "ospfv3"
              ospf_route: "external"
          network:
            - address: "1.1.1.0/24"
            - address: "1.5.1.0/24"
              route_map: "MAP01"
        - afi: "ipv6"
          bgp_params:
            additional_paths: "receive"
          neighbor:
            - peer: "peer2"
              default_originate:
                always: true
        - afi: "ipv6"
          redistribute:
            - protocol: "isis"
              isis_level: "level-2"
          route_target:
            mode: "export"
            target: "33:11"
          vrf: "vrft"
    state: merged


# Task output:
# ------------
# before: {}
#
# commands:
# - router bgp 10
# - address-family ipv4
# - redistribute ospfv3 match external
# - network 1.1.1.0/24
# - network 1.5.1.0/24 route-map MAP01
# - exit
# - address-family ipv6
# - neighbor peer2 default-originate always
# - bgp additional-paths receive
# - exit
# - vrf vrft
# - address-family ipv6
# - redistribute isis level-2
# - route-target export 33:11
# - exit
# - exit
#
# after:
#     address_family:
#     - afi: ipv4
#       neighbor:
#       - activate: true
#         peer: 1.1.1.1
#       network:
#       - address: 1.1.1.0/24
#       - address: 1.5.1.0/24
#         route_map: MAP01
#       redistribute:
#       - ospf_route: external
#         protocol: ospfv3
#     - afi: ipv6
#       bgp_params:
#         additional_paths: receive
#       neighbor:
#       - activate: true
#         default_originate:
#           always: true
#         peer: peer2
#     - afi: ipv6
#       redistribute:
#       - isis_level: level-2
#         protocol: isis
#       route_target:
#         action: export
#         target: '33:11'
#       vrf: vrft
#     as_number: '10'
#     "before": {},
#     "changed": true,

# After state:
# ------------
# veos(config-router-bgp)#show running-config | section bgp
# router bgp 10
#    neighbor peer2 peer group
#    neighbor peer2 maximum-routes 12000
#    neighbor 1.1.1.1 maximum-routes 12000
#    !
#    address-family ipv4
#       neighbor 1.1.1.1 activate
#       network 1.1.1.0/24
#       network 1.5.1.0/24 route-map MAP01
#       redistribute ospfv3 match external
#    !
#    address-family ipv6
#       bgp additional-paths receive
#       neighbor peer2 activate
#       neighbor peer2 default-originate always
#    !
#    vrf vrft
#       address-family ipv6
#          route-target export 33:11
#          redistribute isis level-2

# Using replaced

# Before state:
# -------------
# veos(config-router-bgp)#show running-config | section bgp
# router bgp 10
#    neighbor peer2 peer group
#    neighbor peer2 maximum-routes 12000
#    neighbor 1.1.1.1 maximum-routes 12000
#    !
#    address-family ipv4
#       neighbor 1.1.1.1 activate
#       network 1.1.1.0/24
#       network 1.5.1.0/24 route-map MAP01
#       redistribute ospfv3 match external
#    !
#    address-family ipv6
#       bgp additional-paths receive
#       neighbor peer2 activate
#       neighbor peer2 default-originate always
#    !
#    vrf vrft
#       address-family ipv6
#          route-target export 33:11
#          redistribute isis level-2

- name: Replace running config section with provided config
  arista.eos.eos_bgp_address_family:
    config:
      as_number: "10"
      address_family:
        - afi: "ipv6"
          vrf: "vrft"
          redistribute:
            - protocol: "ospfv3"
              ospf_route: "external"
        - afi: "ipv6"
          redistribute:
            - protocol: "isis"
              isis_level: "level-2"
    state: replaced

# Task output:
# ------------
# before:
#     address_family:
#     - afi: ipv4
#       neighbor:
#       - activate: true
#         peer: 1.1.1.1
#       network:
#       - address: 1.1.1.0/24
#       - address: 1.5.1.0/24
#         route_map: MAP01
#       redistribute:
#       - ospf_route: external
#         protocol: ospfv3
#     - afi: ipv6
#       bgp_params:
#         additional_paths: receive
#       neighbor:
#       - activate: true
#         default_originate:
#           always: true
#         peer: peer2
#     - afi: ipv6
#       redistribute:
#       - isis_level: level-2
#         protocol: isis
#       route_target:
#         action: export
#         target: '33:11'
#       vrf: vrft
#     as_number: '10'
#
# commands:
# - router bgp 10
# - vrf vrft
# - address-family ipv6
# - redistribute ospfv3 match external
# - no redistribute isis level-2
# - no route-target export 33:11
# - exit
# - exit
# - address-family ipv6
# - redistribute isis level-2
# - no neighbor peer2 activate
# - no bgp additional-paths receive
# - exit
#
# after:
#     address_family:
#     - afi: ipv4
#       neighbor:
#       - activate: true
#         peer: 1.1.1.1
#       network:
#       - address: 1.1.1.0/24
#       - address: 1.5.1.0/24
#         route_map: MAP01
#       redistribute:
#       - ospf_route: external
#         protocol: ospfv3
#     - afi: ipv6
#       neighbor:
#       - default_originate:
#           always: true
#         peer: peer2
#       redistribute:
#       - isis_level: level-2
#         protocol: isis
#     - afi: ipv6
#       redistribute:
#       - ospf_route: external
#         protocol: ospfv3
#       vrf: vrft
#     as_number: '10'

# After state:
# ------------
# veos(config-router-bgp)#show running-config | section bgp
# router bgp 10
#    neighbor peer2 peer group
#    neighbor peer2 maximum-routes 12000
#    neighbor 1.1.1.1 maximum-routes 12000
#    !
#    address-family ipv4
#       neighbor 1.1.1.1 activate
#       network 1.1.1.0/24
#       network 1.5.1.0/24 route-map MAP01
#       redistribute ospfv3 match external
#    !
#    address-family ipv6
#       neighbor peer2 default-originate always
#       redistribute isis level-2
#    !
#    vrf vrft
#       address-family ipv6
#          redistribute ospfv3 match external

# Using overridden (overriding af at global context):

# Before state:
# -------------
# veos(config-router-bgp)#show running-config | section bgp
# router bgp 10
#    neighbor peer2 peer group
#    neighbor peer2 maximum-routes 12000
#    neighbor 1.1.1.1 maximum-routes 12000
#    !
#    address-family ipv4
#       neighbor 1.1.1.1 activate
#       network 1.1.1.0/24
#       network 1.5.1.0/24 route-map MAP01
#       redistribute ospfv3 match external
#    !
#    address-family ipv6
#       neighbor peer2 default-originate always
#       redistribute isis level-2
#    !
#    vrf vrft
#       address-family ipv6
#          redistribute ospfv3 match external

- name: Override running config with provided config
  arista.eos.eos_bgp_address_family:
    config:
      as_number: "10"
      address_family:
        - afi: "ipv4"
          bgp_params:
            additional_paths: "receive"
          neighbor:
            - peer: "peer2"
              default_originate:
                always: true
    state: overridden


#
# Task output:
# ------------
# before:
#     address_family:
#     - afi: ipv4
#       neighbor:
#       - activate: true
#         peer: 1.1.1.1
#       network:
#       - address: 1.1.1.0/24
#       - address: 1.5.1.0/24
#         route_map: MAP01
#       redistribute:
#       - ospf_route: external
#         protocol: ospfv3
#     - afi: ipv6
#       neighbor:
#       - default_originate:
#           always: true
#         peer: peer2
#       redistribute:
#       - isis_level: level-2
#         protocol: isis
#     - afi: ipv6
#       redistribute:
#       - ospf_route: external
#         protocol: ospfv3
#       vrf: vrft
#     as_number: '10'
#
# commands:
# - router bgp 10
# - address-family ipv4
# - no redistribute ospfv3 match external
# - no network 1.1.1.0/24
# - no network 1.5.1.0/24 route-map MAP01
# - neighbor peer2 default-originate always
# - no neighbor 1.1.1.1 activate
# - bgp additional-paths receive
# - exit
# - no address-family ipv6
#
# after:
#     address_family:
#     - afi: ipv4
#       bgp_params:
#         additional_paths: receive
#       neighbor:
#       - default_originate:
#           always: true
#         peer: peer2
#     - afi: ipv6
#       redistribute:
#       - ospf_route: external
#         protocol: ospfv3
#       vrf: vrft
#     as_number: '10'

# After state:
# ------------
# veos(config-router-bgp)#show running-config | section bgp
# router bgp 10
#    neighbor peer2 peer group
#    neighbor peer2 maximum-routes 12000
#    neighbor 1.1.1.1 maximum-routes 12000
#    !
#    address-family ipv4
#       bgp additional-paths receive
#       neighbor peer2 default-originate always
#    !
#    vrf vrft
#       address-family ipv6
#          redistribute ospfv3 match external

# using Overridden (overridding af in vrf context):

# Before state:
# -------------
# veos(config-router-bgp)#show running-config | section bgp
# router bgp 10
#    neighbor peer2 peer group
#    neighbor peer2 maximum-routes 12000
#    neighbor 1.1.1.1 maximum-routes 12000
#    !
#    address-family ipv4
#       bgp additional-paths receive
#       neighbor peer2 default-originate always
#       no neighbor 1.1.1.1 activate
#       network 1.1.1.0/24
#       network 1.5.1.0/24 route-map MAP01
#       redistribute ospfv3 match external
#    !
#    address-family ipv6
#       bgp additional-paths receive
#       neighbor peer2 default-originate always
#    !
#    vrf vrft
#       address-family ipv6
#          route-target export 33:11
#          redistribute isis level-2
#          redistribute ospfv3 match external

- name: Override running config with provided config
  arista.eos.eos_bgp_address_family:
    config:
      as_number: "10"
      address_family:
        - afi: "ipv4"
          bgp_params:
            additional_paths: "receive"
          neighbor:
            - peer: "peer2"
              default_originate:
                always: true
          vrf: vrft
    state: overridden

# Task output:
# ------------
# before:
#     address_family:
#     - afi: ipv4
#       bgp_params:
#         additional_paths: receive
#       neighbor:
#       - default_originate:
#           always: true
#         peer: peer2
#       network:
#       - address: 1.1.1.0/24
#       - address: 1.5.1.0/24
#         route_map: MAP01
#       redistribute:
#       - ospf_route: external
#         protocol: ospfv3
#     - afi: ipv6
#       bgp_params:
#         additional_paths: receive
#       neighbor:
#       - default_originate:
#           always: true
#         peer: peer2
#     - afi: ipv6
#       redistribute:
#       - isis_level: level-2
#         protocol: isis
#       - ospf_route: external
#         protocol: ospfv3
#       route_target:
#         action: export
#         target: '33:11'
#       vrf: vrft
#     as_number: '10'
#
# commands:
# - router bgp 10
# - vrf vrft
# - address-family ipv4
# - neighbor peer2 default-originate always
# - bgp additional-paths receive
# - exit
# - exit
# - vrf vrft
# - no address-family ipv6
#
# after:
#     address_family:
#     - afi: ipv4
#       bgp_params:
#         additional_paths: receive
#       neighbor:
#       - default_originate:
#           always: true
#         peer: peer2
#       network:
#       - address: 1.1.1.0/24
#       - address: 1.5.1.0/24
#         route_map: MAP01
#       redistribute:
#       - ospf_route: external
#         protocol: ospfv3
#     - afi: ipv6
#       bgp_params:
#         additional_paths: receive
#       neighbor:
#       - default_originate:
#           always: true
#         peer: peer2
#     - afi: ipv4
#       bgp_params:
#         additional_paths: receive
#       vrf: vrft
#     as_number: '10'

# After state:
# ------------
# veos(config-router-bgp)#show running-config | section bgp
# router bgp 10
#    neighbor peer2 peer group
#    neighbor peer2 maximum-routes 12000
#    neighbor 1.1.1.1 maximum-routes 12000
#    !
#    address-family ipv4
#       bgp additional-paths receive
#       neighbor peer2 default-originate always
#       network 1.1.1.0/24
#       network 1.5.1.0/24 route-map MAP01
#       redistribute ospfv3 match external
#    !
#    address-family ipv6
#       bgp additional-paths receive
#       neighbor peer2 default-originate always
#    !
#    vrf vrft
#       address-family ipv4
#          bgp additional-paths receive

# Using deleted

# Before state:
# -------------
# veos(config-router-bgp)#show running-config | section bgp
# router bgp 10
#    neighbor peer2 peer group
#    neighbor peer2 maximum-routes 12000
#    neighbor 1.1.1.1 maximum-routes 12000
#    !
#    address-family ipv4
#       bgp additional-paths receive
#       neighbor peer2 default-originate always
#       no neighbor 1.1.1.1 activate
#       network 1.1.1.0/24
#       network 1.5.1.0/24 route-map MAP01
#       redistribute ospfv3 match external
#    !
#    address-family ipv6
#       bgp additional-paths receive
#       neighbor peer2 default-originate always
#    !
#    vrf vrft
#       address-family ipv4
#          bgp additional-paths receive

- name: Delete running config for provided afi
  arista.eos.eos_bgp_address_family:
    config:
      as_number: "10"
      address_family:
        - afi: "ipv6"
          vrf: "vrft"
        - afi: "ipv6"
    state: deleted

# Task output:
# ------------
# before:
#     address_family:
#     - afi: ipv4
#       bgp_params:
#         additional_paths: receive
#       neighbor:
#       - default_originate:
#           always: true
#         peer: peer2
#       network:
#       - address: 1.1.1.0/24
#       - address: 1.5.1.0/24
#         route_map: MAP01
#       redistribute:
#       - ospf_route: external
#         protocol: ospfv3
#     - afi: ipv6
#       bgp_params:
#         additional_paths: receive
#       neighbor:
#       - default_originate:
#           always: true
#         peer: peer2
#     - afi: ipv4
#       bgp_params:
#         additional_paths: receive
#       vrf: vrft
#     as_number: '10'
#
# after:
#     address_family:
#     - afi: ipv4
#       bgp_params:
#         additional_paths: receive
#       neighbor:
#       - default_originate:
#           always: true
#         peer: peer2
#       network:
#       - address: 1.1.1.0/24
#       - address: 1.5.1.0/24
#         route_map: MAP01
#       redistribute:
#       - ospf_route: external
#         protocol: ospfv3
#     - afi: ipv4
#       bgp_params:
#         additional_paths: receive
#       vrf: vrft
#     as_number: '10'

# After state:
# ------------
# veos(config-router-bgp)#show running-config | section bgp
# router bgp 10
#    neighbor peer2 peer group
#    neighbor peer2 maximum-routes 12000
#    neighbor 1.1.1.1 maximum-routes 12000
#    !
#    address-family ipv4
#       bgp additional-paths receive
#       neighbor peer2 default-originate always
#       no neighbor 1.1.1.1 activate
#       network 1.1.1.0/24
#       network 1.5.1.0/24 route-map MAP01
#       redistribute ospfv3 match external
#    !
#    vrf vrft
#       address-family ipv4
#          bgp additional-paths receive


# Using parsed

# parsed.cfg
# ----------
# router bgp 10
#    neighbor n2 peer group
#    neighbor n2 next-hop-unchanged
#    neighbor n2 maximum-routes 12000
#    neighbor peer2 peer group
#    neighbor peer2 maximum-routes 12000
#    network 1.1.1.0/24
#    network 1.5.1.0/24 route-map MAP01
#    !
#    address-family ipv4
#       bgp additional-paths receive
#       neighbor peer2 default-originate always
#       redistribute ospfv3 match external
#    !
#    address-family ipv6
#       no bgp additional-paths receive
#       neighbor n2 next-hop-unchanged
#       redistribute isis level-2
#    !
#    vrf bgp_10
#       ip access-group acl01
#       ucmp fec threshold trigger 33 clear 22 warning-only
#       !
#       address-family ipv4
#          route-target import 20:11
#    !
#    vrf vrft
#       address-family ipv4
#          bgp additional-paths receive
#       !
#       address-family ipv6
#          redistribute ospfv3 match external

- name: parse running config and generate structred facts
  arista.eos.eos_bgp_address_family:
    running_config: "{{ lookup('file', './parsed_bgp_address_family.cfg') }}"
    state: parsed

# Task output:
# ------------
# parsed:
#     address_family:
#     - afi: ipv4
#       bgp_params:
#         additional_paths: receive
#       neighbor:
#       - default_originate:
#           always: true
#         peer: peer2
#       redistribute:
#       - ospf_route: external
#         protocol: ospfv3
#     - afi: ipv6
#       neighbor:
#       - next_hop_unchanged: true
#         peer: n2
#       redistribute:
#       - isis_level: level-2
#         protocol: isis
#     - afi: ipv4
#       route_target:
#         action: import
#         target: '20:11'
#       vrf: bgp_10
#     - afi: ipv4
#       bgp_params:
#         additional_paths: receive
#       vrf: vrft
#     - afi: ipv6
#       redistribute:
#       - ospf_route: external
#         protocol: ospfv3
#       vrf: vrft
#     as_number: '10'

# Using gathered

# running config
# --------------
# veos(config-router-bgp)#show running-config | section bgp
# router bgp 10
#    neighbor peer2 peer group
#    neighbor peer2 maximum-routes 12000
#    neighbor 1.1.1.1 maximum-routes 12000
#    !
#    address-family ipv4
#       bgp additional-paths receive
#       neighbor peer2 default-originate always
#       no neighbor 1.1.1.1 activate
#       network 1.1.1.0/24
#       network 1.5.1.0/24 route-map MAP01
#       redistribute ospfv3 match external
#    !
#    vrf vrft
#       address-family ipv4
#          bgp additional-paths receive

- name: gather running config
  arista.eos.eos_bgp_address_family:
    state: gathered

# Task output:
# ------------
# gathered:
#     address_family:
#     - afi: ipv4
#       bgp_params:
#         additional_paths: receive
#       neighbor:
#       - default_originate:
#           always: true
#         peer: peer2
#       network:
#       - address: 1.1.1.0/24
#       - address: 1.5.1.0/24
#         route_map: MAP01
#       redistribute:
#       - ospf_route: external
#         protocol: ospfv3
#     - afi: ipv4
#       bgp_params:
#         additional_paths: receive
#       vrf: vrft
#     as_number: '10'

# using rendered

- name: Render CLI commands for provided config
  arista.eos.eos_bgp_address_family:
    config:
      as_number: "10"
      address_family:
        - afi: "ipv4"
          redistribute:
            - protocol: "ospfv3"
              ospf_route: "external"
          network:
            - address: "1.1.1.0/24"
            - address: "1.5.1.0/24"
              route_map: "MAP01"
        - afi: "ipv6"
          bgp_params:
            additional_paths: "receive"
          neighbor:
            - peer: "peer2"
              default_originate:
                always: true
        - afi: "ipv6"
          redistribute:
            - protocol: "isis"
              isis_level: "level-2"
          route_target:
            mode: "export"
            target: "33:11"
          vrf: "vrft"
    state: rendered

# Task output:
# ------------
# rendered:
# - router bgp 10
# - address-family ipv4
# - redistribute ospfv3 match external
# - network 1.1.1.0/24
# - network 1.5.1.0/24 route-map MAP01
# - exit
# - address-family ipv6
# - neighbor peer2 default-originate always
# - bgp additional-paths receive
# - exit
# - vrf vrft
# - address-family ipv6
# - redistribute isis level-2
# - route-target export 33:11
# - exit
# - exit

Return Values

Key Data Type Description Returned
after dict The resulting configuration after module execution. when changed
before dict The configuration prior to the module execution. when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged)
commands list The set of commands pushed to the remote device. when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged)
gathered dict Facts about the network resource gathered from the remote device as structured data. when I(state) is C(gathered)
parsed dict The device native config provided in I(running_config) option parsed into structured data as per module argspec. when I(state) is C(parsed)
rendered list The provided configuration in the task rendered in device-native format (offline). when I(state) is C(rendered)

Authors

  • Gomathi Selvi Srinivasan (@gomathiselvis)