community.vmware.vmware_guest_custom_attribute_defs 模块 – 从 VMware 管理虚拟机的自定义属性定义
注意
此模块是 community.vmware 集合 (版本 5.2.0) 的一部分。
如果您使用的是 ansible 包,则可能已安装此集合。它不包含在 ansible-core 中。要检查是否已安装它,请运行 ansible-galaxy collection list。
要安装它,请使用: ansible-galaxy collection install community.vmware。
要在 playbook 中使用它,请指定: community.vmware.vmware_guest_custom_attribute_defs。
概要
- 此模块可用于为给定的 VMware 虚拟机添加和删除自定义属性定义。 
参数
| 参数 | 注释 | 
|---|---|
| 自定义属性定义的名称。 这是必需参数,如果  | |
| vSphere vCenter 或 ESXi 服务器的主机名或 IP 地址。 如果任务中未指定该值,则将使用环境变量  | |
| vSphere vCenter 或 ESXi 服务器的密码。 如果任务中未指定该值,则将使用环境变量  | |
| 将接收所有 HTTPS 请求并转发它们的 HTTP 代理的端口。 如果任务中未指定该值,则将使用环境变量  | |
| 管理自定义属性的定义。 如果设置为  如果设置为  如果设置为  如果设置为  选项 
 | |
| vSphere vCenter 或 ESXi 服务器的用户名。 如果任务中未指定该值,则将使用环境变量  | |
备注
注意
- 所有模块都需要API写访问权限,因此在免费ESXi许可证上不支持。 
- 所有变量和VMware对象名称都区分大小写。 
示例
- name: Add VMware Attribute Definition
  community.vmware.vmware_guest_custom_attribute_defs:
    hostname: "{{ vcenter_hostname }}"
    username: "{{ vcenter_username }}"
    password: "{{ vcenter_password }}"
    state: present
    attribute_key: custom_attr_def_1
  delegate_to: localhost
  register: defs
- name: Remove VMware Attribute Definition
  community.vmware.vmware_guest_custom_attribute_defs:
    hostname: "{{ vcenter_hostname }}"
    username: "{{ vcenter_username }}"
    password: "{{ vcenter_password }}"
    state: absent
    attribute_key: custom_attr_def_1
  delegate_to: localhost
  register: defs
返回值
常见的返回值已在此处记录,以下是此模块特有的字段
| 键 | 描述 | 
|---|---|
| 所有当前属性定义的列表 返回:始终 示例:  | 
