b9be45dc71
Complete IaC covering: - 14 roles: common, docker, traefik, vaultwarden, monitoring, media, matrix, home_assistant, frigate, adguard, gitea, semaphore, openclaw, security, backup - Inventory for all hosts (Peggy, Bart, Yoda, NAS, Firewalla) - Stack playbooks: core-infrastructure, monitoring, media, communication, automation, smarthome, security-hardening - Maintenance playbooks: update-containers, backup, health-check - Production Docker Compose templates with Traefik labels - Security hardening (sysctl, auditd, UFW, fail2ban) - Automated backups with retention policy
43 lines
1.1 KiB
YAML
43 lines
1.1 KiB
YAML
---
|
|
- name: Run backups
|
|
hosts: docker_hosts
|
|
become: true
|
|
tasks:
|
|
- name: Ensure backup destination exists
|
|
ansible.builtin.file:
|
|
path: "{{ backup_destination }}"
|
|
state: directory
|
|
mode: "0750"
|
|
tags: [backup]
|
|
|
|
- name: Run backup script
|
|
ansible.builtin.command:
|
|
cmd: /usr/local/bin/homelab-backup.sh
|
|
register: backup_result
|
|
changed_when: backup_result.rc == 0
|
|
tags: [backup]
|
|
|
|
- name: Display backup result
|
|
ansible.builtin.debug:
|
|
msg: "{{ backup_result.stdout_lines }}"
|
|
tags: [backup]
|
|
|
|
- name: Clean up backups older than 30 days
|
|
ansible.builtin.find:
|
|
paths: "{{ backup_destination }}"
|
|
age: 30d
|
|
recurse: false
|
|
file_type: file
|
|
patterns: "*.tar.gz"
|
|
register: old_backups
|
|
tags: [backup, cleanup]
|
|
|
|
- name: Remove old backups
|
|
ansible.builtin.file:
|
|
path: "{{ item.path }}"
|
|
state: absent
|
|
loop: "{{ old_backups.files }}"
|
|
loop_control:
|
|
label: "{{ item.path | basename }}"
|
|
tags: [backup, cleanup]
|