Add playbooks/xcp_xo_snapshot_cleanup.yml
This commit is contained in:
20
playbooks/xcp_xo_snapshot_cleanup.yml
Normal file
20
playbooks/xcp_xo_snapshot_cleanup.yml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
- name: Cleanup Old Snapshots via Xen Orchestra
|
||||||
|
hosts: localhost
|
||||||
|
gather_facts: false
|
||||||
|
vars:
|
||||||
|
retention_days: 7
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: Find and delete snapshots older than {{ retention_days }} days
|
||||||
|
# Note: As of current community modules, specific snapshot cleanup
|
||||||
|
# by date often requires a URI module call to the XO REST API
|
||||||
|
# or a loop over vm_info results.
|
||||||
|
community.general.xen_orchestra_vm_info:
|
||||||
|
api_url: "{{ xo_host }}"
|
||||||
|
api_user: "{{ xo_user }}"
|
||||||
|
api_password: "{{ xo_password }}"
|
||||||
|
register: all_vms
|
||||||
|
|
||||||
|
# Logic here would involve filtering all_vms.vms for snapshots
|
||||||
|
# and comparing 'snapshot_time' against retention_days.
|
||||||
Reference in New Issue
Block a user