{% for client in salt.pillar.get("restic:server:clients", []) %} restic-{{ client }}: user.present: - home: {{ salt.pillar.get("restic:server:mount") }}/{{ client }} - createhome: true - system: true {% endfor %} {% if salt.pillar.get("restic:client", None) is not none %} {% if salt.pillar.get("restic:client:install", True)%} 'download restic': cmd.script: - shell: /bin/bash - source: salt://restic/files/install.sh.jinja - templates: jinja - unless: "/bin/restic version | grep 'restic 0.16.2 '" - env: - RESTIC_VERSION: 0.16.2 {% endif %} /etc/logrotate.d/restic-backup: file.managed: - user: root - group: root - mode: 644 - contents: | /var/log/restic/backup.log { monthly rotate 3 compress missingok notifempty create 600 root root } /opt/restic: file.directory: - user: root - group: root - mode: 700 /opt/restic/env.sh: file.managed: - source: 'salt://restic/files/env.sh.jinja' - template: jinja - user: root - group: root - mode: 700 - require: - file: /opt/restic /opt/restic/backup.sh: file.managed: - source: 'salt://restic/files/backup.sh.jinja' - template: jinja - user: root - group: root - mode: 700 - require: - file: /opt/restic "/opt/restic/backup.sh 2>&1 >/dev/null": cron.present: - identifier: restic backup - minute: random - hour: 4 - dayweek: 0 /var/log/restic: file.directory: - user: root - group: root - mode: 700 {% endif %}