AnsiblePilot — Master Ansible Automation

AnsiblePilot is the leading resource for learning Ansible automation, DevOps, and infrastructure as code. Browse over 1,100 tutorials covering Ansible modules, playbooks, roles, collections, and real-world examples. Whether you are a beginner or an experienced engineer, our step-by-step guides help you automate Linux, Windows, cloud, containers, and network infrastructure.

Popular Topics

About Luca Berton

Luca Berton is an Ansible automation expert, author of "Ansible for VMware by Examples" and "Ansible for Kubernetes by Example" published by Apress, and creator of the Ansible Pilot YouTube channel. He shares practical automation knowledge through tutorials, books, and video courses to help IT professionals and DevOps engineers master infrastructure automation.

Take a VMware Virtual Machine Snapshot - Ansible module vmware_guest_snapshot

By Luca Berton · Published 2024-01-01 · Category: troubleshooting

How to automate taking snapshots named “Ansible Managed Snapshot” to a VMware Virtual Machine “myvm” Ansible Playbook and vmware_guest_snapshot module.

How to Take a VMware Virtual Machine Snapshot with Ansible? I'm going to show you a live Playbook and some simple Ansible code. I'm Luca Berton and welcome to today's episode of Ansible Pilot.

Ansible Take 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 • memory_dump boolean - no/yes - memory snapshots take time and resource

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, "present" to take a snapshot. You could also revert or remove a snapshot with the same Ansible module. If you want to remove a snapshot you could also remove all the dependent snapshots using the parameter remove_children. It's a good practice to set the name and description of the snapshot using thesnapshot_name and description parameters. Advanced practice is to create the memory dump of the virtual machines, please note that memory snapshots take time and resources will take a longer time to create. Default memory dump is disabled but you could enable using memory_dump parameter.

Linkscommunity.vmware.vmware_guest_snapshot

## Playbook

How to Take a VMware Virtual Machine Snapshot with Ansible. I'm going to show you how to take a snapshot of the Virtual Machine named "myvm" using Ansible Playbook setting a name and description to easily find in your VMware vCenter.

code • vm_snapshot_create.yml • vars.yml • inventory

execution

idempotency

before execution

!vmware_guest_snapshot before execution

after execution

!vmware_guest_snapshot after execution

code with ❤️ in GitHub

Conclusion Now you know how to create a VMware vSphere Virtual Machine with Ansible.

Related ArticlesAnsible Template GuideAnsible Become GuideAnsible Inventory Guide

Category: troubleshooting

Watch the video: Take a VMware Virtual Machine Snapshot - Ansible module vmware_guest_snapshot — Video Tutorial

Browse all Ansible tutorials · AnsiblePilot Home