community.vmware.vmware_guest_instant_clone – Instant Clone VM¶
Note
This plugin is part of the community.vmware collection (version 1.9.0).
To install it use: ansible-galaxy collection install community.vmware
.
To use it in a playbook, specify: community.vmware.vmware_guest_instant_clone
.
New in version 1.9.0: of community.vmware
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.
Parameters¶
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 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 | Returned | Description |
---|---|---|
vm_info
dictionary
|
always |
metadata about the virtual machine
Sample:
{'datastore': '', 'host': '', 'vcenter': '', 'vm_folder': '', 'vm_name': ''}
|
Authors¶
Anant Chopra (@Anant99-sys)