dellemc.enterprise_sonic.sonic_static_routes 模块 – 在 SONiC 上管理静态路由配置
注意
此模块是 dellemc.enterprise_sonic 集合 (版本 2.5.1) 的一部分。
如果您使用的是 ansible
包,则可能已经安装了此集合。它不包含在 ansible-core
中。要检查是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用:ansible-galaxy collection install dellemc.enterprise_sonic
。
要在剧本中使用它,请指定:dellemc.enterprise_sonic.sonic_static_routes
。
dellemc.enterprise_sonic 2.0.0 中的新增功能
概要
此模块提供对运行 SONiC 的设备的静态路由的配置管理。
参数
参数 |
注释 |
---|---|
管理“静态路由”配置 |
|
“静态路由”配置列表。 |
|
将用于指定静态路由的下一跳列表。 |
|
用于唯一引用下一跳的标识符。 |
|
指示应丢弃与该路由匹配的数据包。 选项
|
|
对基本接口的引用。 |
|
将用于静态路由的下一跳。 |
|
泄漏路由的下一跳网络实例的名称。 |
|
将下一跳条目注入 RIB 时指定其优先级。 |
|
静态路由的标签值。 |
|
静态路由的 IP SLA 跟踪 ID。 |
|
静态路由的目标前缀,IPv4 或 IPv6。 |
|
设备上配置的 VRF 的名称。 |
|
模块完成后的配置状态。 选项
|
备注
注意
支持
check_mode
。
示例
# Using merged
#
# Before State:
# -------------
#
# sonic# show running-configuration | grep "ip route"
# (No "ip route" configuration present)
- name: Merge static routes configurations
dellemc.enterprise_sonic.sonic_static_routes:
config:
- vrf_name: 'default'
static_list:
- prefix: '2.0.0.0/8'
next_hops:
- index:
interface: 'Ethernet4'
metric: 1
tag: 2
track: 3
- index:
next_hop: '3.0.0.0'
metric: 2
tag: 4
track: 8
- vrf_name: 'VrfReg1'
static_list:
- prefix: '3.0.0.0/8'
next_hops:
- index:
interface: 'eth0'
nexthop_vrf: 'VrfReg2'
next_hop: '4.0.0.0'
metric: 4
tag: 5
track: 6
- index:
blackhole: True
metric: 10
tag: 20
track: 30
state: merged
# After State:
# ------------
#
# sonic# show running-configuration | grep "ip route"
# ip route 2.0.0.0/8 3.0.0.0 tag 4 track 8 2
# ip route 2.0.0.0/8 interface Ethernet4 tag 2 track 3 1
# ip route vrf VrfReg1 3.0.0.0/8 4.0.0.0 interface Management 0 nexthop-vrf VrfReg2 tag 5 track 6 4
# ip route vrf VrfReg1 3.0.0.0/8 blackhole tag 20 track 30 10
#
#
# Modifying previous merge
- name: Modify static routes configurations
dellemc.enterprise_sonic.sonic_static_routes:
config:
- vrf_name: 'VrfReg1'
static_list:
- prefix: '3.0.0.0/8'
next_hops:
- index:
blackhole: True
metric: 11
tag: 22
track: 33
state: merged
# After State:
# ------------
#
# sonic# show running-configuration | grep "ip route"
# ip route 2.0.0.0/8 3.0.0.0 tag 4 track 8 2
# ip route 2.0.0.0/8 interface Ethernet4 tag 2 track 3 1
# ip route vrf VrfReg1 3.0.0.0/8 4.0.0.0 interface Management 0 nexthop-vrf VrfReg2 tag 5 track 6 4
# ip route vrf VrfReg1 3.0.0.0/8 blackhole tag 22 track 33 11
# Using overridden
#
# Before State:
# -------------
#
# sonic# show running-configuration | grep "ip route"
# ip route 4.0.0.0/8 2.0.0.0 tag 4 track 8 2
- name: Override static routes configurations
dellemc.enterprise_sonic.sonic_static_routes:
config:
- vrf_name: 'VrfReg2'
static_list:
- prefix: '3.0.0.0/8'
next_hops:
- index:
blackhole: True
metric: 10
tag: 20
track: 30
state: overridden
# After State:
# ------------
#
# sonic# show running-configuration | grep "ip route"
# ip route vrf VrfReg2 3.0.0.0/8 blackhole tag 20 track 30 10
# Using Replaced
#
# Before State:
# -------------
#
# sonic# show running-configuration | grep "ip route"
# ip route 4.0.0.0/8 2.0.0.0 tag 4 track 8 2
- name: Replace static routes configurations
dellemc.enterprise_sonic.sonic_static_routes:
config:
- vrf_name: 'default'
static_list:
- prefix: '4.0.0.0/8'
next_hops:
- index:
blackhole: True
metric: 5
tag: 10
track: 15
state: replaced
# After State:
# ------------
#
# sonic# show running-configuration | grep "ip route"
# ip route 4.0.0.0/8 blackhole tag 10 track 15 5
# Using deleted
#
# Before State:
# -------------
#
# sonic# show running-configuration | grep "ip route"
# ip route 2.0.0.0/8 3.0.0.0 tag 4 track 8 2
# ip route 2.0.0.0/8 interface Ethernet4 tag 2 track 3 1
# ip route vrf VrfReg1 3.0.0.0/8 4.0.0.0 interface Management 0 nexthop-vrf VrfReg2 tag 5 track 6 4
# ip route vrf VrfReg1 3.0.0.0/8 blackhole tag 22 track 33 11
- name: Delete static routes configurations
dellemc.enterprise_sonic.sonic_static_routes:
config:
- vrf_name: 'default'
static_list:
- prefix: '2.0.0.0/8'
next_hops:
- index:
interface: 'Ethernet4'
- vrf_name: 'VrfReg1'
state: deleted
# After State:
# ------------
#
# sonic# show running-configuration | grep "ip route"
# ip route 2.0.0.0/8 3.0.0.0 tag 4 track 8 2
返回值
常见的返回值在此处有说明 此处,以下是此模块特有的字段
键 |
描述 |
---|---|
模块调用后的最终配置。 返回:发生更改时 示例: |
|
生成的配置模块调用。 返回:当 示例: |
|
模块调用之前的配置。 返回:始终返回 示例: |
|
推送到远程设备的命令集。 返回:始终返回 示例: |