community.network.cnos_bgp 模块 – 在运行 CNOS 的设备上管理 BGP 资源和属性

注意

此模块是 community.network 集合 (版本 5.1.0) 的一部分。

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

要安装它,请使用:ansible-galaxy collection install community.network

要在剧本中使用它,请指定:community.network.cnos_bgp

注意

community.network 集合已被弃用,并将从 Ansible 12 中移除。有关更多信息,请参阅 讨论主题

已弃用

在以下版本中移除:

6.0.0 版本

原因:

此集合及其中的所有内容均未维护且已弃用。

替代方案:

未知。

概要

  • 此模块允许您使用与边界网关协议 (BGP) 相关的配置。使用的运算符已重载,以确保对交换机 BGP 配置的控制。此模块使用 method 方法调用,asNumber 为其参数之一。BGP 配置的第一级允许设置 AS 号,后续属性进入 BGP 上下文中各种配置操作。通过此级别后,有八个 BGP 参数将执行进一步的配置。它们是 bgpArg1、bgpArg2、bgpArg3、bgpArg4、bgpArg5、bgpArg6、bgpArg7 和 bgpArg8。有关如何使用这些参数的更多详细信息,请参阅 [重载变量]。此模块使用 SSH 管理网络设备配置。操作的结果将放在名为“results”的目录中,用户必须在其本地目录(运行剧本的位置)中创建此目录。

别名:network.cnos.cnos_bgp

参数

参数

注释

asNum

字符串 / 必需

AS 号

bgpArg1

字符串 / 必需

这是一个重载的 bgp 第一个参数。此参数的用法可以在上面提到的用户指南中找到。

选项

  • "address-family"

  • "bestpath"

  • "bgp"

  • "cluster-id"

  • "confederation"

  • "enforce-first-as"

  • "fast-external-failover"

  • "graceful-restart"

  • "graceful-restart-helper"

  • "log-neighbor-changes"

  • "maxas-limit"

  • "neighbor"

  • "router-id"

  • "shutdown"

  • "synchronization"

  • "timers"

  • "vrf"

bgpArg2

字符串

这是一个重载的 bgp 第二个参数。此参数的用法可以在上面提到的用户指南中找到。

选项

  • "ipv4 ipv6"

  • "always-compare-med"

  • "compare-confed-aspath"

  • "compare-routerid"

  • "dont-compare-originator-id"

  • "tie-break-on-age"

  • "as-path"

  • "med"

  • "identifier"

  • "peers"

bgpArg3

字符串

这是一个重载的 bgp 第三个参数。此参数的用法可以在上面提到的用户指南中找到。

选项

  • "aggregate-address"

  • "client-to-client"

  • "dampening"

  • "distance"

  • "maximum-paths"

  • "network"

  • "nexthop"

  • "redistribute"

  • "save"

  • "synchronization"

  • "ignore multipath-relax"

  • "confed missing-as-worst non-deterministic remove-recv-med remove-send-med"

bgpArg4

字符串

这是一个重载的 bgp 第四个参数。此参数的用法可以在上面提到的用户指南中找到。

选项

  • "Aggregate prefix"

  • "Reachability Half-life time"

  • "route-map"

  • "Distance for routes ext"

  • "ebgp ibgp"

  • "IP prefix <network>"

  • "IP prefix <network>/<length>"

  • "synchronization"

  • "Delay value"

  • "direct"

  • "ospf"

  • "static"

  • "memory"

bgpArg5

字符串

这是一个重载的 BGP 第五个参数。此参数的用法可以在上面引用的用户指南中找到。

选项

  • "as-set"

  • "summary-only"

  • "开始重新使用路由的值"

  • "内部路由的距离"

  • "支持的多路径数量"

  • "backdoor"

  • "map"

  • "route-map"

bgpArg6

字符串

这是一个重载的 BGP 第六个参数。此参数的用法可以在上面引用的用户指南中找到。

选项

  • "summary-only"

  • "as-set"

  • "路由映射名称"

  • "开始抑制路由的值"

  • "本地路由距离"

  • "网络掩码"

  • "指向路由映射条目的指针"

bgpArg7

字符串

这是一个重载的 BGP 第七个参数。此参数的用法可以在上面引用的用户指南中找到。

