Delete a VMware Virtual Machine Snapshot — Ansible module vmware_guest_snapshot

How to automate the delete of snapshot named “Ansible Managed Snapshot” in a VMware Virtual Machine “myvm” Ansible Playbook and vmware_guest_snapshot module.

Ansible Pilot
5 min readMay 18, 2022

--

How to Delete a VMware Virtual Machine Snapshot with Ansible?

I’m going to show you a live demo and some simple Ansible code.

I’m Luca Berton and welcome to today’s episode of Ansible Pilot.

Ansible Delete a VMware Virtual Machine Snapshot

  • `community.vmware.vmware_guest_snapshot`
  • Manages virtual machines snapshots in vCenter

Let’s talk about the Ansible module `vmware_guest_snapshot`.

The full name is `community.vmware.vmware_guest_snapshot`, which means that is part of the collection of modules to interact with VMware, community-supported.

It manages virtual machine snapshots in vCenter.

Parameters

  • hostname string / username string / password string / datacenter string / validate_certs boolean — connection details
  • state string — present / absent / revert / remove_all
  • remove_children boolean — no/yes
  • snapshot_name string description string — Name/description of the virtual machine to work with

The following parameters are useful in order to Take a VMware Virtual Machine Snapshot using the module `vmware_guest_snapshot`.

First of all, we need to establish the connection with VMware vSphere or VMware vCenter using a plethora of self-explicative parameters: `hostname`, `username`, `password`, `datacenter`, and `validate_certs`.

Once the connection is successfully established you could specify the desired snapshot state, in this case, “absent” to delete a snapshot. You could also manage a snapshot with the same Ansible module.

--

--

Ansible Pilot

I help creative Automation DevOps, Cloud Engineer, System Administrator, and IT Professional to succeed with Ansible Technology to automate more things everyday