Vmware.Collection: vmware_guest_snapshot setting expiration

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.

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.    

My 2 cents…

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

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.

Just a example but there is a lot out there: 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

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

Thank you for sharing!