community.vmware.vmware_all_snapshots_info module – Gathers information about all snapshots across virtual machines in a specified vmware datacenter

Note

This module is part of the community.vmware collection (version 5.2.0).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install community.vmware.

To use it in a playbook, specify: community.vmware.vmware_all_snapshots_info.

Synopsis

  • This module collects detailed information of all the snapshots of the datacenter, can be used with filter options

Parameters

Parameter

Comments

datacenter

string / required

The name of the datacenter to gather snapshot information from. You can get it in the vmware UI.

filters

dictionary

Optional filters to apply to the snapshot data being gathered, you can apply one or more.

Filters are applied based on the variable match_type specified. If match_type exact, filters require exact matches.

On the other hand when match_type includes it gets the values that contain that value.

Available filter options creation_time, description, folder, id, name, quiesced, state, vm_name.

Multiple filters can be applied the snapshot must meet all filter criteria to be included in the results.

Default: {}

hostname

string

The hostname or IP address of the vSphere vCenter or ESXi server.

If the value is not specified in the task, the value of environment variable VMWARE_HOST will be used instead.

match_type

string

Indicates whether the filter match should be exact or includes.

For example when you want to get all the snapshots that contain in their name the word test you place the filter name test and the match_type includes.

For example when you want to get all snapshots that are in state poweredOn you skip the match_type default is exact or you write match_type exact.

Choices:

  • "exact" ← (default)

  • "includes"

password

aliases: pass, pwd

string

The password of the vSphere vCenter or ESXi server.

If the value is not specified in the task, the value of environment variable VMWARE_PASSWORD will be used instead.

port

integer

The port number of the vSphere vCenter or ESXi server.

If the value is not specified in the task, the value of environment variable VMWARE_PORT will be used instead.

Default: 443

proxy_host

string

Address of a proxy that will receive all HTTPS requests and relay them.

The format is a hostname or a IP.

If the value is not specified in the task, the value of environment variable VMWARE_PROXY_HOST will be used instead.

proxy_port

integer

Port of the HTTP proxy that will receive all HTTPS requests and relay them.

If the value is not specified in the task, the value of environment variable VMWARE_PROXY_PORT will be used instead.

username

aliases: admin, user

string

The username of the vSphere vCenter or ESXi server.

If the value is not specified in the task, the value of environment variable VMWARE_USER will be used instead.

validate_certs

boolean

Allows connection when SSL certificates are not valid. Set to false when certificates are not trusted.

If the value is not specified in the task, the value of environment variable VMWARE_VALIDATE_CERTS will be used instead.

Choices:

  • false

  • true ← (default)

Notes

Note

  • All modules requires API write access and hence is not supported on a free ESXi license.

  • All variables and VMware object names are case sensitive.

Examples

- name: Gather information about all snapshots in VMware vCenter
  vmware_snapshot_info_all:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    validate_certs: no
    datacenter: '{{ datacenter_name }}'
  delegate_to: localhost
- name: Gather information of a snapshot with filters applied and match_type in exacts.
  vmware_snapshot_info_all:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    validate_certs: yes
    datacenter: '{{ datacenter_name }}'
    filters:
      state: "poweredOn"
      vm_name: "you_marchine_name"
  delegate_to: localhost
- name: Gather information of snapshots that in their name contain the "test" in their name.
  vmware_snapshot_info_all:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    validate_certs: yes
    datacenter: '{{ datacenter_name }}'
    match_type: "includes"
    filters:
      name: "test"
  delegate_to: localhost

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

vmware_all_snapshots_info

list / elements=dictionary

A list of all snapshots information across all virtual machines in the specified datacenter

Returned: always

creation_time

string

The time the snapshot was created

Returned: always

description

string

The description of the snapshot.

Returned: when it exists because depends if it has or not

folder

string

The folder path of the virtual machine in the datacenter, normally is vm

Returned: always

id

integer

The unique identifier of the snapshot

Returned: always

name

string

The name of the snapshot

Returned: always

quiesced

boolean

Indicates if the snapshot was created with the virtual machines file system quiesced

Returned: always

state

string

The state of the virtual machine at the snapshot (powered on/off)

Returned: always

vm_name

string

The name of the virtual machine that appears in the iu.

Returned: always

Authors

  • Fernando Mendieta (@valkiriaaquatica)