vyos.vyos.vyos_ospfv2 模块 – OSPFv2 资源模块

注意

此模块是 vyos.vyos 集合 (版本 5.0.0) 的一部分。

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

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

要在 playbook 中使用它,请指定:vyos.vyos.vyos_ospfv2

vyos.vyos 1.0.0 中的新增功能

概要

  • 此资源模块配置和管理 VyOS 网络设备上 OSPFv2 路由的属性。

参数

参数

注释

config

字典

提供的 OSPFv2 路由配置。

areas

列表 / 元素=字典

OSPFv2 区域。

area_id

字符串

OSPFv2 区域标识。

area_type

字典

区域类型。

normal

布尔值

普通 OSPFv2 区域。

选项

  • false

  • true

nssa

字典

NSSA OSPFv2 区域。

default_cost

整数

NSSA 区域的默认成本摘要。

no_summary

布尔值

不要将区域间路由注入存根。

选项

  • false

  • true

set

布尔值

启用 NSSA。

选项

  • false

  • true

translate

字符串

NSSA-ABR。

选项

  • "always"

  • "candidate"

  • "never"

stub

字典

存根 OSPFv2 区域。

default_cost

整数

存根区域的默认成本摘要。

no_summary

布尔值

不要将区域间路由注入存根。

选项

  • false

  • true

set

布尔值

启用存根。

选项

  • false

  • true

authentication

字符串

OSPFv2 区域认证类型。

选项

  • "plaintext-password"

  • "md5"

network

列表 / 元素=字典

OSPFv2 网络。

address

字符串 / 必填

OSPFv2 IPv4 网络地址。

range

列表 / 元素=字典

汇总匹配前缀的路由(仅限边界路由器)。

address

字符串

边界路由器 IPv4 地址。

cost

整数

此范围的度量。

not_advertise

布尔值

不要通告此范围。

选项

  • false

  • true

substitute

字符串

将区域范围(IPv4 地址)通告为另一个前缀。

shortcut

字符串

区域的快捷方式模式。

选项

  • "default"

  • "disable"

  • "enable"

列表 / 元素=字典

虚拟链路地址。

字符串

虚拟链路地址。

字典

OSPFv2 区域认证类型。

列表 / 元素=字典

基于 MD5 密钥 ID 的身份验证。

整数

MD5 密钥 ID。

字符串

MD5 密钥。

字符串

纯文本密码。

整数

声明邻居失效后的时间间隔。

整数

Hello 数据包之间的时间间隔。

整数

重新传输丢失的链路状态通告之间的时间间隔。

整数

链路状态传输延迟。

auto_cost

字典

根据带宽计算 OSPFv2 接口成本。

reference_bandwidth

整数

参考带宽成本(Mbit/秒)。

default_information

字典

控制默认信息的分配。

originate

字典

分发默认路由。

always

布尔值

始终通告默认路由。

选项

  • false

  • true

metric

整数

OSPFv2 默认度量。

metric_type

整数

默认路由的 OSPFv2 度量类型。

route_map

字符串

路由映射引用。

default_metric

整数

重新分发路由的度量

distance

字典

管理距离。

global

整数

全局 OSPFv2 管理距离。

ospf

字典

OSPFv2 管理距离。

external

整数

外部路由的距离。

inter_area

整数

区域间路由的距离。

intra_area

整数

区域内路由的距离。

log_adjacency_changes

字符串

记录邻接状态的变化。

选项

  • "detail"

max_metric

字典

OSPFv2 最大/无限距离度量。

router_lsa

字典

使用无限距离通告自己的路由器 LSA(存根路由器)。

administrative

布尔值

管理上应用,无限期。

选项

  • false

  • true

on_shutdown

整数

通告自身为存根路由器的时间。

on_startup

整数

通告自身为存根路由器的时间

mpls_te

字典

多协议标签交换-流量工程 (MPLS-TE) 参数。

enabled

布尔值

启用 MPLS-TE 功能。

选项

  • false

  • true

router_address

字符串

通告路由器的稳定 IP 地址。

neighbor

列表 / 元素=字典

邻居 IP 地址。

neighbor_id

字符串

邻居的标识(编号/IP 地址)。

poll_interval

整数

失效邻居轮询间隔之间的秒数。

priority

整数

邻居优先级。

parameters

字典

OSPFv2 特定参数。

abr_type

字符串

OSPFv2 ABR 类型。

选项

  • "cisco"

  • "ibm"

  • "shortcut"

  • "standard"

opaque_lsa

布尔值

启用不透明 LSA 功能 (rfc2370)。

选项

  • false

  • true

rfc1583_compatibility

布尔值

启用用于处理 AS 外部路由的 rfc1583 标准。

选项

  • false

  • true

router_id

字符串

覆盖默认路由器标识符。

passive_interface

列表 / 元素=字符串

抑制接口上的路由更新。

passive_interface_exclude

列表 / 元素=字符串

使用 passive-interface default 时要排除的接口。

redistribute

列表 / 元素=字典

重新分发来自其他路由协议的信息。

metric

整数

重新分发路由的度量。

metric_type

整数

OSPFv2 度量类型。

route_map

字符串

路由映射引用。

route_type

字符串

要重新分发的路由类型。

选项

  • "bgp"

  • "connected"

  • "kernel"

  • "rip"

  • "static"

route_map

列表 / 元素=字符串

过滤在本地路由映射中安装的路由。

timers

字典

调整路由计时器。

refresh

字典

调整刷新参数。

timers

整数

刷新计时器。

throttle

字典

限制自适应计时器。

spf

字典

OSPFv2 SPF 计时器。

delay

整数

从收到第一个更改到执行 SPF 计算的延迟(毫秒)。

initial_holdtime

整数

连续 SPF 计算之间的初始保持时间(毫秒)。

max_holdtime

整数

最大保持时间(秒)。

running_config

字符串

此选项仅在状态为 *parsed* 时使用。

此选项的值应为通过执行命令 **show configuration commands | grep ospf** 从 VyOS 设备接收到的输出。

状态parsedrunning_config选项读取配置,并根据资源模块的argspec将其转换为Ansible结构化数据,然后将值返回到结果中的parsed键中。

