community.vmware.vmware_datacenter_info 模块 – 收集关于 VMware vSphere 数据中心的信息

注意

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

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

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

要在剧本中使用它,请指定: community.vmware.vmware_datacenter_info

概要

  • 此模块可用于收集 VMware vSphere 数据中心的信息。

参数

参数

注释

datacenter

别名:datacenter_name

字符串

要收集信息的虚拟数据中心名称。

如果未提供,将从 VMware 基础架构收集所有虚拟数据中心的信息。

主机名

字符串

vSphere vCenter 或 ESXi 服务器的主机名或 IP 地址。

如果在任务中未指定该值,则将使用环境变量 VMWARE_HOST 的值。

password

别名:pass, pwd

字符串

vSphere vCenter 或 ESXi 服务器的密码。

如果在任务中未指定该值,则将使用环境变量 VMWARE_PASSWORD 的值。

端口

整数

vSphere vCenter 或 ESXi 服务器的端口号。

如果在任务中未指定该值,则将使用环境变量 VMWARE_PORT 的值。

默认值: 443

属性

列表 / 元素=字符串

指定要检索的属性。

如果未指定,则检索所有属性(深度检索)。

结果以与 vSphere API 相同的结构返回。

示例

properties: [

“overallStatus”

]

仅当 schema=vsphere 时有效。

代理主机

字符串

将接收所有 HTTPS 请求并转发它们的代理的地址。

格式为主机名或 IP。

如果在任务中未指定该值,则将使用环境变量 VMWARE_PROXY_HOST 的值。

代理端口

整数

将接收所有 HTTPS 请求并转发它们的 HTTP 代理的端口。

如果在任务中未指定该值,则将使用环境变量 VMWARE_PROXY_PORT 的值。

模式

字符串

指定所需的输出模式。

summary 输出模式是模块的旧版输出。

vsphere 输出模式是 vSphere API 类定义。

选项

  • "summary" ← (默认)

  • "vsphere"

显示标签

布尔值

如果设置为 true,则显示与数据中心相关的标签。

选项

  • false ← (默认)

  • true

用户名

别名:admin, user

字符串

vSphere vCenter 或 ESXi 服务器的用户名。

如果在任务中未指定该值,则将使用环境变量 VMWARE_USER 的值。

验证证书

布尔值

当 SSL 证书无效时允许连接。当证书不受信任时,设置为 false

如果在任务中未指定该值,则将使用环境变量 VMWARE_VALIDATE_CERTS 的值。

选项

  • false

  • true ← (默认)

注释

注意

  • 所有模块都需要 API 写入访问权限,因此在免费 ESXi 许可证上不支持。

  • 所有变量和 VMware 对象名称都区分大小写。

示例

- name: Gather information about all datacenters
  community.vmware.vmware_datacenter_info:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
  delegate_to: localhost

- name: Gather information about a particular datacenter
  community.vmware.vmware_datacenter_info:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    datacenter: '{{ datacenter_name }}'
  delegate_to: localhost

- name: Gather information about a particular datacenter
  community.vmware.vmware_datacenter_info:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    datacenter: '{{ datacenter_name }}'
    show_tag: true
  delegate_to: localhost

- name: Gather vSphere schema information
  community.vmware.vmware_datacenter_info:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    datacenter: '{{ datacenter_name }}'
    schema: vsphere
    properties:
    - configStatus
    - overallStatus

返回值

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

描述

datacenter_info

列表 / 元素=字符串

关于虚拟数据中心的信息

返回: 始终

示例: [{"configStatus": "gray", "moid": "datacenter-2", "name": "Asia-Datacenter1"}]

作者

  • Abhijeet Kasurde (@Akasurde)