From be5cb6fcf01d5ad58b36b76e3dece6c1d44d7d8b Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Sun, 30 Aug 2020 16:54:26 +0200 Subject: [PATCH] added gobackup state --- states/gobackup/config.sls | 11 +++++++++++ states/gobackup/defaults.yaml | 15 +++++++++++++++ states/gobackup/init.sls | 4 ++++ states/gobackup/install.sls | 10 ++++++++++ states/gobackup/kernelmap.yaml | 3 +++ states/gobackup/map.jinja | 14 ++++++++++++++ states/gobackup/osarchmap.yaml | 21 +++++++++++++++++++++ states/gobackup/templates/gobackup.yml.j2 | 0 8 files changed, 78 insertions(+) create mode 100644 states/gobackup/config.sls create mode 100644 states/gobackup/defaults.yaml create mode 100644 states/gobackup/init.sls create mode 100644 states/gobackup/install.sls create mode 100644 states/gobackup/kernelmap.yaml create mode 100644 states/gobackup/map.jinja create mode 100644 states/gobackup/osarchmap.yaml create mode 100644 states/gobackup/templates/gobackup.yml.j2 diff --git a/states/gobackup/config.sls b/states/gobackup/config.sls new file mode 100644 index 0000000..35326d1 --- /dev/null +++ b/states/gobackup/config.sls @@ -0,0 +1,11 @@ +--- +{%- from "gobackup/map.jinja" import gobackup with context %} +gobackup-config-dir: + file.directory: + - name: {{ gobackup.config_dir }} + +gobackup-config-file: + file.managed: + - name: {{ gobackup.config_dir }}/gobackup.yml + - source: salt://gobackup/templates/gobackup.yml.j2 + - template: jinja \ No newline at end of file diff --git a/states/gobackup/defaults.yaml b/states/gobackup/defaults.yaml new file mode 100644 index 0000000..b57f6d9 --- /dev/null +++ b/states/gobackup/defaults.yaml @@ -0,0 +1,15 @@ +--- +gobackup: + enabled: true + fetch_url: https://paulbsd-pub.s3.fr-par.scw.cloud/gobackup + install_dir: /usr/local/bin + config_dir: /etc/gobackup + config: + user: gobackup + password: password + store: + type: local + keep: 3 + path: /var/lib/gobackup + compress: + type: tgz \ No newline at end of file diff --git a/states/gobackup/init.sls b/states/gobackup/init.sls new file mode 100644 index 0000000..b91d8ec --- /dev/null +++ b/states/gobackup/init.sls @@ -0,0 +1,4 @@ +--- +include: + - .install + - .config \ No newline at end of file diff --git a/states/gobackup/install.sls b/states/gobackup/install.sls new file mode 100644 index 0000000..a435e36 --- /dev/null +++ b/states/gobackup/install.sls @@ -0,0 +1,10 @@ +--- +{%- from "gobackup/map.jinja" import gobackup with context %} +gobackup-bin: + file.managed: + - name: {{ gobackup.install_dir }}/gobackup + - source: {{ gobackup.fetch_url }}/gobackup-{{ gobackup.os }}-{{ gobackup.arch }} + - user: root + - group: root + - skip_verify: True + - if_missing: {{ gobackup.install_dir }}/gobackup \ No newline at end of file diff --git a/states/gobackup/kernelmap.yaml b/states/gobackup/kernelmap.yaml new file mode 100644 index 0000000..b01f41d --- /dev/null +++ b/states/gobackup/kernelmap.yaml @@ -0,0 +1,3 @@ +--- +Linux: + os: linux \ No newline at end of file diff --git a/states/gobackup/map.jinja b/states/gobackup/map.jinja new file mode 100644 index 0000000..2d5273c --- /dev/null +++ b/states/gobackup/map.jinja @@ -0,0 +1,14 @@ +{%- import_yaml "gobackup/defaults.yaml" as default_settings -%} + +{%- set defaults = salt['grains.filter_by'](default_settings, default='gobackup') -%} + +{%- import_yaml "gobackup/kernelmap.yaml" as kernelmap %} +{%- import_yaml "gobackup/osarchmap.yaml" as osarchmap %} + +{%- set gobackup = salt['pillar.get']('gobackup', + default=defaults, + merge=salt['grains.filter_by'](osarchmap, grain='osarch', + merge=salt['grains.filter_by'](kernelmap, grain='kernel') + ) + ) +-%} \ No newline at end of file diff --git a/states/gobackup/osarchmap.yaml b/states/gobackup/osarchmap.yaml new file mode 100644 index 0000000..fbaa340 --- /dev/null +++ b/states/gobackup/osarchmap.yaml @@ -0,0 +1,21 @@ +--- +amd64: + arch: amd64 + +arm64: + arch: arm64 + +# 386: +# arch: 386 + +# arm64: +# arch: arm64 + +# armv6l: +# arch: arm + +# armv7l: +# arch: arm + +# armhf: +# arch: arm \ No newline at end of file diff --git a/states/gobackup/templates/gobackup.yml.j2 b/states/gobackup/templates/gobackup.yml.j2 new file mode 100644 index 0000000..e69de29