state

字符串

配置应保留的状态。

选项

  • "merged" ← (默认)

  • "replaced"

  • "deleted"

  • "parsed"

  • "gathered"

  • "rendered"

备注

注意

  • 已在 VyOS 1.1.8 (helium) 上测试。

  • 此模块与连接ansible.netcommon.network_cli一起使用。请参见VyOS 操作系统平台选项

示例

# Using merged
#
# Before state:
# -------------
#
# vyos@vyos# run show  configuration commands | grep ospf
#
#
- name: Merge the provided configuration with the existing running configuration
  vyos.vyos.vyos_ospfv2:
    config:
      log_adjacency_changes: detail
      max_metric:
        router_lsa:
          administrative: true
          on_shutdown: 10
          on_startup: 10
        default_information:
          originate:
            always: true
            metric: 10
            metric_type: 2
            route_map: ingress
        mpls_te:
          enabled: true
          router_address: 192.0.11.11
        auto_cost:
          reference_bandwidth: 2
        neighbor:
          - neighbor_id: 192.0.11.12
            poll_interval: 10
            priority: 2
        redistribute:
          - route_type: bgp
            metric: 10
            metric_type: 2
        passive_interface:
          - eth1
          - eth2
        parameters:
          router_id: 192.0.1.1
          opaque_lsa: true
          rfc1583_compatibility: true
          abr_type: cisco
        areas:
          - area_id: '2'
            area_type:
              normal: true
              authentication: plaintext-password
              shortcut: enable
          - area_id: '3'
            area_type:
              nssa:
                set: true
          - area_id: '4'
            area_type:
              stub:
                default_cost: 20
            network:
              - address: 192.0.2.0/24
            range:
              - address: 192.0.3.0/24
                cost: 10
              - address: 192.0.4.0/24
            cost: 12
    state: merged
#
#
# -------------------------
# Module Execution Result
# -------------------------
#
# before": {}
#
#    "commands": [
#       "set protocols ospf mpls-te enable",
#       "set protocols ospf mpls-te router-address '192.0.11.11'",
#       "set protocols ospf redistribute bgp",
#       "set protocols ospf redistribute bgp metric-type 2",
#       "set protocols ospf redistribute bgp metric 10",
#       "set protocols ospf default-information originate metric-type 2",
#       "set protocols ospf default-information originate always",
#       "set protocols ospf default-information originate metric 10",
#       "set protocols ospf default-information originate route-map ingress",
#       "set protocols ospf auto-cost reference-bandwidth '2'",
#       "set protocols ospf parameters router-id '192.0.1.1'",
#       "set protocols ospf parameters opaque-lsa",
#       "set protocols ospf parameters abr-type 'cisco'",
#       "set protocols ospf parameters rfc1583-compatibility",
#       "set protocols ospf passive-interface eth1",
#       "set protocols ospf passive-interface eth2",
#       "set protocols ospf max-metric router-lsa on-shutdown 10",
#       "set protocols ospf max-metric router-lsa administrative",
#       "set protocols ospf max-metric router-lsa on-startup 10",
#       "set protocols ospf log-adjacency-changes 'detail'",
#       "set protocols ospf neighbor 192.0.11.12 priority 2",
#       "set protocols ospf neighbor 192.0.11.12 poll-interval 10",
#       "set protocols ospf neighbor 192.0.11.12",
#       "set protocols ospf area '2'",
#       "set protocols ospf area 2 authentication plaintext-password",
#       "set protocols ospf area 2 shortcut enable",
#       "set protocols ospf area 2 area-type normal",
#       "set protocols ospf area '3'",
#       "set protocols ospf area 3 area-type nssa",
#       "set protocols ospf area 4 range 192.0.3.0/24 cost 10",
#       "set protocols ospf area 4 range 192.0.3.0/24",
#       "set protocols ospf area 4 range 192.0.4.0/24 cost 12",
#       "set protocols ospf area 4 range 192.0.4.0/24",
#       "set protocols ospf area 4 area-type stub default-cost 20",
#       "set protocols ospf area '4'",
#       "set protocols ospf area 4 network 192.0.2.0/24"
#    ]
#
# "after": {
#        "areas": [
#            {
#                "area_id": "2",
#                "area_type": {
#                    "normal": true
#                },
#                "authentication": "plaintext-password",
#                "shortcut": "enable"
#            },
#            {
#                "area_id": "3",
#                "area_type": {
#                    "nssa": {
#                        "set": true
#                    }
#                }
#            },
#            {
#                "area_id": "4",
#                "area_type": {
#                    "stub": {
#                        "default_cost": 20,
#                        "set": true
#                    }
#                },
#                "network": [
#                    {
#                        "address": "192.0.2.0/24"
#                    }
#                ],
#                "range": [
#                    {
#                        "address": "192.0.3.0/24",
#                        "cost": 10
#                    },
#                    {
#                        "address": "192.0.4.0/24",
#                        "cost": 12
#                    }
#                ]
#            }
#        ],
#        "auto_cost": {
#            "reference_bandwidth": 2
#        },
#        "default_information": {
#            "originate": {
#                "always": true,
#                "metric": 10,
#                "metric_type": 2,
#                "route_map": "ingress"
#            }
#        },
#        "log_adjacency_changes": "detail",
#        "max_metric": {
#            "router_lsa": {
#                "administrative": true,
#                "on_shutdown": 10,
#                "on_startup": 10
#            }
#        },
#        "mpls_te": {
#            "enabled": true,
#            "router_address": "192.0.11.11"
#        },
#        "neighbor": [
#            {
#                "neighbor_id": "192.0.11.12",
#                "poll_interval": 10,
#                "priority": 2
#            }
#        ],
#        "parameters": {
#            "abr_type": "cisco",
#            "opaque_lsa": true,
#            "rfc1583_compatibility": true,
#            "router_id": "192.0.1.1"
#        },
#        "passive_interface": [
#            "eth2",
#            "eth1"
#        ],
#        "redistribute": [
#            {
#                "metric": 10,
#                "metric_type": 2,
#                "route_type": "bgp"
#            }
#        ]
#    }
#
# After state:
# -------------
#
# vyos@192# run show configuration commands | grep ospf
# set protocols ospf area 2 area-type 'normal'
# set protocols ospf area 2 authentication 'plaintext-password'
# set protocols ospf area 2 shortcut 'enable'
# set protocols ospf area 3 area-type 'nssa'
# set protocols ospf area 4 area-type stub default-cost '20'
# set protocols ospf area 4 network '192.0.2.0/24'
# set protocols ospf area 4 range 192.0.3.0/24 cost '10'
# set protocols ospf area 4 range 192.0.4.0/24 cost '12'
# set protocols ospf auto-cost reference-bandwidth '2'
# set protocols ospf default-information originate 'always'
# set protocols ospf default-information originate metric '10'
# set protocols ospf default-information originate metric-type '2'
# set protocols ospf default-information originate route-map 'ingress'
# set protocols ospf log-adjacency-changes 'detail'
# set protocols ospf max-metric router-lsa 'administrative'
# set protocols ospf max-metric router-lsa on-shutdown '10'
# set protocols ospf max-metric router-lsa on-startup '10'
# set protocols ospf mpls-te 'enable'
# set protocols ospf mpls-te router-address '192.0.11.11'
# set protocols ospf neighbor 192.0.11.12 poll-interval '10'
# set protocols ospf neighbor 192.0.11.12 priority '2'
# set protocols ospf parameters abr-type 'cisco'
# set protocols ospf parameters 'opaque-lsa'
# set protocols ospf parameters 'rfc1583-compatibility'
# set protocols ospf parameters router-id '192.0.1.1'
# set protocols ospf passive-interface 'eth1'
# set protocols ospf passive-interface 'eth2'
# set protocols ospf redistribute bgp metric '10'
# set protocols ospf redistribute bgp metric-type '2'