选项

  • "抑制稳定路由的最大持续时间(分钟)"

  • "backdoor"

  • "route-map"

  • "路由映射的名称"

bgpArg8

字符串

这是一个重载的 BGP 第八个参数。此参数的用法可以在上面引用的用户指南中找到。

选项

  • "不可达性惩罚的半衰期(分钟)"

  • "backdoor"

deviceType

字符串 / 必需

这指定了执行方法的设备类型。自 Ansible 2.4 版本以来,增加了 NE1072T、NE1032、NE1032T、NE10032、NE2572 选项。自 2.8 版本以来,增加了 NE0152T 选项。

选项

  • "g8272_cnos"

  • "g8296_cnos"

  • "g8332_cnos"

  • "NE0152T"

  • "NE1072T"

  • "NE1032"

  • "NE1032T"

  • "NE10032"

  • "NE2572"

enablePassword

字符串

配置用于进入交换机全局配置命令模式的密码。如果交换机不需要此密码,则忽略此参数。虽然通常应从清单文件中获取该值,但您也可以将其指定为变量。此参数是可选的。如果未指定,则不使用默认值。

host

字符串 / 必需

这是用于搜索 /etc/ansible/hosts 中的主机文件并识别将应用模板的设备的 IP 地址的变量。通常,Ansible 关键字 {{ inventory_hostname }} 在剧本中被指定为需要配置的网络元素组的抽象。

outputfile

字符串 / 必需

这指定了保存每个命令执行输出的文件路径。合并的模板文件中指定的每个命令以及来自设备的每个响应都将保存在此处。通常位置是结果文件夹,但您可以根据您的写入权限选择其他位置。

password

字符串 / 必需

配置用于验证与远程设备连接的密码。密码参数的值用于验证 SSH 会话。虽然通常应从清单文件中获取该值,但您也可以将其指定为变量。此参数是可选的。如果未指定,则不使用默认值。

username

字符串 / 必需

配置用于验证与远程设备连接的用户名。用户名参数的值用于验证 SSH 会话。虽然通常应从清单文件中获取该值,但您也可以将其指定为变量。此参数是可选的。如果未指定,则不使用默认值。

注释

注意

示例

Tasks: The following are examples of using the module cnos_bgp. These are
 written in the main.yml file of the tasks directory.
---
- name: Test BGP  - neighbor
  community.network.cnos_bgp:
      deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}"
      outputfile: "./results/test_bgp_{{ inventory_hostname }}_output.txt"
      asNum: 33
      bgpArg1: "neighbor"
      bgpArg2: "10.241.107.40"
      bgpArg3: 13
      bgpArg4: "address-family"
      bgpArg5: "ipv4"
      bgpArg6: "next-hop-self"

- name: Test BGP  - BFD
  community.network.cnos_bgp:
      deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}"
      outputfile: "./results/test_bgp_{{ inventory_hostname }}_output.txt"
      asNum: 33
      bgpArg1: "neighbor"
      bgpArg2: "10.241.107.40"
      bgpArg3: 13
      bgpArg4: "bfd"

- name: Test BGP  - address-family - dampening
  community.network.cnos_bgp:
      deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}"
      outputfile: "./results/test_bgp_{{ inventory_hostname }}_output.txt"
      asNum: 33
      bgpArg1: "address-family"
      bgpArg2: "ipv4"
      bgpArg3: "dampening"
      bgpArg4: 13
      bgpArg5: 233
      bgpArg6: 333
      bgpArg7: 15
      bgpArg8: 33

- name: Test BGP  - address-family - network
  community.network.cnos_bgp:
      deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}"
      outputfile: "./results/test_bgp_{{ inventory_hostname }}_output.txt"
      asNum: 33
      bgpArg1: "address-family"
      bgpArg2: "ipv4"
      bgpArg3: "network"
      bgpArg4: "1.2.3.4/5"
      bgpArg5: "backdoor"

- name: Test BGP - bestpath - always-compare-med
  community.network.cnos_bgp:
      deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}"
      outputfile: "./results/test_bgp_{{ inventory_hostname }}_output.txt"
      asNum: 33
      bgpArg1: "bestpath"
      bgpArg2: "always-compare-med"

