community.routeros.facts 模块 – 从运行 MikroTik RouterOS 的远程设备收集信息

注意

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

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

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

要在 playbook 中使用它,请指定:community.routeros.facts

概要

  • 从运行 RouterOS 的远程设备收集一组基本设备信息。此模块将所有基本网络信息键加上前缀 ansible_net_<fact>。事实模块将始终从设备收集一组基本信息,并可以启用或禁用其他信息的收集。

参数

参数

注释

gather_subset

列表 / 元素=字符串

如果提供此参数,则会将收集的信息限制为给定的子集。此参数的可能值包括 allhardwareconfiginterfacesrouting

可以指定一个值列表以包含更大的子集。值也可以与初始的 ! 一起使用,以指定不应收集特定的子集。

默认值: ["!config"]

属性

属性

支持

描述

check_mode

支持:完全支持

此操作不会修改状态。

可以在 check_mode 中运行并返回已更改的状态预测,而无需修改目标。

diff_mode

支持: 不适用

此操作不会修改状态。

当处于 diff 模式时,将返回有关已更改内容(或在 check_mode 中可能需要更改的内容)的详细信息。

facts

支持:完全支持

操作返回一个 ansible_facts 字典,该字典将更新现有的主机信息。

platform

平台: RouterOS

可以对其进行操作的目标操作系统/系列。

另请参阅

另请参阅

如何使用 SSH 连接到 RouterOS 设备

如何使用 SSH 连接到 RouterOS 设备

示例

- name: Collect all facts from the device
  community.routeros.facts:
    gather_subset: all

- name: Collect only the config and default facts
  community.routeros.facts:
    gather_subset:
      - config

- name: Do not collect hardware facts
  community.routeros.facts:
    gather_subset:
      - "!hardware"

返回的事实

此模块返回的事实会添加到 hostvars 主机事实中并进行更新,并且可以像任何其他主机事实一样通过名称引用。它们不需要注册才能使用。

描述

ansible_net_all_ipv4_addresses

列表 / 元素=字符串

设备上配置的所有 IPv4 地址。

返回: gather_subset 包含 interfaces

ansible_net_all_ipv6_addresses

列表 / 元素=字符串

设备上配置的所有 IPv6 地址。

返回: gather_subset 包含 interfaces

ansible_net_arch

字符串

设备的 CPU 架构。

返回: gather_subset 包含 default

ansible_net_bgp_instance

字典

包含 BGP 实例信息的字典。

返回: gather_subset 包含 routing

ansible_net_bgp_peer

字典

包含 BGP 对等信息的字典。

返回: gather_subset 包含 routing

ansible_net_bgp_vpnv4_route

字典

包含 BGP vpnv4 路由信息的字典。

返回: gather_subset 包含 routing

ansible_net_config

字符串

来自设备的当前活动配置。

返回: gather_subset 包含 config

ansible_net_config_nonverbose

字符串

在 community.routeros 1.2.0 中添加

来自设备的当前活动配置,采用最小形式。

这个值是幂等的,也就是说,如果 facts 模块运行两次,并且设备配置在这两次运行之间没有更改,则该值是相同的。这是通过运行 /export 并删除第一行注释中的时间戳来实现的。

返回: gather_subset 包含 config

ansible_net_cpu_load

字符串

当前 CPU 负载。

返回: gather_subset 包含 default

ansible_net_gather_subset

列表 / 元素=字符串

从设备收集的事实子集列表。

返回: 总是

ansible_net_hostname

字符串

设备配置的主机名。

返回: gather_subset 包含 default

ansible_net_interfaces

字典

系统上所有正在运行的接口的哈希值。

返回: gather_subset 包含 interfaces

ansible_net_memfree_mb

整数

远程设备上可用的空闲内存,单位为 MiB。

返回: gather_subset 包含 hardware

ansible_net_memtotal_mb

整数

远程设备上的总内存,单位为 MiB。

返回: gather_subset 包含 hardware

ansible_net_model

字符串

设备返回的型号名称。

返回: gather_subset 包含 default

ansible_net_neighbors

字典

来自远程设备的邻居列表。

返回: gather_subset 包含 interfaces

ansible_net_ospf_instance

字典

包含 OSPF 实例的字典。

返回: gather_subset 包含 routing

ansible_net_ospf_neighbor

字典

包含 OSPF 邻居的字典。

返回: gather_subset 包含 routing

ansible_net_route

字典

所有路由表中的路由字典。

返回: gather_subset 包含 routing

ansible_net_serialnum

字符串

远程设备的序列号。

返回: gather_subset 包含 default

ansible_net_spacefree_mb

字典

远程设备上可用的磁盘空间,单位为 MiB。

返回: gather_subset 包含 hardware

ansible_net_spacetotal_mb

字典

远程设备上的总磁盘空间,单位为 MiB。

返回: gather_subset 包含 hardware

ansible_net_uptime

字符串

设备的正常运行时间。

返回: gather_subset 包含 default

ansible_net_version

字符串

远程设备上运行的操作系统版本。

返回: gather_subset 包含 default

作者

  • Egor Zaitsev (@heuels)