From 74fcae4162031827b05301779513a33ad7c2b8b5 Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Thu, 1 Oct 2020 23:06:47 +0200 Subject: [PATCH] updated lego state --- states/lego/defaults.yaml | 9 +++++++++ states/lego/init.sls | 3 +++ states/lego/install.sls | 19 +++++++++++++++++++ states/lego/kernelmap.yaml | 3 +++ states/lego/map.jinja | 14 ++++++++++++++ states/lego/osarchmap.yaml | 21 +++++++++++++++++++++ 6 files changed, 69 insertions(+) create mode 100644 states/lego/defaults.yaml create mode 100644 states/lego/init.sls create mode 100644 states/lego/install.sls create mode 100644 states/lego/kernelmap.yaml create mode 100644 states/lego/map.jinja create mode 100644 states/lego/osarchmap.yaml diff --git a/states/lego/defaults.yaml b/states/lego/defaults.yaml new file mode 100644 index 0000000..a494136 --- /dev/null +++ b/states/lego/defaults.yaml @@ -0,0 +1,9 @@ +--- +lego: + enabled: true + install_dir: /usr/local/apps + release_dir: /usr/local/apps/releases + mirror: https://github.com/go-acme/lego/releases/download + version: v4.0.1 + os: linux + arch: amd64 diff --git a/states/lego/init.sls b/states/lego/init.sls new file mode 100644 index 0000000..10ad9a6 --- /dev/null +++ b/states/lego/init.sls @@ -0,0 +1,3 @@ +--- +include: + - .install \ No newline at end of file diff --git a/states/lego/install.sls b/states/lego/install.sls new file mode 100644 index 0000000..7050d66 --- /dev/null +++ b/states/lego/install.sls @@ -0,0 +1,19 @@ +--- +{%- from "lego/map.jinja" import lego with context %} +{%- if not salt['file.file_exists']( lego.install_dir +"/lego-" + lego.version) %} +lego-archive-extract: + archive.extracted: + - name: {{ lego.release_dir }}/lego-{{ lego.version }}-{{ lego.os }}-{{ lego.arch }} + - source: {{ lego.mirror }}/{{ lego.version }}/lego_{{ lego.version }}_{{ lego.os }}_{{ lego.arch }}.tar.gz + - skip_verify: true + - enforce_toplevel: false + - if_missing: {{ lego.release_dir }}/lego-{{ lego.version }}-{{ lego.os }}-{{ lego.arch }} + +lego-binary-symlink: + file.symlink: + - name: /usr/local/bin/lego + - target: {{ lego.release_dir }}/lego-{{ lego.version }}-{{ lego.os }}-{{ lego.arch }}/lego + - force: true + - require: + - archive: lego-archive-extract +{%- endif %} diff --git a/states/lego/kernelmap.yaml b/states/lego/kernelmap.yaml new file mode 100644 index 0000000..e368b24 --- /dev/null +++ b/states/lego/kernelmap.yaml @@ -0,0 +1,3 @@ +--- +Linux: + os: "linux" \ No newline at end of file diff --git a/states/lego/map.jinja b/states/lego/map.jinja new file mode 100644 index 0000000..e473081 --- /dev/null +++ b/states/lego/map.jinja @@ -0,0 +1,14 @@ +{%- import_yaml "lego/defaults.yaml" as default_settings -%} + +{%- import_yaml "lego/kernelmap.yaml" as kernelmap -%} +{%- import_yaml "lego/osarchmap.yaml" as osarchmap -%} + +{%- set defaults = salt['grains.filter_by'](default_settings, + default='lego', + merge=salt['grains.filter_by'](osarchmap, grain='osarch', + merge=salt['grains.filter_by'](kernelmap, grain='kernel') + ) + ) +-%} + +{%- set lego = salt['pillar.get']('lego', default=defaults, merge=True) -%} diff --git a/states/lego/osarchmap.yaml b/states/lego/osarchmap.yaml new file mode 100644 index 0000000..c12e349 --- /dev/null +++ b/states/lego/osarchmap.yaml @@ -0,0 +1,21 @@ +--- +amd64: + arch: "amd64" + +x86_64: + arch: "amd64" + +386: + arch: "386" + +arm64: + arch: "arm64" + +armv6l: + arch: "arm" + +armv7l: + arch: "arm" + +armhf: + arch: "arm" \ No newline at end of file