community.vmware.vmware_guest_cross_vc_clone 模块 – 跨 vCenter VM/模板克隆
注意
此模块是 community.vmware 集合(版本 5.2.0)的一部分。
如果您正在使用 ansible
包,您可能已经安装了此集合。它不包含在 ansible-core
中。要检查是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用: ansible-galaxy collection install community.vmware
。
要在 playbook 中使用它,请指定: community.vmware.vmware_guest_cross_vc_clone
。
概要
此模块可用于跨 vCenter vm/模板克隆
参数
参数 |
注释 |
---|---|
目标数据存储或数据存储集群的名称。 如果指定了数据存储集群名称,我们将在该集群中找到 Storage DRS 推荐的数据存储。 |
|
目标主机的名称。 |
|
目标资源池。 如果未提供,将使用目标主机的父级的资源池。 |
|
目标 VCenter 的主机名或 IP 地址。 |
|
目标 VCenter 的密码。 |
|
在目标 VCenter 中建立连接的端口。 默认值: |
|
目标 VCenter 的用户名。 |
|
指示是否需要在目标 VCenter 上进行证书验证的参数。 选项
|
|
目标文件夹,部署克隆虚拟机的绝对路径。 示例 folder: vm folder: ha-datacenter/vm folder: /datacenter1/vm |
|
克隆虚拟机的名称。 |
|
vSphere vCenter 或 ESXi 服务器的主机名或 IP 地址。 如果任务中未指定该值,则将使用环境变量 |
|
指定是否应将新的虚拟机标记为模板。 选项
|
|
vSphere vCenter 或 ESXi 服务器的密码。 如果任务中未指定该值,则将使用环境变量 |
|
将接收所有 HTTPS 请求并转发它们的 HTTP 代理的端口。 如果任务中未指定该值,则将使用环境变量 |
|
已部署的虚拟机的状态。 如果设置为 如果设置为 如果设置为 如果设置为 选项
|
|
以秒为单位的超时时间。当达到超时时间时,模块将失败。 默认值: |
|
是否使用 VMware 实例 UUID 而不是 BIOS UUID。 选项
|
|
vSphere vCenter 或 ESXi 服务器的用户名。 如果任务中未指定该值,则将使用环境变量 |
|
允许在 SSL 证书无效时进行连接。当证书不受信任时,设置为 如果任务中未指定该值,则将使用环境变量 选项
|
备注
注意
所有模块都需要 API 写入权限,因此免费 ESXi 许可证不支持。
所有变量和 VMware 对象名称都区分大小写。
示例
# Clone template
- name: clone a template across VC
community.vmware.vmware_guest_cross_vc_clone:
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
name: "test_vm1"
destination_vm_name: "cloned_vm_from_template"
destination_vcenter: '{{ destination_vcenter_hostname }}'
destination_vcenter_username: '{{ destination_vcenter_username }}'
destination_vcenter_password: '{{ destination_vcenter_password }}'
destination_vcenter_port: '{{ destination_vcenter_port }}'
destination_vcenter_validate_certs: '{{ destination_vcenter_validate_certs }}'
destination_host: '{{ destination_esxi }}'
destination_datastore: '{{ destination_datastore }}'
destination_vm_folder: '{{ destination_vm_folder }}'
state: present
register: cross_vc_clone_from_template
- name: clone a VM across VC
community.vmware.vmware_guest_cross_vc_clone:
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: "{{ vcenter_password }}"
name: "test_vm1"
destination_vm_name: "cloned_vm_from_vm"
destination_vcenter: '{{ destination_vcenter_hostname }}'
destination_vcenter_username: '{{ destination_vcenter_username }}'
destination_vcenter_password: '{{ destination_vcenter_password }}'
destination_host: '{{ destination_esxi }}'
destination_datastore: '{{ destination_datastore }}'
destination_vm_folder: '{{ destination_vm_folder }}'
state: poweredon
register: cross_vc_clone_from_vm
- name: check_mode support
community.vmware.vmware_guest_cross_vc_clone:
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: "{{ vcenter_password }}"
name: "test_vm1"
destination_vm_name: "cloned_vm_from_vm"
destination_vcenter: '{{ destination_vcenter_hostname }}'
destination_vcenter_username: '{{ destination_vcenter_username }}'
destination_vcenter_password: '{{ destination_vcenter_password }}'
destination_host: '{{ destination_esxi }}'
destination_datastore: '{{ destination_datastore }}'
destination_vm_folder: '{{ destination_vm_folder }}'
check_mode: true
返回值
通用返回值在此处 记录,以下是此模块独有的字段
键 |
描述 |
---|---|
关于虚拟机的元数据 返回: 总是 示例: |