dellemc.enterprise_sonic.sonic_bgp_af 模块 – 管理全局 BGP 地址族及其参数

注意

此模块是 dellemc.enterprise_sonic 集合(版本 2.5.1)的一部分。

如果您正在使用 ansible 包,则可能已经安装了此集合。它不包含在 ansible-core 中。要检查是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用:ansible-galaxy collection install dellemc.enterprise_sonic

要在 playbook 中使用它,请指定:dellemc.enterprise_sonic.sonic_bgp_af

dellemc.enterprise_sonic 1.0.0 中的新增功能

概要

  • 此模块提供在运行 Enterprise SONiC 的设备上全局 BGP_AF 参数的配置管理。

  • 必须提前在设备上创建 bgp_as 和 vrf_name。

注意

此模块具有相应的 action 插件

参数

参数

注释

config

列表 / 元素=字典

指定与 BGP_AF 相关的配置。

address_family

字典

指定 BGP 地址族相关的配置。

afis

列表 / 元素=字典

地址族列表,例如 ipv4、ipv6 和 l2vpn。

afi 和 safi 必须一起使用。

advertise_all_vni

布尔值

指定通告所有 vni 标志。

选项

  • false

  • true

advertise_default_gw

布尔值

指定通告默认网关标志。

选项

  • false

  • true

advertise_pip

布尔值

启用通告 PIP

选项

  • false

  • true

advertise_pip_ip

字符串

PIP IPv4 地址

advertise_pip_peer_ip

字符串

PIP 对等 IPv4 地址

advertise_svi_ip

布尔值

启用通告 SVI MACIP 路由

选项

  • false

  • true

afi

字符串 / 必需

要配置的地址族类型。

选项

  • "ipv4"

  • "ipv6"

  • "l2vpn"

aggregate_address_config

列表 / 元素=字典

在 dellemc.enterprise_sonic 2.5.0 中添加

聚合地址配置

as_set

布尔值

启用/禁用 AS 集路径信息的生成

选项

  • false

  • true

policy_name

字符串

要应用于聚合网络的预配置路由策略(路由映射名称)

prefix

字符串 / 必需

聚合地址前缀

summary_only

布尔值

启用/禁用更新中包含的路由信息的限制

选项

  • false

  • true

dampening

布尔值

如果设置为 true,则启用路由翻动抑制

选项

  • false

  • true

import

字典

在 dellemc.enterprise_sonic 2.5.0 中添加

指定要导入到此地址族的路由。

vrf

字典

从其他 VRF 导入路由。

route_map

字符串

指定路由映射。

vrf_list

列表 / 元素=字符串

指定要从中导入路由的 VRF。

max_path

字典

指定 ibgp 和 ebgp 计数的最大路径数。

ebgp

整数

指定 ebgp 多路径计数。

ibgp

整数

指定 ibgp 多路径计数。

network

列表 / 元素=字符串

为网络中提供的每个前缀启用 IP 网络上的路由

rd

字符串

指定 VRF 实例要使用的路由区分符。

redistribute

列表 / 元素=字典

指定从另一个路由协议重新分配的信息。

metric

字符串

指定重新分配路由的度量值。

protocol

字符串 / 必需

指定用于配置重新分配信息的协议。

选项

  • "ospf"

  • "static"

  • "connected"

route_map

字符串

指定路由映射参考。

route_advertise_list

列表 / 元素=字典

通告路由列表

advertise_afi

字符串 / 必需

指定地址族

选项

  • "ipv4"

  • "ipv6"

route_map

字符串

指定路由映射参考

rt_in

列表 / 元素=字符串

要导入的路由目标。

rt_out

列表 / 元素=字符串

要导出的路由目标。

safi

字符串

指定地址族的通信类型。

选项

  • "unicast" ← (默认)

  • "evpn"

vnis

列表 / 元素=字典

EVPN 的 VNI 配置。

advertise_default_gw

布尔值

指定通告默认网关标志。

选项

  • false

  • true

advertise_svi_ip

布尔值

启用通告 SVI MACIP 路由

选项

  • false

  • true

rd

字符串

指定 VRF 实例要使用的路由区分符。

rt_in

列表 / 元素=字符串

要导入的路由目标。

rt_out

列表 / 元素=字符串

要导出的路由目标。

vni_number

整数 / 必需

指定 VNI 编号。

bgp_as

字符串 / 必需

指定已在设备上配置的 BGP 自治系统 (AS) 编号。

vrf_name

字符串

指定已在设备上配置的 VRF 名称。

