vmware_guest_snapshot – Manages virtual machines snapshots in vCenter
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 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 string |
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. | |
memory_dump boolean added in 2.4 |
|
If set to 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 |
name - |
Name of the virtual machine to work with. This is required parameter, if | |
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 string |
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.
| |
port integer 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 Environment variable support added in Ansible 2.6. |
quiesce boolean added in 2.4 |
|
If set to 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 If virtual machine does not provide capability to take quiesce snapshot, then this flag is set to |
remove_children boolean added in 2.4 |
|
If set to |
snapshot_name - |
Sets the snapshot name to manage. This param is required only if state is not | |
state - / required |
|
Manage snapshot(s) attached to a specific virtual machine. If set to If set to If set to If set to If set to If set to If set to If set to |
use_instance_uuid boolean added in 2.8 |
|
Whether to use the VMWare instance UUID rather than the BIOS UUID. |
username string |
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 - |
UUID of the instance to manage if known, this is VMware's BIOS UUID by default. This is required if | |
validate_certs boolean |
|
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 |
Notes
Note
- Tested on vSphere 5.5, 6.0 and 6.5
Examples
- name: Create a snapshot
vmware_guest_snapshot:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
folder: "/{{ datacenter_name }}/vm/"
name: "{{ guest_name }}"
state: present
snapshot_name: snap1
description: snap1_description
delegate_to: localhost
- name: Remove a snapshot
vmware_guest_snapshot:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
folder: "/{{ datacenter_name }}/vm/"
name: "{{ guest_name }}"
state: absent
snapshot_name: snap1
delegate_to: localhost
- name: Revert to a snapshot
vmware_guest_snapshot:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
folder: "/{{ datacenter_name }}/vm/"
name: "{{ guest_name }}"
state: revert
snapshot_name: snap1
delegate_to: localhost
- name: Remove all snapshots of a VM
vmware_guest_snapshot:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
folder: "/{{ datacenter_name }}/vm/"
name: "{{ guest_name }}"
state: remove_all
delegate_to: localhost
- name: Take snapshot of a VM using quiesce and memory flag on
vmware_guest_snapshot:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
folder: "/{{ datacenter_name }}/vm/"
name: "{{ guest_name }}"
state: present
snapshot_name: dummy_vm_snap_0001
quiesce: yes
memory_dump: yes
delegate_to: localhost
- name: Remove a snapshot and snapshot subtree
vmware_guest_snapshot:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
folder: "/{{ datacenter_name }}/vm/"
name: "{{ guest_name }}"
state: absent
remove_children: yes
snapshot_name: snap1
delegate_to: localhost
- name: Rename a snapshot
vmware_guest_snapshot:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
folder: "/{{ datacenter_name }}/vm/"
name: "{{ guest_name }}"
state: present
snapshot_name: current_snap_name
new_snapshot_name: im_renamed
new_description: "{{ new_snapshot_description }}"
delegate_to: localhost
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key | Returned | Description |
---|---|---|
snapshot_results dictionary |
always |
metadata about the virtual machine snapshots
Sample: {'current_snapshot': {'creation_time': '2019-04-09T14:40:26.617427+00:00', 'description': 'Snapshot 4 example', 'id': 4, 'name': 'snapshot4', 'state': 'poweredOff'}, 'snapshots': [{'creation_time': '2019-04-09T14:38:24.667543+00:00', 'description': 'Snapshot 3 example', 'id': 3, 'name': 'snapshot3', 'state': 'poweredOff'}, {'creation_time': '2019-04-09T14:40:26.617427+00:00', 'description': 'Snapshot 4 example', 'id': 4, 'name': 'snapshot4', 'state': 'poweredOff'}]} |
Status
- This module is not guaranteed to have a backwards compatible interface. [preview]
- This module is maintained by the Ansible Community. [community]
Authors
- Loic Blot (@nerzhul) <[email protected]>
© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.8/modules/vmware_guest_snapshot_module.html