Files
ansible/hetzner.yaml

32 lines
792 B
YAML

---
# This playbook backups the customers on hetzner server.
- name: Backup hetzner
hosts: all
gather_facts: true
tasks:
- include_vars: vars/hetzner/secret.yaml
- include_vars: vars/hetzner/variable.yaml
- name: Create backup directory
file:
path: {{ backup_dir }}
state: directory
- name: Check if directories exist
stat:
path: "{{ backup_dir }}/{{ item.key }}"
register: dirs
loop: "{{ lookup('dict', customers) }}"
loop_control:
label: "{{ item.key }}"
- debug: var=dirs
- name: Create not existing directories
debug: var=item.invocation.module_args.path
when: item.stat.exists == false
with_items: "{{ dirs.results }}"
loop_control:
label: "{{ item.item }}"