瀏覽代碼

check if restic init is failing

les 3 年之前
父節點
當前提交
96da8149f0
共有 1 個文件被更改,包括 8 次插入0 次删除
  1. 8 0
      roles/stable/restic/tasks/main.yml

+ 8 - 0
roles/stable/restic/tasks/main.yml

@@ -65,3 +65,11 @@
   environment:
     RESTIC_REPOSITORY: "sftp:{{ restic_ssh_host }}:{{ restic_repository_name }}"
     RESTIC_PASSWORD: "{{restic_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
+    - not 'config already initialized' in restic_init.stderr
+    - not 'config already exists' in restic_init.stderr