From 9730b83e41ba2c7a4a63cf08a5ed95d4d82f4066 Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Sat, 7 Jan 2023 21:04:49 +0100 Subject: [PATCH] added iplbc state --- states/ipblc/defaults.yaml | 9 +++++++++ states/ipblc/init.sls | 4 ++++ states/ipblc/install.sls | 30 ++++++++++++++++++++++++++++++ states/ipblc/ipblc.service.j2 | 12 ++++++++++++ states/ipblc/kernelmap.yaml | 3 +++ states/ipblc/map.jinja | 14 ++++++++++++++ states/ipblc/osarchmap.yaml | 21 +++++++++++++++++++++ states/ipblc/service.sls | 14 ++++++++++++++ 8 files changed, 107 insertions(+) create mode 100644 states/ipblc/defaults.yaml create mode 100644 states/ipblc/init.sls create mode 100644 states/ipblc/install.sls create mode 100644 states/ipblc/ipblc.service.j2 create mode 100644 states/ipblc/kernelmap.yaml create mode 100644 states/ipblc/map.jinja create mode 100644 states/ipblc/osarchmap.yaml create mode 100644 states/ipblc/service.sls diff --git a/states/ipblc/defaults.yaml b/states/ipblc/defaults.yaml new file mode 100644 index 0000000..090f49b --- /dev/null +++ b/states/ipblc/defaults.yaml @@ -0,0 +1,9 @@ +--- +ipblc: + enabled: true + install_dir: /usr/local/apps + release_dir: /usr/local/apps/releases + mirror: https://git.paulbsd.com/paulbsd/ipblc/releases/download + version: "1.1.0" + os: linux + arch: amd64 diff --git a/states/ipblc/init.sls b/states/ipblc/init.sls new file mode 100644 index 0000000..b71e4b0 --- /dev/null +++ b/states/ipblc/init.sls @@ -0,0 +1,4 @@ +--- +include: + - .install + - .service diff --git a/states/ipblc/install.sls b/states/ipblc/install.sls new file mode 100644 index 0000000..277a8d8 --- /dev/null +++ b/states/ipblc/install.sls @@ -0,0 +1,30 @@ +--- +{%- from "ipblc/map.jinja" import ipblc with context %} +ipblc-dependencies: + pkg.installed: + - name: libczmq4 + +ipblc-archive-extract: + archive.extracted: + - name: {{ ipblc.release_dir }}/ipblc-{{ ipblc.version }} + - source: {{ ipblc.mirror }}/{{ ipblc.version }}/ipblc-{{ ipblc.version }}-{{ ipblc.os }}-{{ ipblc.arch }}.tar.gz + - skip_verify: true + - enforce_toplevel: false + - if_missing: {{ ipblc.release_dir }}/ipblc-{{ ipblc.version }} + - watch_in: + - service: ipblc-service + +ipblc-binary-symlink: + file.symlink: + - name: {{ ipblc.install_dir }}/ipblc + - target: {{ ipblc.release_dir }}/ipblc-{{ ipblc.version }} + - require: + - archive: ipblc-archive-extract + - watch_in: + - service: ipblc-service + +ipblc-cleanup: + software.cleanup: + - name: ipblc + - path: {{ ipblc.release_dir }} + - version: "{{ ipblc.version }}" diff --git a/states/ipblc/ipblc.service.j2 b/states/ipblc/ipblc.service.j2 new file mode 100644 index 0000000..31e4fda --- /dev/null +++ b/states/ipblc/ipblc.service.j2 @@ -0,0 +1,12 @@ +{%- from "ipblc/map.jinja" import ipblc with context -%} +## {{ salt['pillar.get']('salt_managed', default='Salt Managed') }} +[Unit] +Description=ipblc +After=network.target postgresql.service + +[Service] +Type=simple +ExecStart={{ ipblc.install_dir }}/ipblc/ipblc + +[Install] +WantedBy=multi-user.target diff --git a/states/ipblc/kernelmap.yaml b/states/ipblc/kernelmap.yaml new file mode 100644 index 0000000..40943f2 --- /dev/null +++ b/states/ipblc/kernelmap.yaml @@ -0,0 +1,3 @@ +--- +Linux: + os: "linux" diff --git a/states/ipblc/map.jinja b/states/ipblc/map.jinja new file mode 100644 index 0000000..2b276fd --- /dev/null +++ b/states/ipblc/map.jinja @@ -0,0 +1,14 @@ +{%- import_yaml "ipblc/defaults.yaml" as default_settings -%} + +{%- import_yaml "ipblc/kernelmap.yaml" as kernelmap -%} +{%- import_yaml "ipblc/osarchmap.yaml" as osarchmap -%} + +{%- set defaults = salt['grains.filter_by'](default_settings, + default='ipblc', + merge=salt['grains.filter_by'](osarchmap, grain='osarch', + merge=salt['grains.filter_by'](kernelmap, grain='kernel') + ) + ) +-%} + +{%- set ipblc = salt['pillar.get']('ipblc', default=defaults, merge=True) -%} diff --git a/states/ipblc/osarchmap.yaml b/states/ipblc/osarchmap.yaml new file mode 100644 index 0000000..4bd82f8 --- /dev/null +++ b/states/ipblc/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" diff --git a/states/ipblc/service.sls b/states/ipblc/service.sls new file mode 100644 index 0000000..d8b05ac --- /dev/null +++ b/states/ipblc/service.sls @@ -0,0 +1,14 @@ +--- +{%- from "ipblc/map.jinja" import ipblc with context %} +ipblc-service-file: + file.managed: + - name: /etc/systemd/system/ipblc.service + - source: salt://ipblc/ipblc.service.j2 + - user: root + - group: root + - template: jinja + +ipblc-service: + service.running: + - name: ipblc + - enable: true