community.general.proxmox_snap (8.5.0) — module

Snapshot management of instances in Proxmox VE cluster

| "added in version" 2.0.0 of community.general"

Authors: Jeffrey van Pelt (@Thulium-Drake)

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

Allows you to create/delete/restore snapshots from instances in Proxmox VE cluster.

Supports both KVM and LXC, OpenVZ has not been tested, as it is no longer supported on Proxmox VE.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create new container snapshot
  community.general.proxmox_snap:
    api_user: root@pam
    api_password: 1q2w3e
    api_host: node1
    vmid: 100
    state: present
    snapname: pre-updates
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create new container snapshot and keep only the 2 newest snapshots
  community.general.proxmox_snap:
    api_user: root@pam
    api_password: 1q2w3e
    api_host: node1
    vmid: 100
    state: present
    snapname: snapshot-42
    retention: 2
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create new snapshot for a container with configured mountpoints
  community.general.proxmox_snap:
    api_user: root@pam
    api_password: 1q2w3e
    api_host: node1
    vmid: 100
    state: present
    unbind: true # requires root@pam+password auth, API tokens are not supported
    snapname: pre-updates
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Remove container snapshot
  community.general.proxmox_snap:
    api_user: root@pam
    api_password: 1q2w3e
    api_host: node1
    vmid: 100
    state: absent
    snapname: pre-updates
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Rollback container snapshot
  community.general.proxmox_snap:
    api_user: root@pam
    api_password: 1q2w3e
    api_host: node1
    vmid: 100
    state: rollback
    snapname: pre-updates

Inputs

    
vmid:
    description:
    - The instance id.
    - If not set, will be fetched from PromoxAPI based on the hostname.
    type: str

force:
    default: false
    description:
    - For removal from config file, even if removing disk snapshot fails.
    type: bool

state:
    choices:
    - present
    - absent
    - rollback
    default: present
    description:
    - Indicate desired state of the instance snapshot.
    - The V(rollback) value was added in community.general 4.8.0.
    type: str

unbind:
    default: false
    description:
    - This option only applies to LXC containers.
    - Allows to snapshot a container even if it has configured mountpoints.
    - Temporarily disables all configured mountpoints, takes snapshot, and finally restores
      original configuration.
    - If running, the container will be stopped and restarted to apply config changes.
    - Due to restrictions in the Proxmox API this option can only be used authenticating
      as V(root@pam) with O(api_password), API tokens do not work either.
    - See U(https://pve.proxmox.com/pve-docs/api-viewer/#/nodes/{node}/lxc/{vmid}/config)
      (PUT tab) for more details.
    type: bool
    version_added: 5.7.0
    version_added_collection: community.general

timeout:
    default: 30
    description:
    - Timeout for operations.
    type: int

vmstate:
    default: false
    description:
    - Snapshot includes RAM.
    type: bool

api_host:
    description:
    - Specify the target host of the Proxmox VE cluster.
    required: true
    type: str

api_user:
    description:
    - Specify the user to authenticate with.
    required: true
    type: str

hostname:
    description:
    - The instance name.
    type: str

snapname:
    default: ansible_snap
    description:
    - Name of the snapshot that has to be created/deleted/restored.
    type: str

retention:
    default: 0
    description:
    - Remove old snapshots if there are more than O(retention) snapshots.
    - If O(retention) is set to V(0), all snapshots will be kept.
    - This is only used when O(state=present) and when an actual snapshot is created.
      If no snapshot is created, all existing snapshots will be kept.
    type: int
    version_added: 7.1.0
    version_added_collection: community.general

description:
    description:
    - Specify the description for the snapshot. Only used on the configuration web interface.
    - This is saved as a comment inside the configuration file.
    type: str

api_password:
    description:
    - Specify the password to authenticate with.
    - You can use E(PROXMOX_PASSWORD) environment variable.
    type: str

api_token_id:
    description:
    - Specify the token ID.
    - Requires C(proxmoxer>=1.1.0) to work.
    type: str
    version_added: 1.3.0
    version_added_collection: community.general

validate_certs:
    default: false
    description:
    - If V(false), SSL certificates will not be validated.
    - This should only be used on personally controlled sites using self-signed certificates.
    type: bool

api_token_secret:
    description:
    - Specify the token secret.
    - Requires C(proxmoxer>=1.1.0) to work.
    type: str
    version_added: 1.3.0
    version_added_collection: community.general