The vmware_guest_snapshot module

This module allows you to manage your VM snapshots; for example, the following creates a snapshot:

- name: Create a snapshot  vmware_guest_snapshot:    hostname: "{{ vsphere_host }}"    username: "{{ vsphere_username }}"    password: "{{ vsphere_password }}"    validate_certs: "no"    datacenter: "my-datacenter"    folder: "/vms"    name: "yet_another_example_vm"    snapshot_name: "pre-patching"    description: "snapshot made before patching"    state: "present"  delegate_to: localhost

As you can see from the previous example, this snapshot is being taken because we are about to patch the VM. If the patching goes as expected, then we can run the following task:

- name: Remove a snapshot  vmware_guest_snapshot: hostname: "{{ vsphere_host }}" ...

Get Learn Ansible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.