# Using merged
#
# Before state:
# -------------
#
# vyos@vyos# run show  configuration commands | grep ospf
#
#
- name: Merge the provided configuration to update existing running configuration
  vyos.vyos.vyos_ospfv2:
    config:
      areas:
        - area_id: '2'
          area_type:
            normal: true
          authentication: plaintext-password
          shortcut: enable
        - area_id: '3'
          area_type:
            nssa:
              set: false
        - area_id: '4'
          area_type:
            stub:
              default_cost: 20
          network:
            - address: 192.0.2.0/24
            - address: 192.0.22.0/24
            - address: 192.0.32.0/24
    state: merged
#
#
# -------------------------
# Module Execution Result
# -------------------------
#
# "before": {
#        "areas": [
#            {
#                "area_id": "2",
#                "area_type": {
#                    "normal": true
#                },
#                "authentication": "plaintext-password",
#                "shortcut": "enable"
#            },
#            {
#                "area_id": "3",
#                "area_type": {
#                    "nssa": {
#                        "set": true
#                    }
#                }
#            },
#            {
#                "area_id": "4",
#                "area_type": {
#                    "stub": {
#                        "default_cost": 20,
#                        "set": true
#                    }
#                },
#                "network": [
#                    {
#                        "address": "192.0.2.0/24"
#                    }
#                ],
#                "range": [
#                    {
#                        "address": "192.0.3.0/24",
#                        "cost": 10
#                    },
#                    {
#                        "address": "192.0.4.0/24",
#                        "cost": 12
#                    }
#                ]
#            }
#        ],
#        "auto_cost": {
#            "reference_bandwidth": 2
#        },
#        "default_information": {
#            "originate": {
#                "always": true,
#                "metric": 10,
#                "metric_type": 2,
#                "route_map": "ingress"
#            }
#        },
#        "log_adjacency_changes": "detail",
#        "max_metric": {
#            "router_lsa": {
#                "administrative": true,
#                "on_shutdown": 10,
#                "on_startup": 10
#            }
#        },
#        "mpls_te": {
#            "enabled": true,
#            "router_address": "192.0.11.11"
#        },
#        "neighbor": [
#            {
#                "neighbor_id": "192.0.11.12",
#                "poll_interval": 10,
#                "priority": 2
#            }
#        ],
#        "parameters": {
#            "abr_type": "cisco",
#            "opaque_lsa": true,
#            "rfc1583_compatibility": true,
#            "router_id": "192.0.1.1"
#        },
#        "passive_interface": [
#            "eth2",
#            "eth1"
#        ],
#        "redistribute": [
#            {
#                "metric": 10,
#                "metric_type": 2,
#                "route_type": "bgp"
#            }
#        ]
#    }
#
#    "commands": [
#       "delete protocols ospf area 4 area-type stub",
#       "set protocols ospf area 4 network 192.0.22.0/24"
#       "set protocols ospf area 4 network 192.0.32.0/24"
#    ]
#
# "after": {
#        "areas": [
#            {
#                "area_id": "2",
#                "area_type": {
#                    "normal": true
#                },
#                "authentication": "plaintext-password",
#                "shortcut": "enable"
#            },
#            {
#                "area_id": "3",
#                "area_type": {
#                    "nssa": {
#                        "set": true
#                    }
#                }
#            },
#            {
#                "area_id": "4",
#                },
#                "network": [
#                    {
#                        "address": "192.0.2.0/24"
#                    },
#                    {
#                        "address": "192.0.22.0/24"
#                    },
#                    {
#                        "address": "192.0.32.0/24"
#                    }
#                ],
#                "range": [
#                    {
#                        "address": "192.0.3.0/24",
#                        "cost": 10
#                    },
#                    {
#                        "address": "192.0.4.0/24",
#                        "cost": 12
#                    }
#                ]
#            }
#        ],
#        "auto_cost": {
#            "reference_bandwidth": 2
#        },
#        "default_information": {
#            "originate": {
#                "always": true,
#                "metric": 10,
#                "metric_type": 2,
#                "route_map": "ingress"
#            }
#        },
#        "log_adjacency_changes": "detail",
#        "max_metric": {
#            "router_lsa": {
#                "administrative": true,
#                "on_shutdown": 10,
#                "on_startup": 10
#            }
#        },
#        "mpls_te": {
#            "enabled": true,
#            "router_address": "192.0.11.11"
#        },
#        "neighbor": [
#            {
#                "neighbor_id": "192.0.11.12",
#                "poll_interval": 10,
#                "priority": 2
#            }
#        ],
#        "parameters": {
#            "abr_type": "cisco",
#            "opaque_lsa": true,
#            "rfc1583_compatibility": true,
#            "router_id": "192.0.1.1"
#        },
#        "passive_interface": [
#            "eth2",
#            "eth1"
#        ],
#        "redistribute": [
#            {
#                "metric": 10,
#                "metric_type": 2,
#                "route_type": "bgp"
#            }
#        ]
#    }
#
# After state:
# -------------
#
# vyos@192# run show configuration commands | grep ospf
# set protocols ospf area 2 area-type 'normal'
# set protocols ospf area 2 authentication 'plaintext-password'
# set protocols ospf area 2 shortcut 'enable'
# set protocols ospf area 3 area-type 'nssa'
# set protocols ospf area 4 network '192.0.2.0/24'
# set protocols ospf area 4 network '192.0.22.0/24'
# set protocols ospf area 4 network '192.0.32.0/24'
# set protocols ospf area 4 range 192.0.3.0/24 cost '10'
# set protocols ospf area 4 range 192.0.4.0/24 cost '12'
# set protocols ospf auto-cost reference-bandwidth '2'
# set protocols ospf default-information originate 'always'
# set protocols ospf default-information originate metric '10'
# set protocols ospf default-information originate metric-type '2'
# set protocols ospf default-information originate route-map 'ingress'
# set protocols ospf log-adjacency-changes 'detail'
# set protocols ospf max-metric router-lsa 'administrative'
# set protocols ospf max-metric router-lsa on-shutdown '10'
# set protocols ospf max-metric router-lsa on-startup '10'
# set protocols ospf mpls-te 'enable'
# set protocols ospf mpls-te router-address '192.0.11.11'
# set protocols ospf neighbor 192.0.11.12 poll-interval '10'
# set protocols ospf neighbor 192.0.11.12 priority '2'
# set protocols ospf parameters abr-type 'cisco'
# set protocols ospf parameters 'opaque-lsa'
# set protocols ospf parameters 'rfc1583-compatibility'
# set protocols ospf parameters router-id '192.0.1.1'
# set protocols ospf passive-interface 'eth1'
# set protocols ospf passive-interface 'eth2'
# set protocols ospf redistribute bgp metric '10'
# set protocols ospf redistribute bgp metric-type '2'


