From e753afd5e1384bcfef22a7c1415f1ed58cd5c1a2 Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Mon, 30 Nov 2020 21:44:50 +0100 Subject: [PATCH] added pki state --- states/pki/defaults.yaml | 9 +++++++++ states/pki/init.sls | 3 +++ states/pki/install.sls | 16 ++++++++++++++++ states/pki/kernelmap.yaml | 3 +++ states/pki/map.jinja | 14 ++++++++++++++ states/pki/osarchmap.yaml | 21 +++++++++++++++++++++ 6 files changed, 66 insertions(+) create mode 100644 states/pki/defaults.yaml create mode 100644 states/pki/init.sls create mode 100644 states/pki/install.sls create mode 100644 states/pki/kernelmap.yaml create mode 100644 states/pki/map.jinja create mode 100644 states/pki/osarchmap.yaml diff --git a/states/pki/defaults.yaml b/states/pki/defaults.yaml new file mode 100644 index 0000000..752da7e --- /dev/null +++ b/states/pki/defaults.yaml @@ -0,0 +1,9 @@ +--- +pki: + enabled: true + install_dir: /usr/local/apps + release_dir: /usr/local/apps/releases + mirror: https://git.paulbsd.com/paulbsd/pki/releases/download + version: 0.1.0 + os: linux + arch: amd64 diff --git a/states/pki/init.sls b/states/pki/init.sls new file mode 100644 index 0000000..10ad9a6 --- /dev/null +++ b/states/pki/init.sls @@ -0,0 +1,3 @@ +--- +include: + - .install \ No newline at end of file diff --git a/states/pki/install.sls b/states/pki/install.sls new file mode 100644 index 0000000..b76d05d --- /dev/null +++ b/states/pki/install.sls @@ -0,0 +1,16 @@ +--- +{% from "pki/map.jinja" import pki with context %} +pki-archive-extract: + archive.extracted: + - name: {{ pki.release_dir }}/pki-{{ pki.version }} + - source: {{ pki.mirror }}/{{ pki.version }}/pki-{{ pki.version }}-{{ pki.os }}-{{ pki.arch }}.tar.gz + - skip_verify: true + - enforce_toplevel: false + - if_missing: {{ pki.release_dir }}/pki-{{ pki.version }} + +pki-binary-symlink: + file.symlink: + - name: {{ pki.install_dir }}/pki + - target: {{ pki.release_dir }}/pki-{{ pki.version }} + - require: + - archive: pki-archive-extract diff --git a/states/pki/kernelmap.yaml b/states/pki/kernelmap.yaml new file mode 100644 index 0000000..e368b24 --- /dev/null +++ b/states/pki/kernelmap.yaml @@ -0,0 +1,3 @@ +--- +Linux: + os: "linux" \ No newline at end of file diff --git a/states/pki/map.jinja b/states/pki/map.jinja new file mode 100644 index 0000000..a1ba258 --- /dev/null +++ b/states/pki/map.jinja @@ -0,0 +1,14 @@ +{%- import_yaml "pki/defaults.yaml" as default_settings -%} + +{%- import_yaml "pki/kernelmap.yaml" as kernelmap -%} +{%- import_yaml "pki/osarchmap.yaml" as osarchmap -%} + +{%- set defaults = salt['grains.filter_by'](default_settings, + default='pki', + merge=salt['grains.filter_by'](osarchmap, grain='osarch', + merge=salt['grains.filter_by'](kernelmap, grain='kernel') + ) + ) +-%} + +{%- set pki = salt['pillar.get']('pki', default=defaults, merge=True) -%} diff --git a/states/pki/osarchmap.yaml b/states/pki/osarchmap.yaml new file mode 100644 index 0000000..c12e349 --- /dev/null +++ b/states/pki/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