main.yml 621 B

123456789101112131415161718192021
  1. - name: Ensure restic binary is in place
  2. copy:
  3. src: restic_linux_amd64
  4. dest: /usr/local/bin
  5. - name: Ensure restic password file exists
  6. copy:
  7. dest: /root/.rest.password
  8. content: "{{ restic_repo_password }}"
  9. mode: 0600
  10. - name: Init restic repository
  11. shell: /usr/local/bin/restic -p /root/.rest.password -t {{ restic_repo }} init || true
  12. - name: Ensure restic cron jobs exist
  13. cron:
  14. name: Restic backups for {{ item.dir }}
  15. job: /usr/local/bin/restic -p /root/.rest.password -t {{ restic_repo }} backup {{ item.dir }}
  16. hour: 2
  17. minute: 35
  18. with_items: "{{ restic_stateful_dirs }}"