默认值: "default"

state

字符串

指定要在设备上配置的 BGP_AF 进程上执行的操作。

在合并的情况下,输入配置与设备上现有的 BGP_AF 配置合并。

在删除的情况下,现有的 BGP_AF 配置将从设备中删除。

在替换的情况下,将使用提供的配置替换指定 BGP AS 的现有 BGP_AF。

在覆盖的情况下,现有的 BGP_AF 配置将使用提供的配置覆盖。

选项

  • "merged" ← (默认)

  • "deleted"

  • "overridden"

  • "replaced"

注释

注意

  • 已针对戴尔科技的 Enterprise SONiC 发行版进行测试。

  • 支持 check_mode

示例

# Using deleted
#
# Before state:
# -------------
#
#do show running-configuration bgp
#!
#router bgp 51 vrf VrfReg1
# log-neighbor-changes
# timers 60 180
# !
# address-family ipv4 unicast
#  maximum-paths 1
#  maximum-paths ibgp 1
#  network 3.3.3.3/16
#  aggregate-address 1.1.1.1/1
#  aggregate-address 5.5.5.5/5 as-set summary-only route-map rmap-1
#  dampening
#  import vrf route-map rmap-1
#  import vrf default
#!
#router bgp 51
# router-id 111.2.2.41
# timers 60 180
# !
# address-family ipv4 unicast
#  maximum-paths 1
#  maximum-paths ibgp 1
#  dampening
# !
# address-family ipv6 unicast
#  redistribute connected route-map bb metric 21
#  redistribute ospf route-map aa metric 27
#  redistribute static route-map bb metric 26
#  maximum-paths 4
#  maximum-paths ibgp 5
# !
# address-family l2vpn evpn
#  advertise-svi-ip
#  advertise ipv6 unicast route-map aa
#  rd 3.3.3.3:33
#  route-target import 22:22
#  route-target export 33:33
#  advertise-pip ip 1.1.1.1 peer-ip 2.2.2.2
#  !
#  vni 1
#   advertise-default-gw
#   advertise-svi-ip
#   rd 5.5.5.5:55
#   route-target import 88:88
#   route-target export 77:77
#
- name: Delete BGP Address family configuration from the device
  dellemc.enterprise_sonic.sonic_bgp_af:
     config:
       - bgp_as: 51
         address_family:
           afis:
             - afi: l2vpn
               safi: evpn
               advertise_pip: True
               advertise_pip_ip: "1.1.1.1"
               advertise_pip_peer_ip: "2.2.2.2"
               advertise_svi_ip: True
               advertise_all_vni: False
               advertise_default_gw: False
               route_advertise_list:
                 - advertise_afi: ipv6
                   route_map: aa
               rd: "3.3.3.3:33"
               rt_in:
                 - "22:22"
               rt_out:
                 - "33:33"
               vnis:
                 - vni_number: 1
             - afi: ipv4
               safi: unicast
             - afi: ipv6
               safi: unicast
               max_path:
                 ebgp: 2
                 ibgp: 5
               redistribute:
                 - metric: "21"
                   protocol: connected
                   route_map: bb
                 - metric: "27"
                   protocol: ospf
                   route_map: aa
                 - metric: "26"
                   protocol: static
                   route_map: bb
       - bgp_as: 51
         vrf_name: VrfReg1
         address_family:
           afis:
             - afi: ipv4
               safi: unicast
               import:
                 vrf:
                   vrf_list:
                     - default
                   route_map: rmap-1
               aggregate_address_config:
                 - prefix: "1.1.1.1/1"
                 - prefix: "5.5.5.5/5"
                   as_set: True
                   policy_name: rmap-1
                   summary_only: True
     state: deleted

# After state:
# ------------
#
#do show running-configuration bgp
#!
#router bgp 51 vrf VrfReg1
# log-neighbor-changes
# timers 60 180
# !
# address-family ipv4 unicast
#  maximum-paths 1
#  maximum-paths ibgp 1
#  network 3.3.3.3/16
#  aggregate-address 5.5.5.5/5
#  dampening
#!
#router bgp 51
# router-id 111.2.2.41
# timers 60 180
# !
# address-family ipv6 unicast
# !
# address-family l2vpn evpn
#
# Using deleted
#
# Before state:
# -------------
#
#do show running-configuration bgp
#!
#router bgp 51 vrf VrfReg1
# log-neighbor-changes
# timers 60 180
# !
# address-family ipv4 unicast
#  maximum-paths 1
#  maximum-paths ibgp 1
#  network 3.3.3.3/16
#  aggregate-address 5.5.5.5/5 as-set summary-only route-map rmap-1
#  dampening
#  import vrf route-map rmap-1
#  import vrf default
#!
#router bgp 51
# router-id 111.2.2.41
# timers 60 180
# !
# address-family ipv6 unicast
# !
# address-family l2vpn evpn
#
- name: Delete All BGP address family configurations
  dellemc.enterprise_sonic.sonic_bgp_af:
     config:
     state: deleted


