More backup stuff
This commit is contained in:
parent
16e9c32e41
commit
846496d618
@ -35,6 +35,7 @@ all:
|
|||||||
3331636339356236330a333330373264306163393162386330393763613332376261373433303035
|
3331636339356236330a333330373264306163393162386330393763613332376261373433303035
|
||||||
65633034366439343232356639346665326234666630633063616437376131396463
|
65633034366439343232356639346665326234666630633063616437376131396463
|
||||||
backup_location: "/backup/pfsense"
|
backup_location: "/backup/pfsense"
|
||||||
|
backup_number_to_keep: 10
|
||||||
boardwalk:
|
boardwalk:
|
||||||
ansible_host: "10.77.7.2"
|
ansible_host: "10.77.7.2"
|
||||||
backup_url: "10.77.7.2"
|
backup_url: "10.77.7.2"
|
||||||
@ -47,6 +48,7 @@ all:
|
|||||||
6566663062336566320a323536303233393431363263313933643839303435356266656136343438
|
6566663062336566320a323536303233393431363263313933643839303435356266656136343438
|
||||||
35306638356564333962656433323735656136386130373233393765616265306636
|
35306638356564333962656433323735656136386130373233393765616265306636
|
||||||
backup_location: "/backup/pfsense"
|
backup_location: "/backup/pfsense"
|
||||||
|
backup_number_to_keep: 10
|
||||||
children:
|
children:
|
||||||
docker_nodes:
|
docker_nodes:
|
||||||
hosts:
|
hosts:
|
||||||
|
@ -83,6 +83,27 @@
|
|||||||
changed_when: false
|
changed_when: false
|
||||||
no_log: "{{ pfsense_backup_disable_logging | default(false) }}"
|
no_log: "{{ pfsense_backup_disable_logging | default(false) }}"
|
||||||
|
|
||||||
|
- name: Find all PFSense backups for the current host
|
||||||
|
ansible.builtin.find:
|
||||||
|
paths: "{{ backup_location }}"
|
||||||
|
patterns: "{{ inventory_hostname }}*"
|
||||||
|
register: all_pfsense_backups
|
||||||
|
|
||||||
|
- name: If too many backups kept
|
||||||
|
when: all_pfsense_backups | length > backup_number_to_keep
|
||||||
|
block:
|
||||||
|
- name: Get the oldest file paths
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
oldest_file_paths: >-
|
||||||
|
{{ (all_pfsense_backups.files | sort(attribute='mtime'))[:all_pfsense_backups.files | length - backup_number_to_keep] |
|
||||||
|
map(attribute=path) | list }}
|
||||||
|
|
||||||
|
- name: Remove the files
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ item }}"
|
||||||
|
state: absent
|
||||||
|
loop: "{{ oldest_file_paths }}"
|
||||||
|
|
||||||
- name: Docker Infrastructure Compose Backups
|
- name: Docker Infrastructure Compose Backups
|
||||||
hosts: docker_nodes
|
hosts: docker_nodes
|
||||||
become: true
|
become: true
|
||||||
|
Loading…
Reference in New Issue
Block a user