etcd/backup: native ansible modules instead of shell (#10540)
This make native ansible features (dry-run, changed state) easier to have, and should have a minimal performance impact, since it only runs on the etcd members.pull/10509/merge
parent
5f9a7b9d49
commit
8f0e553e11
|
@ -2,11 +2,21 @@
|
||||||
- name: Cleanup etcd backups
|
- name: Cleanup etcd backups
|
||||||
command: /bin/true
|
command: /bin/true
|
||||||
notify:
|
notify:
|
||||||
|
- Find old etcd backups
|
||||||
- Remove old etcd backups
|
- Remove old etcd backups
|
||||||
|
|
||||||
- name: Remove old etcd backups
|
- name: Find old etcd backups
|
||||||
shell:
|
ansible.builtin.find:
|
||||||
chdir: "{{ etcd_backup_prefix }}"
|
file_type: directory
|
||||||
cmd: "set -o pipefail && find . -name 'etcd-*' -type d | sort -n | head -n -{{ etcd_backup_retention_count }} | xargs rm -rf"
|
recurse: false
|
||||||
executable: /bin/bash
|
paths: "{{ etcd_backup_prefix }}"
|
||||||
|
patterns: "etcd-*"
|
||||||
|
register: _etcd_backups
|
||||||
|
when: etcd_backup_retention_count >= 0
|
||||||
|
|
||||||
|
- name: Remove old etcd backups
|
||||||
|
ansible.builtin.file:
|
||||||
|
state: absent
|
||||||
|
path: "{{ item }}"
|
||||||
|
loop: "{{ (_etcd_backups.files | sort(attribute='ctime', reverse=True))[etcd_backup_retention_count:] | map(attribute='path') }}"
|
||||||
when: etcd_backup_retention_count >= 0
|
when: etcd_backup_retention_count >= 0
|
||||||
|
|
Loading…
Reference in New Issue