diff --git a/TODO b/TODO deleted file mode 100644 index a18f136..0000000 --- a/TODO +++ /dev/null @@ -1,4 +0,0 @@ -screenrc -apt remove triggerhappy -restic pulls x86 on the pi -install python3-dev for manual pip setup diff --git a/restic/files/install.sh b/restic/files/install.sh index 1ffc73c..adffc24 100644 --- a/restic/files/install.sh +++ b/restic/files/install.sh @@ -1,10 +1,19 @@ #!/bin/bash -{% set arch = 'arm' if salt.grains.get('cpuarch').startswith('arm') else 'amd64' %} +{% if salt.grains.get('cpuarch').startswith('arm') %} + {% set arch = 'arm' %} +{% elif salt.grains.get('cpuarch') == 'aarch64' %} + {% set arch = 'arm64' %} +{% else %} + {% set arch = 'amd64' %} +{% endif %} + {% set restic_version = salt.pillar.get("restic:version") %} URL="https://github.com/restic/restic/releases/download/v{{ restic_version }}/restic_{{ restic_version }}_linux_{{ arch }}.bz2" -wget --quiet "${URL}" -O - | bzip2 -cd > /bin/restic.tmp +echo "$URL" + +wget --quiet "$URL" -O - | bzip2 -cd > /bin/restic.tmp if [ $? -eq 0 ]; then chmod +x /bin/restic.tmp mv /bin/restic.tmp /bin/restic diff --git a/restic/init.sls b/restic/init.sls index 400f24a..279c5ca 100644 --- a/restic/init.sls +++ b/restic/init.sls @@ -1,21 +1,34 @@ +{{ salt.pillar.get("restic:server:mount:path") }}: + mount.mounted: + - device: {{ salt.pillar.get("restic:server:mount:device") | yaml_encode }} + - fstype: {{ salt.pillar.get("restic:server:mount:fstype") | yaml_encode }} + - mkmnt: {{ salt.pillar.get("restic:server:mount:mkmnt", True) | yaml_encode }} + - persist: {{ salt.pillar.get("restic:server:mount:persist", True) | yaml_encode }} + {% for name, minion_id in salt.pillar.get("restic:server:clients", {}).items() %} restic-{{ name }}: user.present: - - home: {{ salt.pillar.get("restic:server:mount") }}/{{ name }} + - home: {{ salt.pillar.get("restic:server:mount:path") }}/{{ name }} - createhome: true - system: true + - require: + - mount: {{ salt.pillar.get("restic:server:mount:path") }} -{{ salt.pillar.get("restic:server:mount") }}/{{ name }}/.ssh: +{{ salt.pillar.get("restic:server:mount:path") }}/{{ name }}/.ssh: file.directory: - user: restic-{{ name }} - group: restic-{{ name }} - mode: 700 -{{ salt.pillar.get("restic:server:mount") }}/{{ name }}/.ssh/authorized_keys: + - require: + - user: restic-{{ name }} +{{ salt.pillar.get("restic:server:mount:path") }}/{{ name }}/.ssh/authorized_keys: file.managed: - user: restic-{{ name }} - group: restic-{{ name }} - mode: 400 - contents: {{ salt.mine.get(minion_id, 'root_id_rsa_pub').get(minion_id, "") | yaml_encode }} + - require: + - file: {{ salt.pillar.get("restic:server:mount:path") }}/{{ name }}/.ssh {% endfor %} bzip2: