49 lines
1.1 KiB
YAML
49 lines
1.1 KiB
YAML
---
|
|
# This playbook cleans up its own backup directory.
|
|
- name: Cleanup semaphore
|
|
hosts: all
|
|
gather_facts: true
|
|
|
|
tasks:
|
|
- name: Include variables
|
|
include_vars: vars/semaphore.yaml
|
|
|
|
- name: Search for volume's backup directories
|
|
become: yes
|
|
find:
|
|
paths: "{{ local_backup }}"
|
|
file_type: directory
|
|
recurse: false
|
|
register: backup_dirs
|
|
|
|
- name: Copy backup files
|
|
become: yes
|
|
copy:
|
|
remote_src: true
|
|
src: "{{ item.path }}"
|
|
dest: "{{ backup_dir }}"
|
|
loop: "{{ backup_dirs.files }}"
|
|
loop_control:
|
|
label: "{{ item.path }}"
|
|
|
|
- name: Cleanup volume's backup directories
|
|
become: yes
|
|
file:
|
|
path: "{{ item.path }}"
|
|
state: absent
|
|
loop: "{{ backup_dirs.files }}"
|
|
loop_control:
|
|
label: "{{ item.path }}"
|
|
|
|
- name: Correct directory owner
|
|
become: yes
|
|
file:
|
|
path: "{{ backup_dir }}"
|
|
owner: chris
|
|
group: chris
|
|
recurse: yes
|
|
|
|
- name: Include the run next playbook
|
|
import_playbook: run-next.yaml
|
|
vars:
|
|
to_do: rotate |