community.vmware.vmware_guest_cross_vc_clone module – Cross-vCenter VM/template clone
Note
This module is part of the community.vmware collection (version 1.18.2).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install community.vmware
.
To use it in a playbook, specify: community.vmware.vmware_guest_cross_vc_clone
.
Parameters
Parameter |
Comments |
---|---|
The name of the destination datastore or the datastore cluster. If datastore cluster name is specified, we will find the Storage DRS recommended datastore in that cluster. |
|
The name of the destination host. |
|
Destination resource pool. If not provided, the destination host’s parent’s resource pool will be used. |
|
The hostname or IP address of the destination VCenter. |
|
The password of the destination VCenter. |
|
The port to establish connection in the destination VCenter. Default: 443 |
|
The username of the destination VCenter. |
|
Parameter to indicate if certification validation needs to be done on destination VCenter. Choices:
|
|
Destination folder, absolute path to deploy the cloned vm. This parameter is case sensitive. Examples:
|
|
The name of the cloned VM. |
|
The hostname or IP address of the vSphere vCenter or ESXi server. If the value is not specified in the task, the value of environment variable Environment variable support added in Ansible 2.6. |
|
Specifies whether or not the new virtual machine should be marked as a template. Choices:
|
|
Managed Object ID of the vm/template instance to manage if known, this is a unique identifier only within a single vCenter instance. This is required if |
|
Name of the virtual machine or template. This is a required parameter, if parameter |
|
The password of the vSphere vCenter or ESXi server. If the value is not specified in the task, the value of environment variable Environment variable support added in Ansible 2.6. |
|
The port number of the vSphere vCenter or ESXi server. If the value is not specified in the task, the value of environment variable Environment variable support added in Ansible 2.6. Default: 443 |
|
Address of a proxy that will receive all HTTPS requests and relay them. The format is a hostname or a IP. If the value is not specified in the task, the value of environment variable This feature depends on a version of pyvmomi greater than v6.7.1.2018.12 |
|
Port of the HTTP proxy that will receive all HTTPS requests and relay them. If the value is not specified in the task, the value of environment variable |
|
The state of Virtual Machine deployed. If set to If set to If set to If set to Choices:
|
|
Whether to use the VMware instance UUID rather than the BIOS UUID. Choices:
|
|
The username of the vSphere vCenter or ESXi server. If the value is not specified in the task, the value of environment variable Environment variable support added in Ansible 2.6. |
|
UUID of the vm/template instance to clone from, this is VMware’s unique identifier. This is a required parameter, if parameter |
|
Allows connection when SSL certificates are not valid. Set to If the value is not specified in the task, the value of environment variable Environment variable support added in Ansible 2.6. If set to Choices:
|
Notes
Note
All modules requires API write access and hence is not supported on a free ESXi license.
Examples
# 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
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
metadata about the virtual machine Returned: always Sample: {“datastore”: “”, “host”: “”, “power_on”: “”, “vcenter”: “”, “vm_folder”: “”, “vm_name”: “”} |
Authors
Anusha Hegde (@anusha94)