vmware_guest_snapshot - Manages virtual machines snapshots in vCenter
New in version 2.3.
Synopsis
- This module can be used to create, delete and update snapshot(s) of the given virtual machine.
- All parameters and VMware object names are case sensitive.
Requirements
The below requirements are needed on the host that executes this module.
- python >= 2.6
- PyVmomi
Parameters
Parameter | Choices/Defaults | Comments |
---|---|---|
datacenter required | Destination datacenter for the deploy operation. | |
description | Default: "" | Define an arbitrary description to attach to snapshot. |
folder | Destination folder, absolute or relative path to find an existing guest. This is required parameter, if name is supplied.The folder should include the datacenter. ESX's datacenter is ha-datacenter. Examples: folder: /ha-datacenter/vm folder: ha-datacenter/vm folder: /datacenter1/vm folder: datacenter1/vm folder: /datacenter1/vm/folder1 folder: datacenter1/vm/folder1 folder: /folder1/datacenter1/vm folder: folder1/datacenter1/vm folder: /folder1/datacenter1/vm/folder2 folder: vm/folder2 folder: folder2 | |
hostname str | 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 VMWARE_HOST will be used instead.Environment variable support added in version 2.6. | |
memory_dump bool (added in 2.4) |
| If set to true , memory dump of virtual machine is also included in snapshot.Note that memory snapshots take time and resources, this will take longer time to create. If virtual machine does not provide capability to take memory snapshot, then this flag is set to false . |
name | Name of the virtual machine to work with. This is required parameter, if uuid is not supplied. | |
name_match |
| If multiple VMs matching the name, use the first or last found. |
new_description (added in 2.5) | Value to change the description of an existing snapshot to. | |
new_snapshot_name (added in 2.5) | Value to rename the existing snapshot to. | |
password str | The password of the vSphere vCenter or ESXi server. If the value is not specified in the task, the value of environment variable VMWARE_PASSWORD will be used instead.Environment variable support added in version 2.6. aliases: pass, pwd | |
port int (added in 2.5) | Default: 443 | The port number of the vSphere vCenter or ESXi server. If the value is not specified in the task, the value of environment variable VMWARE_PORT will be used instead.Environment variable support added in version 2.6. |
quiesce bool (added in 2.4) |
| If set to true and virtual machine is powered on, it will quiesce the file system in virtual machine.Note that VMWare Tools are required for this flag. If virtual machine is powered off or VMware Tools are not available, then this flag is set to false .If virtual machine does not provide capability to take quiesce snapshot, then this flag is set to false . |
remove_children bool (added in 2.4) |
| If set to true and state is set to absent , then entire snapshot subtree is set for removal. |
snapshot_name | Sets the snapshot name to manage. This param is required only if state is not remove_all
| |
state required |
| Manage snapshot(s) attached to a specific virtual machine. If set to present and snapshot absent, then will create a new snapshot with the given name.If set to present and snapshot present, then no changes are made.If set to absent and snapshot present, then snapshot with the given name is removed.If set to absent and snapshot absent, then no changes are made.If set to revert and snapshot present, then virtual machine state is reverted to the given snapshot.If set to revert and snapshot absent, then no changes are made.If set to remove_all and snapshot(s) present, then all snapshot(s) will be removed.If set to remove_all and snapshot(s) absent, then no changes are made. |
username str | The username of the vSphere vCenter or ESXi server. If the value is not specified in the task, the value of environment variable VMWARE_USER will be used instead.Environment variable support added in version 2.6. aliases: admin, user | |
uuid | UUID of the instance to manage if known, this is VMware's unique identifier. This is required parameter, if name is not supplied. | |
validate_certs bool |
| Allows connection when SSL certificates are not valid. Set to false when certificates are not trusted.If the value is not specified in the task, the value of environment variable VMWARE_VALIDATE_CERTS will be used instead.Environment variable support added in version 2.6. If set to yes , please make sure Python >= 2.7.9 is installed on the given machine. |
Notes
Note
- Tested on vSphere 5.5, 6.0 and 6.5
Examples
- name: Create a snapshot vmware_guest_snapshot: hostname: 192.168.1.209 username: [email protected] password: vmware datacenter: datacenter_name folder: /myfolder name: dummy_vm state: present snapshot_name: snap1 description: snap1_description delegate_to: localhost - name: Remove a snapshot vmware_guest_snapshot: hostname: 192.168.1.209 username: [email protected] password: vmware name: dummy_vm datacenter: datacenter_name folder: /myfolder state: absent snapshot_name: snap1 delegate_to: localhost - name: Revert to a snapshot vmware_guest_snapshot: hostname: 192.168.1.209 username: [email protected] password: vmware datacenter: datacenter_name folder: /myfolder name: dummy_vm state: revert snapshot_name: snap1 delegate_to: localhost - name: Remove all snapshots of a VM vmware_guest_snapshot: hostname: 192.168.1.209 username: [email protected] password: vmware datacenter: datacenter_name folder: /myfolder name: dummy_vm state: remove_all delegate_to: localhost - name: Take snapshot of a VM using quiesce and memory flag on vmware_guest_snapshot: hostname: 192.168.1.209 username: [email protected] password: vmware name: dummy_vm state: present snapshot_name: dummy_vm_snap_0001 quiesce: True memory_dump: True delegate_to: localhost - name: Remove a snapshot and snapshot subtree vmware_guest_snapshot: hostname: 192.168.1.209 username: [email protected] password: vmware name: dummy_vm state: absent remove_children: True snapshot_name: snap1 delegate_to: localhost - name: Rename a snapshot vmware_guest_snapshot: hostname: 192.168.1.209 username: [email protected] password: vmware name: dummy_vm state: present snapshot_name: current_snap_name new_snapshot_name: im_renamed new_description: "renamed snapshot today" delegate_to: localhost
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key | Returned | Description |
---|---|---|
instance dict | always | metadata about the new virtual machine snapshot Sample: None |
Status
This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.
Maintenance
This module is flagged as community which means that it is maintained by the Ansible Community. See Module Maintenance & Support for more info.
For a list of other modules that are also maintained by the Ansible Community, see here.
Author
- Loic Blot (@nerzhul) <loic.blot@unix-experience.fr>
Hint
If you notice any issues in this documentation you can edit this document to improve it.
© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.6/modules/vmware_guest_snapshot_module.html