# Using replaced
#
# Before state:
# -------------
#
# vyos@192# run show configuration commands | grep ospf
# set protocols ospf area 2 area-type 'normal'
# set protocols ospf area 2 authentication 'plaintext-password'
# set protocols ospf area 2 shortcut 'enable'
# set protocols ospf area 3 area-type 'nssa'
# set protocols ospf area 4 area-type stub default-cost '20'
# set protocols ospf area 4 network '192.0.2.0/24'
# set protocols ospf area 4 range 192.0.3.0/24 cost '10'
# set protocols ospf area 4 range 192.0.4.0/24 cost '12'
# set protocols ospf auto-cost reference-bandwidth '2'
# set protocols ospf default-information originate 'always'
# set protocols ospf default-information originate metric '10'
# set protocols ospf default-information originate metric-type '2'
# set protocols ospf default-information originate route-map 'ingress'
# set protocols ospf log-adjacency-changes 'detail'
# set protocols ospf max-metric router-lsa 'administrative'
# set protocols ospf max-metric router-lsa on-shutdown '10'
# set protocols ospf max-metric router-lsa on-startup '10'
# set protocols ospf mpls-te 'enable'
# set protocols ospf mpls-te router-address '192.0.11.11'
# set protocols ospf neighbor 192.0.11.12 poll-interval '10'
# set protocols ospf neighbor 192.0.11.12 priority '2'
# set protocols ospf parameters abr-type 'cisco'
# set protocols ospf parameters 'opaque-lsa'
# set protocols ospf parameters 'rfc1583-compatibility'
# set protocols ospf parameters router-id '192.0.1.1'
# set protocols ospf passive-interface 'eth1'
# set protocols ospf passive-interface 'eth2'
# set protocols ospf redistribute bgp metric '10'
# set protocols ospf redistribute bgp metric-type '2'
#
- name: Replace ospfv2 routes attributes configuration.
  vyos.vyos.vyos_ospfv2:
    config:
      log_adjacency_changes: detail
      max_metric:
        router_lsa:
          administrative: true
          on_shutdown: 10
          on_startup: 10
        default_information:
          originate:
            always: true
            metric: 10
            metric_type: 2
            route_map: ingress
        mpls_te:
          enabled: true
          router_address: 192.0.22.22
        auto_cost:
          reference_bandwidth: 2
        neighbor:
          - neighbor_id: 192.0.11.12
            poll_interval: 10
            priority: 2
        redistribute:
          - route_type: bgp
            metric: 10
            metric_type: 2
        passive_interface:
          - eth1
        parameters:
          router_id: 192.0.1.1
          opaque_lsa: true
          rfc1583_compatibility: true
          abr_type: cisco
        areas:
          - area_id: '2'
            area_type:
              normal: true
            authentication: plaintext-password
            shortcut: enable
          - area_id: '4'
            area_type:
              stub:
                default_cost: 20
            network:
              - address: 192.0.2.0/24
              - address: 192.0.12.0/24
              - address: 192.0.22.0/24
              - address: 192.0.32.0/24
            range:
              - address: 192.0.42.0/24
                cost: 10
    state: replaced

