From 99efec7e952c7fb666f52d1c3a04fa4291d13b12 Mon Sep 17 00:00:00 2001 From: Keiran Snowden Date: Mon, 27 Nov 2023 19:51:17 -0500 Subject: [PATCH] restic version from pillar --- restic/files/install.sh | 8 ++------ restic/init.sls | 4 +--- top.sls | 3 ++- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/restic/files/install.sh b/restic/files/install.sh index e940468..977d6bb 100644 --- a/restic/files/install.sh +++ b/restic/files/install.sh @@ -1,12 +1,8 @@ #!/bin/bash {% set arch = 'arm' salt.grains.get(cpuarch).startswith('arm') else 'amd64' %} +{% set restic_version = salt.pillar.get("restic:version") %} -if test -z "$RESTIC_VERSION"; then - echo "RESTIC_VERSION is not defined" - exit 1 -fi - -URL="https://github.com/restic/restic/releases/download/v${RESTIC_VERSION}/restic_${RESTIC_VERSION}_linux_{{ arch }}.bz2" +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 if [ $? -eq 0 ]; then diff --git a/restic/init.sls b/restic/init.sls index 116dcda..35f6503 100644 --- a/restic/init.sls +++ b/restic/init.sls @@ -26,9 +26,7 @@ restic-{{ name }}: - shell: /bin/bash - source: 'salt://restic/files/install.sh' - template: jinja - - unless: "/bin/restic version | grep 'restic 0.16.2 '" - - env: - - RESTIC_VERSION: 0.16.2 + - unless: "/bin/restic version | grep 'restic {{ salt.pillar.get("restic:version") }} '" {% endif %} /etc/logrotate.d/restic-backup: diff --git a/top.sls b/top.sls index a211c26..4a80126 100644 --- a/top.sls +++ b/top.sls @@ -3,7 +3,8 @@ - salt - common - users -{% if salt.pillar.get('restic', None) is not none %} +{% if salt.pillar.get('restic:client', None) is not none or + if salt.pillar.get('restic:server', None) is not none %} - restic {% endif %} '*.keiran.us':