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