#
#
# -------------------------
# Module Execution Result
# -------------------------
#
#    "before": {
#        "areas": [
#            {
#                "area_id": "2",
#                "area_type": {
#                    "normal": true
#                },
#                "authentication": "plaintext-password",
#                "shortcut": "enable"
#            },
#            {
#                "area_id": "3",
#                "area_type": {
#                    "nssa": {
#                        "set": true
#                    }
#                }
#            },
#            {
#                "area_id": "4",
#                "area_type": {
#                    "stub": {
#                        "default_cost": 20,
#                        "set": true
#                    }
#                },
#                "network": [
#                    {
#                        "address": "192.0.2.0/24"
#                    }
#                ],
#                "range": [
#                    {
#                        "address": "192.0.3.0/24",
#                        "cost": 10
#                    },
#                    {
#                        "address": "192.0.4.0/24",
#                        "cost": 12
#                    }
#                ]
#            }
#        ],
#        "auto_cost": {
#            "reference_bandwidth": 2
#        },
#        "default_information": {
#            "originate": {
#                "always": true,
#                "metric": 10,
#                "metric_type": 2,
#                "route_map": "ingress"
#            }
#        },
#        "log_adjacency_changes": "detail",
#        "max_metric": {
#            "router_lsa": {
#                "administrative": true,
#                "on_shutdown": 10,
#                "on_startup": 10
#            }
#        },
#        "mpls_te": {
#            "enabled": true,
#            "router_address": "192.0.11.11"
#        },
#        "neighbor": [
#            {
#                "neighbor_id": "192.0.11.12",
#                "poll_interval": 10,
#                "priority": 2
#            }
#        ],
#        "parameters": {
#            "abr_type": "cisco",
#            "opaque_lsa": true,
#            "rfc1583_compatibility": true,
#            "router_id": "192.0.1.1"
#        },
#        "passive_interface": [
#            "eth2",
#            "eth1"
#        ],
#        "redistribute": [
#            {
#                "metric": 10,
#                "metric_type": 2,
#                "route_type": "bgp"
#            }
#        ]
#    }
#
# "commands": [
#     "delete protocols ospf passive-interface eth2",
#     "delete protocols ospf area 3",
#     "delete protocols ospf area 4 range 192.0.3.0/24 cost",
#     "delete protocols ospf area 4 range 192.0.3.0/24",
#     "delete protocols ospf area 4 range 192.0.4.0/24 cost",
#     "delete protocols ospf area 4 range 192.0.4.0/24",
#     "set protocols ospf mpls-te router-address '192.0.22.22'",
#     "set protocols ospf area 4 range 192.0.42.0/24 cost 10",
#     "set protocols ospf area 4 range 192.0.42.0/24",
#     "set protocols ospf area 4 network 192.0.12.0/24",
#     "set protocols ospf area 4 network 192.0.22.0/24",
#     "set protocols ospf area 4 network 192.0.32.0/24"
#    ]
#
#    "after": {
#        "areas": [
#            {
#                "area_id": "2",
#                "area_type": {
#                    "normal": true
#                },
#                "authentication": "plaintext-password",
#                "shortcut": "enable"
#            },
#            {
#                "area_id": "4",
#                "area_type": {
#                    "stub": {
#                        "default_cost": 20,
#                        "set": true
#                    }
#                },
#                "network": [
#                    {
#                        "address": "192.0.12.0/24"
#                    },
#                    {
#                        "address": "192.0.2.0/24"
#                    },
#                    {
#                        "address": "192.0.22.0/24"
#                    },
#                    {
#                        "address": "192.0.32.0/24"
#                    }
#                ],
#                "range": [
#                    {
#                        "address": "192.0.42.0/24",
#                        "cost": 10
#                    }
#                ]
#            }
#        ],
#        "auto_cost": {
#            "reference_bandwidth": 2
#        },
#        "default_information": {
#            "originate": {
#                "always": true,
#                "metric": 10,
#                "metric_type": 2,
#                "route_map": "ingress"
#            }
#        },
#        "log_adjacency_changes": "detail",
#        "max_metric": {
#            "router_lsa": {
#                "administrative": true,
#                "on_shutdown": 10,
#                "on_startup": 10
#            }
#        },
#        "mpls_te": {
#            "enabled": true,
#            "router_address": "192.0.22.22"
#        },
#        "neighbor": [
#            {
#                "neighbor_id": "192.0.11.12",
#                "poll_interval": 10,
#                "priority": 2
#            }
#        ],
#        "parameters": {
#            "abr_type": "cisco",
#            "opaque_lsa": true,
#            "rfc1583_compatibility": true,
#            "router_id": "192.0.1.1"
#        },
#        "passive_interface": [
#            "eth1"
#        ],
#        "redistribute": [
#            {
#                "metric": 10,
#                "metric_type": 2,
#                "route_type": "bgp"
#            }
#        ]
#    }
#
# After state:
# -------------
#
# vyos@192# run show configuration commands | grep ospf
# set protocols ospf area 2 area-type 'normal'
# set protocols ospf area 2 authentication 'plaintext-password'
# set protocols ospf area 2 shortcut 'enable'
# set protocols ospf area 4 area-type stub default-cost '20'
# set protocols ospf area 4 network '192.0.2.0/24'
# set protocols ospf area 4 network '192.0.12.0/24'
# set protocols ospf area 4 network '192.0.22.0/24'
# set protocols ospf area 4 network '192.0.32.0/24'
# set protocols ospf area 4 range 192.0.42.0/24 cost '10'
# set protocols ospf auto-cost reference-bandwidth '2'
# set protocols ospf default-information originate 'always'
# set protocols ospf default-information originate metric '10'
# set protocols ospf default-information originate metric-type '2'
# set protocols ospf default-information originate route-map 'ingress'
# set protocols ospf log-adjacency-changes 'detail'
# set protocols ospf max-metric router-lsa 'administrative'
# set protocols ospf max-metric router-lsa on-shutdown '10'
# set protocols ospf max-metric router-lsa on-startup '10'
# set protocols ospf mpls-te 'enable'
# set protocols ospf mpls-te router-address '192.0.22.22'
# set protocols ospf neighbor 192.0.11.12 poll-interval '10'
# set protocols ospf neighbor 192.0.11.12 priority '2'
# set protocols ospf parameters abr-type 'cisco'
# set protocols ospf parameters 'opaque-lsa'
# set protocols ospf parameters 'rfc1583-compatibility'
# set protocols ospf parameters router-id '192.0.1.1'
# set protocols ospf passive-interface 'eth1'
# set protocols ospf redistribute bgp metric '10'
# set protocols ospf redistribute bgp metric-type '2'


