community.vmware.vmware_guest_custom_attributes 模块 – 管理指定虚拟机的 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_attributes
。
概要
此模块可用于添加、删除和更新给定虚拟机的自定义属性。
参数
参数 |
注释 |
---|---|
属性的名称。 |
|
属性的值。 默认: |
|
虚拟机所在的数据中心名称。 |
|
查找现有虚拟机的绝对路径。 如果提供了 |
|
vSphere vCenter 或 ESXi 服务器的主机名或 IP 地址。 如果未在任务中指定该值,则将使用环境变量 |
|
vSphere vCenter 或 ESXi 服务器的密码。 如果未在任务中指定该值,则将使用环境变量 |
|
将接收所有 HTTPS 请求并转发它们的 HTTP 代理的端口。 如果未在任务中指定该值,则将使用环境变量 |
|
要执行的操作。 如果设置为 如果设置为 选项
|
|
是否使用 VMware 实例 UUID 而不是 BIOS UUID。 选项
|
|
vSphere vCenter 或 ESXi 服务器的用户名。 如果任务中未指定该值,则将使用环境变量 |
|
允许在 SSL 证书无效时进行连接。当证书不受信任时,设置为 如果任务中未指定该值,则将使用环境变量 选项
|
备注
注意
所有模块都需要 API 写入访问权限,因此在免费的 ESXi 许可证上不受支持。
所有变量和 VMware 对象名称都区分大小写。
示例
- name: Add virtual machine custom attributes
community.vmware.vmware_guest_custom_attributes:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
uuid: 421e4592-c069-924d-ce20-7e7533fab926
state: present
attributes:
- name: MyAttribute
value: MyValue
delegate_to: localhost
register: attributes
- name: Add multiple virtual machine custom attributes
community.vmware.vmware_guest_custom_attributes:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
uuid: 421e4592-c069-924d-ce20-7e7533fab926
state: present
attributes:
- name: MyAttribute
value: MyValue
- name: MyAttribute2
value: MyValue2
delegate_to: localhost
register: attributes
- name: Remove virtual machine Attribute
community.vmware.vmware_guest_custom_attributes:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
uuid: 421e4592-c069-924d-ce20-7e7533fab926
state: absent
attributes:
- name: MyAttribute
delegate_to: localhost
register: attributes
- name: Remove virtual machine Attribute using Virtual Machine MoID
community.vmware.vmware_guest_custom_attributes:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
moid: vm-42
state: absent
attributes:
- name: MyAttribute
delegate_to: localhost
register: attributes
返回值
通用返回值记录在此处,以下是此模块特有的字段
键 |
描述 |
---|---|
关于虚拟机属性的元数据 返回: 总是 示例: |