- name: Test BGP - bestpath-compare-confed-aspat
  community.network.cnos_bgp:
      deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}"
      outputfile: "./results/test_bgp_{{ inventory_hostname }}_output.txt"
      asNum: 33
      bgpArg1: "bestpath"
      bgpArg2: "compare-confed-aspath"

- name: Test BGP - bgp
  community.network.cnos_bgp:
      deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}"
      outputfile: "./results/test_bgp_{{ inventory_hostname }}_output.txt"
      asNum: 33
      bgpArg1: "bgp"
      bgpArg2: 33

- name: Test BGP  - cluster-id
  community.network.cnos_bgp:
      deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}"
      outputfile: "./results/test_bgp_{{ inventory_hostname }}_output.txt"
      asNum: 33
      bgpArg1: "cluster-id"
      bgpArg2: "1.2.3.4"

- name: Test BGP - confederation-identifier
  community.network.cnos_bgp:
      deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}"
      outputfile: "./results/test_bgp_{{ inventory_hostname }}_output.txt"
      asNum: 33
      bgpArg1: "confederation"
      bgpArg2: "identifier"
      bgpArg3: 333

- name: Test BGP - enforce-first-as
  community.network.cnos_bgp:
      deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}"
      outputfile: "./results/test_bgp_{{ inventory_hostname }}_output.txt"
      asNum: 33
      bgpArg1: "enforce-first-as"

- name: Test BGP - fast-external-failover
  community.network.cnos_bgp:
      deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}"
      outputfile: "./results/test_bgp_{{ inventory_hostname }}_output.txt"
      asNum: 33
      bgpArg1: "fast-external-failover"

- name: Test BGP  - graceful-restart
  community.network.cnos_bgp:
      deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}"
      outputfile: "./results/test_bgp_{{ inventory_hostname }}_output.txt"
      asNum: 33
      bgpArg1: "graceful-restart"
      bgpArg2: 333

- name: Test BGP - graceful-restart-helper
  community.network.cnos_bgp:
      deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}"
      outputfile: "./results/test_bgp_{{ inventory_hostname }}_output.txt"
      asNum: 33
      bgpArg1: "graceful-restart-helper"

- name: Test BGP - maxas-limit
  community.network.cnos_bgp:
      deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}"
      outputfile: "./results/test_bgp_{{ inventory_hostname }}_output.txt"
      asNum: 33
      bgpArg1: "maxas-limit"
      bgpArg2: 333

- name: Test BGP  - neighbor
  community.network.cnos_bgp:
      deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}"
      outputfile: "./results/test_bgp_{{ inventory_hostname }}_output.txt"
      asNum: 33
      bgpArg1: "neighbor"
      bgpArg2: "10.241.107.40"
      bgpArg3: 13
      bgpArg4: "address-family"
      bgpArg5: "ipv4"
      bgpArg6: "next-hop-self"

- name: Test BGP - router-id
  community.network.cnos_bgp:
      deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}"
      outputfile: "./results/test_bgp_{{ inventory_hostname }}_output.txt"
      asNum: 33
      bgpArg1: "router-id"
      bgpArg2: "1.2.3.4"

- name: Test BGP - synchronization
  community.network.cnos_bgp:
      deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}"
      outputfile: "./results/test_bgp_{{ inventory_hostname }}_output.txt"
      asNum: 33
      bgpArg1: "synchronization"

- name: Test BGP - timers
  community.network.cnos_bgp:
      deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}"
      outputfile: "./results/test_bgp_{{ inventory_hostname }}_output.txt"
      asNum: 33
      bgpArg1: "timers"
      bgpArg2: 333
      bgpArg3: 3333

- name: Test BGP - vrf
  community.network.cnos_bgp:
      deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}"
      outputfile: "./results/test_bgp_{{ inventory_hostname }}_output.txt"
      asNum: 33
      bgpArg1: "vrf"

返回值

常见的返回值已在 此处 记录,以下是此模块特有的字段

描述

msg

字符串

成功或失败消息。发生任何故障时,方法将返回错误显示字符串。

返回:始终

状态

  • 此模块将在 6.0.0 版本中移除。[已弃用]

  • 更多信息请参见 已弃用

作者

  • Anil Kumar Muraleedharan (@amuraleedhar)