# Using rendered
#
#
- name: Render the commands for provided  configuration
  vyos.vyos.vyos_ospfv2:
    config:
      log_adjacency_changes: detail
      max_metric:
        router_lsa:
          administrative: true
          on_shutdown: 10
          on_startup: 10
        default_information:
          originate:
            always: true
            metric: 10
            metric_type: 2
            route_map: ingress
        mpls_te:
          enabled: true
          router_address: 192.0.11.11
        auto_cost:
          reference_bandwidth: 2
        neighbor:
          - neighbor_id: 192.0.11.12
            poll_interval: 10
            priority: 2
        redistribute:
          - route_type: bgp
            metric: 10
            metric_type: 2
        passive_interface:
          - eth1
          - eth2
        parameters:
          router_id: 192.0.1.1
          opaque_lsa: true
          rfc1583_compatibility: true
          abr_type: cisco
        areas:
          - area_id: '2'
            area_type:
              normal: true
            authentication: plaintext-password
            shortcut: enable
          - area_id: '3'
            area_type:
              nssa:
                set: true
          - area_id: '4'
            area_type:
              stub:
                default_cost: 20
            network:
              - address: 192.0.2.0/24
            range:
              - address: 192.0.3.0/24
                cost: 10
              - address: 192.0.4.0/24
                cost: 12
    state: rendered
#
#
# -------------------------
# Module Execution Result
# -------------------------
#
#
# "rendered": [
#        [
#       "set protocols ospf mpls-te enable",
#       "set protocols ospf mpls-te router-address '192.0.11.11'",
#       "set protocols ospf redistribute bgp",
#       "set protocols ospf redistribute bgp metric-type 2",
#       "set protocols ospf redistribute bgp metric 10",
#       "set protocols ospf default-information originate metric-type 2",
#       "set protocols ospf default-information originate always",
#       "set protocols ospf default-information originate metric 10",
#       "set protocols ospf default-information originate route-map ingress",
#       "set protocols ospf auto-cost reference-bandwidth '2'",
#       "set protocols ospf parameters router-id '192.0.1.1'",
#       "set protocols ospf parameters opaque-lsa",
#       "set protocols ospf parameters abr-type 'cisco'",
#       "set protocols ospf parameters rfc1583-compatibility",
#       "set protocols ospf passive-interface eth1",
#       "set protocols ospf passive-interface eth2",
#       "set protocols ospf max-metric router-lsa on-shutdown 10",
#       "set protocols ospf max-metric router-lsa administrative",
#       "set protocols ospf max-metric router-lsa on-startup 10",
#       "set protocols ospf log-adjacency-changes 'detail'",
#       "set protocols ospf neighbor 192.0.11.12 priority 2",
#       "set protocols ospf neighbor 192.0.11.12 poll-interval 10",
#       "set protocols ospf neighbor 192.0.11.12",
#       "set protocols ospf area '2'",
#       "set protocols ospf area 2 authentication plaintext-password",
#       "set protocols ospf area 2 shortcut enable",
#       "set protocols ospf area 2 area-type normal",
#       "set protocols ospf area '3'",
#       "set protocols ospf area 3 area-type nssa",
#       "set protocols ospf area 4 range 192.0.3.0/24 cost 10",
#       "set protocols ospf area 4 range 192.0.3.0/24",
#       "set protocols ospf area 4 range 192.0.4.0/24 cost 12",
#       "set protocols ospf area 4 range 192.0.4.0/24",
#       "set protocols ospf area 4 area-type stub default-cost 20",
#       "set protocols ospf area '4'",
#       "set protocols ospf area 4 network 192.0.2.0/24"
#    ]


# Using parsed
#
#
- name: Parse the commands for provided  structured configuration
  vyos.vyos.vyos_ospfv2:
    running_config:
      "set protocols ospf area 2 area-type 'normal'
       set protocols ospf area 2 authentication 'plaintext-password'
       set protocols ospf area 2 shortcut 'enable'
       set protocols ospf area 3 area-type 'nssa'
       set protocols ospf area 4 area-type stub default-cost '20'
       set protocols ospf area 4 network '192.0.2.0/24'
       set protocols ospf area 4 range 192.0.3.0/24 cost '10'
       set protocols ospf area 4 range 192.0.4.0/24 cost '12'
       set protocols ospf auto-cost reference-bandwidth '2'
       set protocols ospf default-information originate 'always'
       set protocols ospf default-information originate metric '10'
       set protocols ospf default-information originate metric-type '2'
       set protocols ospf default-information originate route-map 'ingress'
       set protocols ospf log-adjacency-changes 'detail'
       set protocols ospf max-metric router-lsa 'administrative'
       set protocols ospf max-metric router-lsa on-shutdown '10'
       set protocols ospf max-metric router-lsa on-startup '10'
       set protocols ospf mpls-te 'enable'
       set protocols ospf mpls-te router-address '192.0.11.11'
       set protocols ospf neighbor 192.0.11.12 poll-interval '10'
       set protocols ospf neighbor 192.0.11.12 priority '2'
       set protocols ospf parameters abr-type 'cisco'
       set protocols ospf parameters 'opaque-lsa'
       set protocols ospf parameters 'rfc1583-compatibility'
       set protocols ospf parameters router-id '192.0.1.1'
       set protocols ospf passive-interface 'eth1'
       set protocols ospf passive-interface 'eth2'
       set protocols ospf redistribute bgp metric '10'
       set protocols ospf redistribute bgp metric-type '2'"
    state: parsed
