community.vmware.vmware_guest_instant_clone module – Instant Clone VM
Note
This module is part of the community.vmware collection (version 3.11.1).
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_instant_clone
.
Synopsis
This module can be used for Creating a powered-on Instant Clone of a virtual machine.
All variables and VMware object names are case sensitive.
community.vmware.vmware_guest module is needed for creating a VM with poweredon state which would be used as a parent VM.
community.vmware.vmware_guest_powerstate module is also needed to poweroff the instant cloned module.
The powered off VM would in turn be deleted by again using community.vmware.vmware_guest module.
Thus community.vmware.vmware_guest module is necessary for removing Instant Cloned VM when VMs being created in testing environment.
Also GuestOS Customization has now been added with guestinfo_vars parameter.
The Parent VM must have The Guest customization Engine for instant Clone to customize Guest OS.
Only Linux Os in Parent VM enable support for native vSphere Guest Customization for Instant Clone in vSphere 7.
Parameters
Parameter |
Comments |
---|---|
Name of the datacenter, where VM to be deployed. |
|
The name of the datastore or the datastore cluster. If datastore cluster name is specified, module will find the Storage DRS recommended datastore in that cluster. |
|
Destination folder, absolute path to deploy the cloned vm. This parameter is case sensitive. Examples: folder: ha-datacenter/vm folder: /datacenter1/vm |
|
Provides GuestOS Customization functionality in instant cloned VM. A list of key value pairs that will be passed to the destination VM. These pairs should be used to provide user-defined customization to differentiate the destination VM from the source VM. |
|
dns is used to set the dns in Instant Cloned Guest Operating System.. |
|
domain is used to set A fully qualified domain name (FQDN) or complete domain name for Instant Cloned Guest operating System. |
|
netmask is used to set the netmask in Instant Cloned Guest Operating System. |
|
hostname is used to obtain the DNS(Domain Name System) name and set the Guest system’s hostname. |
|
ipaddress is used to set the ipaddress in Instant Cloned Guest Operating System. |
|
netmask is used to set the netmask in Instant Cloned Guest Operating System. |
|
Name of the ESX Host in datacenter in which to place cloned VM. The host has to be a member of the cluster that contains the resource pool. Required with resource_pool to find resource pool details. This will be used as additional information when there are resource pools with same name. |
|
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. |
|
Managed Object ID of the vm instance to manage if known, this is a unique identifier only within a single vCenter instance. This is required if |
|
Name of the Cloned virtual machine. |
|
Name of the parent virtual machine. 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: |
|
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 |
|
Name of the resource pool in datacenter in which to place deployed VM. Required if cluster is not specified. For default or non-unique resource pool names, specify host and cluster.
|
|
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 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:
|
|
The password used to login-in to the virtual machine. Only required when using guest customization feature. |
|
The user to login-in to the virtual machine. Only required when using guest customization feature. |
|
Whether waiting until vm tools start after rebooting an instant clone vm. Choices:
|
|
Define a timeout (in seconds) for the wait_vm_tools parameter. Default: |
Notes
Note
All modules requires API write access and hence is not supported on a free ESXi license.
Examples
- name: Instant Clone a VM
community.vmware.vmware_guest_instant_clone:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
validate_certs: false
folder: "{{ f0 }}"
datastore: "{{ rw_datastore }}"
datacenter: "{{ dc1 }}"
host: "{{ esxi1 }}"
name: "{{ Clone_vm }}"
parent_vm: "{{ testvm_1 }}"
resource_pool: "{{ test_resource_001 }}"
register: vm_clone
delegate_to: localhost
- name: set state to poweroff the Cloned VM
community.vmware.vmware_guest_powerstate:
validate_certs: false
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: "cloned_vm_from_vm_cluster"
folder: "{{ f0 }}"
state: powered-off
register: poweroff_instant_clone_from_vm_when_cluster
delegate_to: localhost
- name: Clean VM
community.vmware.vmware_guest:
validate_certs: false
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: "cloned_vm_from_vm_cluster"
datacenter: "{{ dc1 }}"
state: absent
register: delete_instant_clone_from_vm_when_cluster
ignore_errors: true
delegate_to: localhost
- name: Instant Clone a VM with guest_customization
community.vmware.vmware_guest_instant_clone:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
vm_username: "root"
vm_password: "SuperSecret"
validate_certs: false
folder: "{{ f0 }}"
datastore: "{{ rw_datastore }}"
datacenter: "{{ dc1 }}"
host: "{{ esxi1 }}"
guestinfo_vars:
- hostname: "{{ guestinfo.ic.hostname }}"
ipaddress: "{{ guestinfo.ic.ipaddress }}"
netmask: "{{ guestinfo.ic.netmask }}"
gateway: "{{ guestinfo.ic.gateway }}"
dns: "{{ guestinfo.ic.dns }}"
domain: "{{ guestinfo.ic.domain }}"
name: "Instant_clone_guest_customize"
parent_vm: "test_vm1"
resource_pool: DC0_C0_RP1
register: Instant_cloned_guest_customize
delegate_to: localhost
- name: Instant Clone a VM when skipping optional params
community.vmware.vmware_guest_instant_clone:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
validate_certs: false
name: "{{ Clone_vm }}"
parent_vm: "{{ testvm_1 }}"
datacenter: "{{ dc1 }}"
datastore: "{{ rw_datastore }}"
host: "{{ esxi1 }}"
register: VM_clone_optional_arguments
delegate_to: localhost
- name: Instant clone in check mode
community.vmware.vmware_guest_instant_clone:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
validate_certs: false
folder: "{{ f0 }}"
datastore: "{{ rw_datastore }}"
datacenter: "{{ dc1 }}"
host: "{{ esx1 }}"
name: "{{ Clone_vm }}"
parent_vm: "{{ testvm_2 }}"
resource_pool: "{{ test_resource_001 }}"
check_mode: true
register: check_mode_clone
delegate_to: localhost
- debug:
var: check_mode_clone
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
metadata about the virtual machine added instance_uuid from version 1.12.0 Returned: always Sample: |