community.vmware.vmware_guest_snapshot – Manages virtual machines snapshots in vCenter¶
Note
This plugin is part of the community.vmware collection (version 1.7.0).
To install it use: ansible-galaxy collection install community.vmware
.
To use it in a playbook, specify: community.vmware.vmware_guest_snapshot
.
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¶
Examples¶
- name: Create a snapshot
community.vmware.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
community.vmware.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
community.vmware.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
community.vmware.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: Remove all snapshots of a VM using MoID
community.vmware.vmware_guest_snapshot:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
folder: "/{{ datacenter_name }}/vm/"
moid: vm-42
state: remove_all
delegate_to: localhost
- name: Take snapshot of a VM using quiesce and memory flag on
community.vmware.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: true
memory_dump: true
delegate_to: localhost
- name: Remove a snapshot and snapshot subtree
community.vmware.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: true
snapshot_name: snap1
delegate_to: localhost
- name: Rename a snapshot
community.vmware.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:
Authors¶
Loic Blot (@nerzhul) <loic.blot@unix-experience.fr>