role_borgmatic/handlers/main.yml

32 lines
759 B
YAML

---
# handlers file for borgmatic
- name: Créer le dépôt
ansible.builtin.command:
cmd: borgmatic rcreate --encryption repokey-aes-ocb
become: true
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
- 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