# After state:
# ------------
#
#do show running-configuration bgp
#!
#router bgp 51 vrf VrfReg1
# log-neighbor-changes
# timers 60 180
#!
#router bgp 51
# router-id 111.2.2.41
# timers 60 180
#
# Using merged
#
# Before state:
# -------------
#
#do show running-configuration bgp
#!
#router bgp 51 vrf VrfReg1
# log-neighbor-changes
# timers 60 180
#!
#router bgp 51
# router-id 111.2.2.41
# timers 60 180
# !
# address-family l2vpn evpn
#
- name: Merge provided BGP address family configuration on the device.
  dellemc.enterprise_sonic.sonic_bgp_af:
     config:
       - bgp_as: 51
         address_family:
           afis:
             - afi: l2vpn
               safi: evpn
               advertise_pip: True
               advertise_pip_ip: "3.3.3.3"
               advertise_pip_peer_ip: "4.4.4.4"
               advertise_svi_ip: True
               advertise_all_vni: False
               advertise_default_gw: False
               route_advertise_list:
                 - advertise_afi: ipv4
                   route_map: bb
               rd: "1.1.1.1:11"
               rt_in:
                 - "12:12"
               rt_out:
                 - "13:13"
               vnis:
                 - vni_number: 1
                   advertise_default_gw: True
                   advertise_svi_ip: True
                   rd: "5.5.5.5:55"
                   rt_in:
                     - "88:88"
                   rt_out:
                     - "77:77"
             - afi: ipv4
               safi: unicast
               network:
                 - 2.2.2.2/16
                 - 192.168.10.1/32
               dampening: True
               aggregate_address_config:
                 - prefix: 1.1.1.1/1
                   as_set: True
                   policy_name: bb
                   summary_only: True
             - afi: ipv6
               safi: unicast
               max_path:
                 ebgp: 4
                 ibgp: 5
               redistribute:
                 - metric: "21"
                   protocol: connected
                   route_map: bb
                 - metric: "27"
                   protocol: ospf
                   route_map: aa
                 - metric: "26"
                   protocol: static
                   route_map: bb
       - bgp_as: 51
         vrf_name: VrfReg1
         address_family:
           afis:
             - afi: ipv4
               safi: unicast
               import:
                 vrf:
                   vrf_list:
                     - default
                   route_map: rmap-1
     state: merged
# After state:
# ------------
#
#do show running-configuration bgp
#!
#router bgp 51 vrf VrfReg1
# log-neighbor-changes
# timers 60 180
# !
# address-family ipv4 unicast
#  maximum-paths 1
#  maximum-paths ibgp 1
#  import vrf route-map rmap-1
#  import vrf default
#!
#router bgp 51
# router-id 111.2.2.41
# timers 60 180
# !
# address-family ipv4 unicast
#  network 2.2.2.2/16
#  network 192.168.10.1/32
#  aggregate-address 1.1.1.1/1 as-set summary-only route-map bb
#  dampening
# !
# address-family ipv6 unicast
#  redistribute connected route-map bb metric 21
#  redistribute ospf route-map aa metric 27
#  redistribute static route-map bb metric 26
#  maximum-paths 4
#  maximum-paths ibgp 5
# !
# address-family l2vpn evpn
#  advertise-svi-ip
#  advertise ipv4 unicast route-map bb
#  rd 1.1.1.1:11
#  route-target import 12:12
#  route-target import 13:13
#  advertise-pip ip 3.3.3.3 peer-ip 4.4.4.4
#  !
#  vni 1
#   advertise-default-gw
#   advertise-svi-ip
#   rd 5.5.5.5:55
#   route-target import 88:88
#   route-target export 77:77


