This role automates the creation and management of Proxmox container snapshots.
Find a file
2025-10-17 16:21:24 +02:00
defaults fix venv path 2025-10-03 17:00:34 +02:00
meta add namespace 2025-06-21 11:19:58 +02:00
tasks fix linting warnings 2025-10-17 16:21:24 +02:00
vars.example Standardize YAML file formatting 2025-06-06 16:24:43 +02:00
.gitignore add namespace 2025-06-21 11:19:58 +02:00
LICENSE Initial commit 2025-06-02 21:41:33 +02:00
README.md Initial commit 2025-06-02 21:41:33 +02:00

proxmox_snapshot Role

This role automates the creation and management of Proxmox container snapshots. It generates a timestamped snapshot name, creates a new snapshot for a specified container, and ensures that only the two most recent snapshots are retained.

Description

The proxmox_snapshot role simplifies snapshot management for Proxmox containers. It dynamically generates a unique snapshot name based on the current date and time, creates the snapshot, and enforces a retention policy to keep only the two newest snapshots. This ensures efficient snapshot management and prevents storage from being overwhelmed by old snapshots.

Installation

  1. Ensure that Ansible is installed on your system. The recommended version is at least 2.17.
  2. Clone this repository or add the role to your existing project.
  3. Ensure the following dependencies are met:
    • The community.general collection is installed (required for the proxmox_snap module).
    • API access to the Proxmox server with a valid token.

Variables

The role uses the following variables:

  • proxmox_uri: The base URI of the Proxmox server. Example: proxmox.domain.

  • proxmox_api_user: The Proxmox API username. Example: xxxx@pam.

  • proxmox_token_id: The ID of the Proxmox API token. Example: xxxx.

  • proxmox_token_secret: The secret for the Proxmox API token. Example: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.

  • vmid: The ID of the container for which the snapshot will be created. Example: 101.

  • proxmox_snapshot_name: A prefix for the snapshot name. The full name will include the prefix, the current date, and time. Example: "backup".

Usage

Example Playbook

- name: Create snapshot
  ansible.builtin.include_role:
    name: proxmox

Features

  • Dynamic Snapshot Naming: Generates a unique snapshot name based on the current date and time.
  • Snapshot Creation: Creates a new snapshot for the specified container.
  • Retention Policy: Ensures that only the two most recent snapshots are retained, automatically deleting older snapshots.
  • Proxmox API Integration: Uses the Proxmox API for seamless snapshot management.

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository.
  2. Create a new branch for your changes.
  3. Submit a pull request describing your changes.

License

This project is licensed under the AGPL License. The AGPL license requires that modifications to the software be disclosed when distributed or made available over a network. For more information, see the LICENSE file.