mirror of
https://github.com/roles-ansible/ansible_role_restic.git
synced 2024-12-11 23:41:32 +01:00
30 lines
No EOL
961 B
YAML
30 lines
No EOL
961 B
YAML
---
|
|
- name: Initialize repository
|
|
command: '{{ restic_install_path }}/restic init'
|
|
environment:
|
|
RESTIC_REPOSITORY: '{{ item.value.location }}'
|
|
RESTIC_PASSWORD: '{{ item.value.password }}'
|
|
no_log: True
|
|
register: restic_init
|
|
changed_when: "'created restic repository' in restic_init.stdout"
|
|
failed_when:
|
|
- restic_init.rc != 0
|
|
- not 'config file already exists' in restic_init.stderr
|
|
loop: "{{ restic_repos|dict2items }}"
|
|
when:
|
|
- item.value.init is defined
|
|
- item.value.init == true
|
|
|
|
- name: Create backup script
|
|
template:
|
|
src: restic_script.j2
|
|
dest: '{{ restic_script_dir }}/backup-{{ item.name }}.sh'
|
|
mode: '0700'
|
|
owner: '{{ restic_dir_owner }}'
|
|
group: '{{ restic_dir_group }}'
|
|
no_log: True
|
|
with_items: '{{ restic_backups }}'
|
|
when:
|
|
- item.name is defined
|
|
- item.src is defined or item.stdin is defined and item.stdin == true and item.stdin_cmd is defined
|
|
- item.repo in restic_repos |