| defaults | ||
| meta | ||
| tasks | ||
| vars.example | ||
| .gitignore | ||
| LICENSE | ||
| README.md | ||
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
- Ensure that Ansible is installed on your system. The recommended version is at least
2.17. - Clone this repository or add the role to your existing project.
- Ensure the following dependencies are met:
- The
community.generalcollection is installed (required for theproxmox_snapmodule). - API access to the Proxmox server with a valid token.
- The
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:
- Fork the repository.
- Create a new branch for your changes.
- 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.