#
#
# -------------------------
# Module Execution Result
# -------------------------
#
#
# "parsed": {
#        "areas": [
#            {
#                "area_id": "2",
#                "area_type": {
#                    "normal": true
#                },
#                "authentication": "plaintext-password",
#                "shortcut": "enable"
#            },
#            {
#                "area_id": "3",
#                "area_type": {
#                    "nssa": {
#                        "set": true
#                    }
#                }
#            },
#            {
#                "area_id": "4",
#                "area_type": {
#                    "stub": {
#                        "default_cost": 20,
#                        "set": true
#                    }
#                },
#                "network": [
#                    {
#                        "address": "192.0.2.0/24"
#                    }
#                ],
#                "range": [
#                    {
#                        "address": "192.0.3.0/24",
#                        "cost": 10
#                    },
#                    {
#                        "address": "192.0.4.0/24",
#                        "cost": 12
#                    }
#                ]
#            }
#        ],
#        "auto_cost": {
#            "reference_bandwidth": 2
#        },
#        "default_information": {
#            "originate": {
#                "always": true,
#                "metric": 10,
#                "metric_type": 2,
#                "route_map": "ingress"
#            }
#        },
#        "log_adjacency_changes": "detail",
#        "max_metric": {
#            "router_lsa": {
#                "administrative": true,
#                "on_shutdown": 10,
#                "on_startup": 10
#            }
#        },
#        "mpls_te": {
#            "enabled": true,
#            "router_address": "192.0.11.11"
#        },
#        "neighbor": [
#            {
#                "neighbor_id": "192.0.11.12",
#                "poll_interval": 10,
#                "priority": 2
#            }
#        ],
#        "parameters": {
#            "abr_type": "cisco",
#            "opaque_lsa": true,
#            "rfc1583_compatibility": true,
#            "router_id": "192.0.1.1"
#        },
#        "passive_interface": [
#            "eth2",
#            "eth1"
#        ],
#        "redistribute": [
#            {
#                "metric": 10,
#                "metric_type": 2,
#                "route_type": "bgp"
#            }
#        ]
#    }
# }


# Using gathered
#
# Before state:
# -------------
#
# vyos@192# run show configuration commands | grep ospf
# set protocols ospf area 2 area-type 'normal'
# set protocols ospf area 2 authentication 'plaintext-password'
# set protocols ospf area 2 shortcut 'enable'
# set protocols ospf area 3 area-type 'nssa'
# set protocols ospf area 4 area-type stub default-cost '20'
# set protocols ospf area 4 network '192.0.2.0/24'
# set protocols ospf area 4 range 192.0.3.0/24 cost '10'
# set protocols ospf area 4 range 192.0.4.0/24 cost '12'
# set protocols ospf auto-cost reference-bandwidth '2'
# set protocols ospf default-information originate 'always'
# set protocols ospf default-information originate metric '10'
# set protocols ospf default-information originate metric-type '2'
# set protocols ospf default-information originate route-map 'ingress'
# set protocols ospf log-adjacency-changes 'detail'
# set protocols ospf max-metric router-lsa 'administrative'
# set protocols ospf max-metric router-lsa on-shutdown '10'
# set protocols ospf max-metric router-lsa on-startup '10'
# set protocols ospf mpls-te 'enable'
# set protocols ospf mpls-te router-address '192.0.11.11'
# set protocols ospf neighbor 192.0.11.12 poll-interval '10'
# set protocols ospf neighbor 192.0.11.12 priority '2'
# set protocols ospf parameters abr-type 'cisco'
# set protocols ospf parameters 'opaque-lsa'
# set protocols ospf parameters 'rfc1583-compatibility'
# set protocols ospf parameters router-id '192.0.1.1'
# set protocols ospf passive-interface 'eth1'
# set protocols ospf passive-interface 'eth2'
# set protocols ospf redistribute bgp metric '10'
# set protocols ospf redistribute bgp metric-type '2'
#
- name: Gather ospfv2 routes config with provided configurations
  vyos.vyos.vyos_ospfv2:
    config:
    state: gathered
#
#
# -------------------------
# Module Execution Result
# -------------------------
#
#    "gathered": {
#        "areas": [
#            {
#                "area_id": "2",
#                "area_type": {
#                    "normal": true
#                },
#                "authentication": "plaintext-password",
#                "shortcut": "enable"
#            },
#            {
#                "area_id": "3",
#                "area_type": {
#                    "nssa": {
#                        "set": true
#                    }
#                }
#            },
#            {
#                "area_id": "4",
#                "area_type": {
#                    "stub": {
#                        "default_cost": 20,
#                        "set": true
#                    }
#                },
#                "network": [
#                    {
#                        "address": "192.0.2.0/24"
#                    }
#                ],
#                "range": [
#                    {
#                        "address": "192.0.3.0/24",
#                        "cost": 10
#                    },
#                    {
#                        "address": "192.0.4.0/24",
#                        "cost": 12
#                    }
#                ]
#            }
#        ],
#        "auto_cost": {
#            "reference_bandwidth": 2
#        },
#        "default_information": {
#            "originate": {
#                "always": true,
#                "metric": 10,
#                "metric_type": 2,
#                "route_map": "ingress"
#            }
#        },
#        "log_adjacency_changes": "detail",
#        "max_metric": {
#            "router_lsa": {
#                "administrative": true,
#                "on_shutdown": 10,
#                "on_startup": 10
#            }
#        },
#        "mpls_te": {
#            "enabled": true,
#            "router_address": "192.0.11.11"
#        },
#        "neighbor": [
#            {
#                "neighbor_id": "192.0.11.12",
#                "poll_interval": 10,
#                "priority": 2
#            }
#        ],
#        "parameters": {
#            "abr_type": "cisco",
#            "opaque_lsa": true,
#            "rfc1583_compatibility": true,
#            "router_id": "192.0.1.1"
#        },
#        "passive_interface": [
#            "eth2",
#            "eth1"
#        ],
#        "redistribute": [
#            {
#                "metric": 10,
#                "metric_type": 2,
#                "route_type": "bgp"
#            }
#        ]
#    }
#
# After state:
# -------------
#
# vyos@192# run show configuration commands | grep ospf
# set protocols ospf area 2 area-type 'normal'
# set protocols ospf area 2 authentication 'plaintext-password'
# set protocols ospf area 2 shortcut 'enable'
# set protocols ospf area 3 area-type 'nssa'
# set protocols ospf area 4 area-type stub default-cost '20'
# set protocols ospf area 4 network '192.0.2.0/24'
# set protocols ospf area 4 range 192.0.3.0/24 cost '10'
# set protocols ospf area 4 range 192.0.4.0/24 cost '12'
# set protocols ospf auto-cost reference-bandwidth '2'
# set protocols ospf default-information originate 'always'
# set protocols ospf default-information originate metric '10'
# set protocols ospf default-information originate metric-type '2'
# set protocols ospf default-information originate route-map 'ingress'
# set protocols ospf log-adjacency-changes 'detail'
# set protocols ospf max-metric router-lsa 'administrative'
# set protocols ospf max-metric router-lsa on-shutdown '10'
# set protocols ospf max-metric router-lsa on-startup '10'
# set protocols ospf mpls-te 'enable'
# set protocols ospf mpls-te router-address '192.0.11.11'
# set protocols ospf neighbor 192.0.11.12 poll-interval '10'
# set protocols ospf neighbor 192.0.11.12 priority '2'
# set protocols ospf parameters abr-type 'cisco'
# set protocols ospf parameters 'opaque-lsa'
# set protocols ospf parameters 'rfc1583-compatibility'
# set protocols ospf parameters router-id '192.0.1.1'
# set protocols ospf passive-interface 'eth1'
# set protocols ospf passive-interface 'eth2'
# set protocols ospf redistribute bgp metric '10'
# set protocols ospf redistribute bgp metric-type '2'


