role_borgmatic/handlers/main.yml

32 lines
756 B
YAML
Raw Normal View History

2023-03-06 23:13:54 +00:00
---
# handlers file for borgmatic
- name: Créer le dépôt
ansible.builtin.command:
2023-07-28 07:03:59 +00:00
cmd: borg init -e repokey-blake2 {{ item.path }}
2023-03-06 23:13:54 +00:00
become: true
2023-07-28 07:03:59 +00:00
loop: "{{ borgmatic_repositories }}"
register: borg_init
failed_when:
- "'A repository already exists' not in borg_init.stderr"
- borg_init.rc != 0
changed_when:
- "'A repository already exists' not in borg_init.stderr"
- borg_init.rc == 0
2023-03-06 23:13:54 +00:00
- name: Activer la planification
ansible.builtin.systemd:
daemon_reload: true
enabled: true
state: stopped
name: borgmatic.timer
become: true
- name: Activer et démarrer le service
ansible.builtin.systemd:
daemon_reload: true
enabled: false
state: started
name: borgmatic.service
become: true