cisco.ios.ios_facts 模块 – 从远程设备收集事实的模块。

注意

此模块是 cisco.ios 集合 (版本 9.0.3) 的一部分。

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

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

要在 playbook 中使用它,请指定:cisco.ios.ios_facts

cisco.ios 1.0.0 中的新增功能

概要

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

参数

参数

注释

available_network_resources

布尔值

当为“True”时,将提供一个可用于资源模块的网络资源列表。

选项

  • false ← (默认)

  • true

gather_network_resources

列表 / 元素=字符串

当提供此参数时,它将收集的事实限制为给定的子集。此参数的可能值包括 all 和接口、vlan 等资源。可以指定一个值列表以包含更大的子集。值也可以与初始 ! 一起使用,以指定不应收集特定子集。有效的子集是“bgp_global”、“l3_interfaces”、“lag_interfaces”、“ntp_global”、“acls”、“hostname”、“interfaces”、“lldp_interfaces”、“logging_global”、“ospf_interfaces”、“ospfv2”、“prefix_lists”、“static_routes”、“acl_interfaces”、“all”、“bgp_address_family”、“l2_interfaces”、“lacp”、“lacp_interfaces”、“lldp_global”、“ospfv3”、“snmp_server”、“vlans”、“service”。

gather_subset

列表 / 元素=字符串

当提供此参数时,它将收集的事实限制为给定的子集。

此参数的可能值包括 allmindefaulthardwareconfiginterfaces

指定一个值列表以包含更大的子集。

使用以初始 ! 开头的值来收集除该子集之外的所有事实。

默认值: ["min"]

备注

注意

示例

- name: Gather all legacy facts
  cisco.ios.ios_facts:
    gather_subset: all

- name: Gather only the config and default facts
  cisco.ios.ios_facts:
    gather_subset:
      - config

- name: Do not gather hardware facts
  cisco.ios.ios_facts:
    gather_subset:
      - "!hardware"

- name: Gather legacy and resource facts
  cisco.ios.ios_facts:
    gather_subset: all
    gather_network_resources: all

- name: Gather only the interfaces resource facts and no legacy facts
  cisco.ios.ios_facts:
    gather_subset:
      - "!all"
      - "!min"
    gather_network_resources:
      - interfaces

- name: Gather interfaces resource and minimal legacy facts
  cisco.ios.ios_facts:
    gather_subset: min
    gather_network_resources: interfaces

- name: Gather L2 interfaces resource and minimal legacy facts
  cisco.ios.ios_facts:
    gather_subset: min
    gather_network_resources: l2_interfaces

- name: Gather L3 interfaces resource and minimal legacy facts
  cisco.ios.ios_facts:
    gather_subset: min
    gather_network_resources: l3_interfaces

返回值

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

描述

ansible_net_all_ipv4_addresses

列表 / 元素=字符串

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

返回:当配置接口时

ansible_net_all_ipv6_addresses

列表 / 元素=字符串

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

返回:当配置接口时

ansible_net_api

字符串

传输的名称

返回:始终返回

ansible_net_config

字符串

设备当前活动的配置

返回:当配置 config 时

ansible_net_cpu_utilization

字典

设备当前的 CPU 利用率

返回:当配置 hardware 时

ansible_net_filesystems

列表 / 元素=字符串

设备上可用的所有文件系统名称

返回:当配置 hardware 时

ansible_net_filesystems_info

字典

包含有关每个文件系统信息(例如可用空间和总空间)的所有文件系统的哈希表

返回:当配置 hardware 时

ansible_net_gather_network_resources

列表 / 元素=字符串

从设备收集的网络资源子集的事实列表

返回:当配置资源时

ansible_net_gather_subset

列表 / 元素=字符串

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

返回:始终返回

ansible_net_hostname

字符串

设备的配置主机名

返回:始终返回

ansible_net_image

字符串

设备正在运行的镜像文件

返回:始终返回

ansible_net_interfaces

字典

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

返回:当配置接口时

ansible_net_iostype

字符串

远程设备上运行的操作系统类型(IOS 或 IOS-XE)

返回:始终返回

ansible_net_memfree_mb

整数

远程设备上可用的空闲内存(MiB)

返回:当配置 hardware 时

ansible_net_memtotal_mb

整数

远程设备上的总内存(MiB)

返回:当配置 hardware 时

ansible_net_model

字符串

设备返回的型号名称

返回:始终返回

ansible_net_neighbors

字典

远程设备的CDP和LLDP邻居列表。如果一个端口上同时存在CDP和LLDP邻居数据,则优先使用CDP。

返回:当配置接口时

ansible_net_python_version

字符串

Ansible控制器使用的Python版本

返回:始终返回

ansible_net_serialnum

字符串

远程设备的序列号

返回:始终返回

ansible_net_stacked_models

列表 / 元素=字符串

堆栈中每个设备的型号名称

返回:当多个设备配置在堆栈中时

ansible_net_stacked_serialnums

列表 / 元素=字符串

堆栈中每个设备的序列号

返回:当多个设备配置在堆栈中时

ansible_net_version

字符串

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

返回:始终返回

作者

  • Peter Sprygada (@privateip)

  • Sumit Jaiswal (@justjais)