# Using replaced
#
# Before state:
# -------------
#
#do show running-configuration bgp
#!
#router bgp 51 vrf VrfReg1
# log-neighbor-changes
# timers 60 180
# !
# address-family ipv4 unicast
#  maximum-paths 1
#  maximum-paths ibgp 1
#  network 3.3.3.3/16
#  dampening
#!
#router bgp 51 vrf VrfReg2
# log-neighbor-changes
# timers 60 180
# !
# address-family ipv4 unicast
#  maximum-paths 1
#  maximum-paths ibgp 1
#  import vrf route-map rmap-1
#  import vrf default
#!
#router bgp 51
# router-id 111.2.2.41
# log-neighbor-changes
# timers 60 180
# !
# address-family ipv4 unicast
#  redistribute connected route-map bb metric 21
#  redistribute ospf route-map bb metric 27
#  maximum-paths 1
#  maximum-paths ibgp 1
#  network 2.2.2.2/16
#  network 192.168.10.1/32
#  aggregate-address 5.5.5.5/5 as-set summary-only route-map bb
#  dampening
# !
# address-family ipv6 unicast
#  redistribute static route-map aa metric 26
#  maximum-paths 4
#  maximum-paths ibgp 5
# !
# address-family l2vpn evpn
#  advertise-all-vni
#  advertise-svi-ip
#  advertise ipv4 unicast route-map bb
#  rd 1.1.1.1:11
#  route-target import 12:12
#  route-target export 13:13
#  dup-addr-detection
#  advertise-pip ip 3.3.3.3 peer-ip 4.4.4.4
#  !
#  vni 1
#   advertise-default-gw
#   advertise-svi-ip
#   rd 5.5.5.5:55
#   route-target import 88:88
#   route-target export 77:77

- name: Replace device configuration of address families of specified BGP AS with provided configuration.
  dellemc.enterprise_sonic.sonic_bgp_af:
    config:
      - bgp_as: 51
        address_family:
          afis:
            - afi: l2vpn
              safi: evpn
              advertise_pip: True
              advertise_pip_ip: "3.3.3.3"
              advertise_pip_peer_ip: "4.4.4.4"
              advertise_svi_ip: True
              advertise_all_vni: True
              advertise_default_gw: False
              route_advertise_list:
                - advertise_afi: ipv4
                  route_map: bb
              rd: "1.1.1.1:11"
              rt_in:
                - "22:22"
              rt_out:
                - "13:13"
              vnis:
                - vni_number: 5
                  advertise_default_gw: True
                  advertise_svi_ip: True
                  rd: "10.10.10.10:55"
                  rt_in:
                    - "88:88"
                  rt_out:
                    - "77:77"
            - afi: ipv4
              safi: unicast
              network:
                - 2.2.2.2/16
                - 192.168.10.1/32
              dampening: True
              redistribute:
                - protocol: connected
                - protocol: ospf
                  metric: 30
              aggregate-address-config:
                - prefix: '5.5.5.5/5'
                  as_set: True
      - bgp_as: 51
        vrf_name: VrfReg2
        address_family:
          afis:
            - afi: ipv4
              safi: unicast
              import:
                vrf:
                  vrf_list:
                    - VrfReg1
                  route_map: rmap-reg1
    state: replaced

# After state:
# ------------
#
#do show running-configuration bgp
#!
#router bgp 51 vrf VrfReg1
# log-neighbor-changes
# timers 60 180
# !
# address-family ipv4 unicast
#  maximum-paths 1
#  maximum-paths ibgp 1
#  network 3.3.3.3/16
#  dampening
#!
#router bgp 51 vrf VrfReg2
# log-neighbor-changes
# timers 60 180
# !
# address-family ipv4 unicast
#  maximum-paths 1
#  maximum-paths ibgp 1
#  import vrf route-map rmap-reg1
#  import vrf VrfReg1
#!
#router bgp 51
# router-id 111.2.2.41
# log-neighbor-changes
# timers 60 180
# !
# address-family ipv4 unicast
#  redistribute connected
#  redistribute ospf metric 30
#  maximum-paths 1
#  maximum-paths ibgp 1
#  network 2.2.2.2/16
#  network 192.168.10.1/32
#  aggregate-address 5.5.5.5/5 as-set
#  dampening
# !
# address-family ipv6 unicast
#  redistribute static route-map aa metric 26
#  maximum-paths 4
#  maximum-paths ibgp 5
# !
# address-family l2vpn evpn
#  advertise-svi-ip
#  advertise ipv4 unicast route-map bb
#  rd 1.1.1.1:11
#  route-target import 22:22
#  route-target export 13:13
#  dup-addr-detection
#  advertise-pip ip 3.3.3.3 peer-ip 4.4.4.4
#  !
#  vni 5
#   advertise-default-gw
#   advertise-svi-ip
#   rd 10.10.10.10:55
#   route-target import 88:88
#   route-target export 77:77


