# Vmware.Collection: vmware\_guest\_snapshot setting expiration

**URL:** <https://forum.ansible.com/t/vmware-collection-vmware-guest-snapshot-setting-expiration/37757>\
**Category:** Ansible Project\
**Tags:** vmware\
**Created:** [March 12, 2023, 10:00pm UTC](https://forum.ansible.com/t/vmware-collection-vmware-guest-snapshot-setting-expiration/37757 "2023-03-12T22:00:26Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kyle\_jones](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kyle_jones/32/2553_2.png) [@kyle\_jones](https://forum.ansible.com/u/kyle_jones)\
**Post date:** [March 12, 2023, 10:00pm UTC](https://forum.ansible.com/t/vmware-collection-vmware-guest-snapshot-setting-expiration/37757/1 "2023-03-12T22:00:26Z")

</div>

Hello,

Does anyone have any documentation or know what parameters to use when using vmware\_guest\_snapshot to take snapshot, but adding an expiration period?

I looked over the ansible docs a few times and I did not see it.

---

<div class="post-metadata">

**Author:** ![Endure\_Kona](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/endure_kona/32/391_2.png) [@Endure\_Kona](https://forum.ansible.com/u/Endure_Kona)\
**Post date:** [March 12, 2023, 10:38pm UTC](https://forum.ansible.com/t/vmware-collection-vmware-guest-snapshot-setting-expiration/37757/2 "2023-03-12T22:38:45Z")

</div>

```auto
Hey Kyle – I have done a bit of ansible playbooks for the VI environment I work in…I had found that ansible is someone limit with the VI module. I have accomplished everything with PowerCLI with ansible.windows.win_shell module. I run it all from the Ansible server by installing Powershell on the RHEL ansible server. This setup allows us to run deeper/more complicated plays.    

```

```auto

```

```auto
My 2 cents…

```

---

<div class="post-metadata">

**Author:** ![kyle\_jones](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kyle_jones/32/2553_2.png) [@kyle\_jones](https://forum.ansible.com/u/kyle_jones)\
**Post date:** [March 13, 2023, 2:13am UTC](https://forum.ansible.com/t/vmware-collection-vmware-guest-snapshot-setting-expiration/37757/3 "2023-03-13T02:13:49Z")

</div>

Ah! Okay then it’s not just me. Mind pointing out some documentation on the powershell script?

---

<div class="post-metadata">

**Author:** ![Stefan\_Coussens](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/stefan_coussens/32/8432_2.png) [@Stefan\_Coussens](https://forum.ansible.com/u/Stefan_Coussens)\
**Post date:** [March 13, 2023, 1:05pm UTC](https://forum.ansible.com/t/vmware-collection-vmware-guest-snapshot-setting-expiration/37757/4 "2023-03-13T13:05:51Z")

</div>

I don’t know if you use tower but what I do is take a snapshot named “snapshot by ansible” and for the removal I use the absent parameter (state: absent) and schedule the playbook to run at a certain time.

---

<div class="post-metadata">

**Author:** ![Endure\_Kona](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/endure_kona/32/391_2.png) [@Endure\_Kona](https://forum.ansible.com/u/Endure_Kona)\
**Post date:** [March 14, 2023, 2:55pm UTC](https://forum.ansible.com/t/vmware-collection-vmware-guest-snapshot-setting-expiration/37757/5 "2023-03-14T14:55:03Z")

</div>

Just a example but there is a lot out there: [https://petri.com/use-powercli-create-snapshot/](https://petri.com/use-powercli-create-snapshot/)

Examples of the plays that I run:

- name: Check the servers in the cluster to ensure none are offline

ansible.builtin.shell: |

Connect-VIServer -Server “{{ inventory\_hostname }}” -User “{{ Admin\_Acct }}” -Password “{{ Admin\_Pass }}” | Out-Null

$NotRespondingHost = (Get-Cluster | Get-VMHost | ? { $\_.ConnectionState -match “NotResponding”}).Name

ForEach ($NotRespondingHost in $NotRespondingHosts) {

$pos = $NotRespondingHost.IndexOf(“.”)

$ESXi\_name = $NotRespondingHost.Substring(0, $pos)

$domain\_name = $NotRespondingHost.Substring($pos+1)

$ESXi\_name + “.\_ilo.” + $domain\_name

}

args:

executable: /usr/bin/pwsh

register: NotRespondingHostILO\_Pre

delegate\_to: localhost

---

<div class="post-metadata">

**Author:** ![kyle\_jones](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kyle_jones/32/2553_2.png) [@kyle\_jones](https://forum.ansible.com/u/kyle_jones)\
**Post date:** [March 20, 2023, 6:48pm UTC](https://forum.ansible.com/t/vmware-collection-vmware-guest-snapshot-setting-expiration/37757/6 "2023-03-20T18:48:32Z")

</div>

We don’t have tower but I am planning on building AWX. We only have satellite and it is very limited.

---

<div class="post-metadata">

**Author:** ![kyle\_jones](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kyle_jones/32/2553_2.png) [@kyle\_jones](https://forum.ansible.com/u/kyle_jones)\
**Post date:** [March 20, 2023, 6:49pm UTC](https://forum.ansible.com/t/vmware-collection-vmware-guest-snapshot-setting-expiration/37757/7 "2023-03-20T18:49:12Z")

</div>

Thank you for sharing!
