creating vmware snapshots playbook

Hello everyone,

I’m currently learning more about ansible and I gotta say I am enjoying it. Anyway, so I created a playbook to create snapshots for a single vm host using the UUID, but I am curious if anyone has created or if there’s a way to create multiple snapshots at one time? The only thing I can think of, only because I’m a noob, is to add each uuid into the playbook. I have it prompt for the username and password then takes a snapshot of the single vm host. Has anyone dealt with this? Here’s my playbook currently that works for a single host snapshot

#Prompts username and passowrd for Vsphere before proceeding to take a snapshot

  • hosts: Linux

vars_prompt:

  • name: “Username”

prompt: “Enter Your VMware Username”

private: no

  • name: “Password”

prompt: “Enter Your VMware Password”

#Taking VM snapshot#

tasks

  • name: VM Snapshot

vmware_guest_snapshot:

datacenter: “name of my datacenter”

hostname: “ip address”

username: “{{Username}}”

password: “{{Password}}”

name: globus0

uuid: 42035680-90c8-7033-8390-11aad4f83e13

state: present

snapshot_name: test1

description: patch_snapshot

validate_certs: false

delegate_to: localhost

Thanks,

Israel

You can refer to {{ ansible_product_uuid }} if you have facts for the hosts stored and loop through those.