# Using overridden
#
# Before state:
# -------------
#
#do show running-configuration bgp
#!
#router bgp 51 vrf VrfReg1
# log-neighbor-changes
# timers 60 180
# !
# address-family ipv4 unicast
#  maximum-paths 1
#  maximum-paths ibgp 1
#  network 3.3.3.3/16
#  dampening
#  import vrf route-map rmap-1
#  import vrf default
#!
#router bgp 51
# router-id 111.2.2.41
# log-neighbor-changes
# timers 60 180
# !
# address-family ipv4 unicast
#  redistribute connected route-map bb metric 21
#  redistribute ospf route-map bb metric 27
#  maximum-paths 1
#  maximum-paths ibgp 1
#  network 2.2.2.2/16
#  network 192.168.10.1/32
#  dampening
# !
# address-family ipv6 unicast
#  redistribute static route-map aa metric 26
#  maximum-paths 4
#  maximum-paths ibgp 5
# !
# address-family l2vpn evpn
#  advertise-all-vni
#  advertise-svi-ip
#  advertise ipv4 unicast route-map bb
#  rd 1.1.1.1:11
#  route-target import 12:12
#  route-target export 13:13
#  dup-addr-detection
#  advertise-pip ip 3.3.3.3 peer-ip 4.4.4.4
#  !
#  vni 1
#   advertise-default-gw
#   advertise-svi-ip
#   rd 5.5.5.5:55
#   route-target import 88:88
#   route-target export 77:77

- name: Override device configuration of BGP address families with provided configuration.
  dellemc.enterprise_sonic.sonic_bgp_af:
    config:
      - bgp_as: 51
        address_family:
          afis:
            - afi: l2vpn
              safi: evpn
              advertise_pip: True
              advertise_pip_ip: "3.3.3.3"
              advertise_pip_peer_ip: "4.4.4.4"
              advertise_svi_ip: True
              advertise_all_vni: True
              advertise_default_gw: False
              route_advertise_list:
                - advertise_afi: ipv4
                  route_map: bb
              rd: "1.1.1.1:11"
              rt_in:
                - "22:22"
              rt_out:
                - "13:13"
              vnis:
                - vni_number: 5
                  advertise_default_gw: True
                  advertise_svi_ip: True
                  rd: "10.10.10.10:55"
                  rt_in:
                    - "88:88"
                  rt_out:
                    - "77:77"
            - afi: ipv4
              safi: unicast
              network:
                - 2.2.2.2/16
                - 192.168.10.1/32
              dampening: True
              redistribute:
                - protocol: connected
                - protocol: ospf
                  metric: 30
              aggregate_address_config:
                - prefix: 4.4.4.4/4
                  as_set: True
                  policy_name: bb
                  summary_only: True
    state: overridden

# After state:
# ------------
#
#do show running-configuration bgp
#!
#router bgp 51 vrf VrfReg1
# log-neighbor-changes
# timers 60 180
#!
#router bgp 51
# router-id 111.2.2.41
# log-neighbor-changes
# timers 60 180
# !
# address-family ipv4 unicast
#  redistribute connected
#  redistribute ospf metric 30
#  maximum-paths 1
#  maximum-paths ibgp 1
#  network 2.2.2.2/16
#  network 192.168.10.1/32
#  aggregate-address 4.4.4.4/4 as-set summary-only route-map bb
#  dampening
# !
# address-family l2vpn evpn
#  advertise-all-vni
#  advertise-svi-ip
#  advertise ipv4 unicast route-map bb
#  rd 1.1.1.1:11
#  route-target import 22:22
#  route-target export 13:13
#  dup-addr-detection
#  advertise-pip ip 3.3.3.3 peer-ip 4.4.4.4
#  !
#  vni 5
#   advertise-default-gw
#   advertise-svi-ip
#   rd 10.10.10.10:55
#   route-target import 88:88
#   route-target export 77:77

返回值

通用返回值记录在此处,以下是此模块独有的字段

描述

after

列表 / 元素=字符串

生成的配置模块调用。

返回值:发生更改时

示例: ["The configuration returned always in the same format as the parameters above.\n"]

before

列表 / 元素=字符串

模块调用之前的配置。

返回值:始终

示例: ["The configuration returned is always in the same format as the parameters above.\n"]

commands

列表 / 元素=字符串

推送到远程设备的命令集。

返回值:始终

示例: ["命令 1", "命令 2", "命令 3"]

作者

  • Niraimadaiselvam M (@niraimadaiselvamm)