# Using deleted
#
# Before state
# -------------
#
# vyos@192# run show configuration commands | grep ospf
# set protocols ospf area 2 area-type 'normal'
# set protocols ospf area 2 authentication 'plaintext-password'
# set protocols ospf area 2 shortcut 'enable'
# set protocols ospf area 3 area-type 'nssa'
# set protocols ospf area 4 area-type stub default-cost '20'
# set protocols ospf area 4 network '192.0.2.0/24'
# set protocols ospf area 4 range 192.0.3.0/24 cost '10'
# set protocols ospf area 4 range 192.0.4.0/24 cost '12'
# set protocols ospf auto-cost reference-bandwidth '2'
# set protocols ospf default-information originate 'always'
# set protocols ospf default-information originate metric '10'
# set protocols ospf default-information originate metric-type '2'
# set protocols ospf default-information originate route-map 'ingress'
# set protocols ospf log-adjacency-changes 'detail'
# set protocols ospf max-metric router-lsa 'administrative'
# set protocols ospf max-metric router-lsa on-shutdown '10'
# set protocols ospf max-metric router-lsa on-startup '10'
# set protocols ospf mpls-te 'enable'
# set protocols ospf mpls-te router-address '192.0.11.11'
# set protocols ospf neighbor 192.0.11.12 poll-interval '10'
# set protocols ospf neighbor 192.0.11.12 priority '2'
# set protocols ospf parameters abr-type 'cisco'
# set protocols ospf parameters 'opaque-lsa'
# set protocols ospf parameters 'rfc1583-compatibility'
# set protocols ospf parameters router-id '192.0.1.1'
# set protocols ospf passive-interface 'eth1'
# set protocols ospf passive-interface 'eth2'
# set protocols ospf redistribute bgp metric '10'
# set protocols ospf redistribute bgp metric-type '2'
#
- name: Delete attributes of ospfv2 routes.
  vyos.vyos.vyos_ospfv2:
    config:
    state: deleted
#
#
# ------------------------
# Module Execution Results
# ------------------------
#
#    "before": {
#        "areas": [
#            {
#                "area_id": "2",
#                "area_type": {
#                    "normal": true
#                },
#                "authentication": "plaintext-password",
#                "shortcut": "enable"
#            },
#            {
#                "area_id": "3",
#                "area_type": {
#                    "nssa": {
#                        "set": true
#                    }
#                }
#            },
#            {
#                "area_id": "4",
#                "area_type": {
#                    "stub": {
#                        "default_cost": 20,
#                        "set": true
#                    }
#                },
#                "network": [
#                    {
#                        "address": "192.0.2.0/24"
#                    }
#                ],
#                "range": [
#                    {
#                        "address": "192.0.3.0/24",
#                        "cost": 10
#                    },
#                    {
#                        "address": "192.0.4.0/24",
#                        "cost": 12
#                    }
#                ]
#            }
#        ],
#        "auto_cost": {
#            "reference_bandwidth": 2
#        },
#        "default_information": {
#            "originate": {
#                "always": true,
#                "metric": 10,
#                "metric_type": 2,
#                "route_map": "ingress"
#            }
#        },
#        "log_adjacency_changes": "detail",
#        "max_metric": {
#            "router_lsa": {
#                "administrative": true,
#                "on_shutdown": 10,
#                "on_startup": 10
#            }
#        },
#        "mpls_te": {
#            "enabled": true,
#            "router_address": "192.0.11.11"
#        },
#        "neighbor": [
#            {
#                "neighbor_id": "192.0.11.12",
#                "poll_interval": 10,
#                "priority": 2
#            }
#        ],
#        "parameters": {
#            "abr_type": "cisco",
#            "opaque_lsa": true,
#            "rfc1583_compatibility": true,
#            "router_id": "192.0.1.1"
#        },
#        "passive_interface": [
#            "eth2",
#            "eth1"
#        ],
#        "redistribute": [
#            {
#                "metric": 10,
#                "metric_type": 2,
#                "route_type": "bgp"
#            }
#        ]
#    }
# "commands": [
#        "delete protocols ospf"
#    ]
#
# "after": {}
# After state
# ------------
# vyos@192# run show configuration commands | grep ospf
#

返回值

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

描述

after

字典

生成的配置模型调用。

返回:发生更改时

示例:"The configuration returned will always be in the same format\n of the parameters above.\n"

before

字典

模型调用之前的配置。

返回:始终返回

示例:"The configuration returned will always be in the same format\n of the parameters above.\n"

commands

列表 / 元素=字符串

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

返回:始终返回

示例:["set protocols ospf parameters router-id 192.0.1.1", "set protocols ospf passive-interface 'eth1'"]

作者

  • Rohit Thakur (@rohitthakur2590)