2019-08-13 13:52:25 +02:00
|
|
|
---
|
|
|
|
- name: Initialize repository
|
|
|
|
command: '{{ restic_install_path }}/restic init'
|
|
|
|
environment:
|
|
|
|
RESTIC_REPOSITORY: '{{ item.value.location }}'
|
|
|
|
RESTIC_PASSWORD: '{{ item.value.password }}'
|
2020-06-02 19:45:52 +02:00
|
|
|
AWS_ACCESS_KEY_ID: '{{ item.value.aws_access_key | default("") }}'
|
2020-06-02 19:47:37 +02:00
|
|
|
AWS_SECRET_ACCESS_KEY: '{{
|
|
|
|
item.value.aws_secret_access_key
|
|
|
|
| default("")
|
|
|
|
}}'
|
2020-06-02 19:45:52 +02:00
|
|
|
AWS_DEFAULT_REGION: '{{ item.value.aws_default_region | default("") }}'
|
2019-08-14 16:59:32 +02:00
|
|
|
no_log: true
|
2019-08-13 13:52:25 +02:00
|
|
|
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
|
2020-06-02 15:58:43 +02:00
|
|
|
- not 'config already initialized' in restic_init.stderr
|
2019-08-13 13:52:25 +02:00
|
|
|
loop: "{{ restic_repos|dict2items }}"
|
|
|
|
when:
|
|
|
|
- item.value.init is defined
|
2019-08-15 10:00:45 +02:00
|
|
|
- item.value.init
|