diff --git a/states/dip/defaults.yaml b/states/dip/defaults.yaml new file mode 100644 index 0000000..a934874 --- /dev/null +++ b/states/dip/defaults.yaml @@ -0,0 +1,10 @@ +--- +dip: + enabled: true + install_dir: /usr/local/apps + release_dir: /usr/local/apps/releases + port: 8989 + mirror: https://git.paulbsd.com/paulbsd/dip/releases/download + version: 1.0.0 + os: linux + arch: amd64 \ No newline at end of file diff --git a/states/dip/dip.service.j2 b/states/dip/dip.service.j2 new file mode 100644 index 0000000..0c0af92 --- /dev/null +++ b/states/dip/dip.service.j2 @@ -0,0 +1,12 @@ +## {{ salt['pillar.get']('salt_managed', default='Salt Managed') }} +{%- from "dip/map.jinja" import dip with context %} +[Unit] +Description=DIP +After=network.target + +[Service] +Type=simple +ExecStart={{ dip.install_dir }}/dip/dip -configfile {{ dip.install_dir }}/config/common.ini -port {{ dip.port }} + +[Install] +WantedBy=multi-user.target diff --git a/states/dip/init.sls b/states/dip/init.sls new file mode 100644 index 0000000..b07358d --- /dev/null +++ b/states/dip/init.sls @@ -0,0 +1,4 @@ +--- +include: + - .install + - .service \ No newline at end of file diff --git a/states/dip/install.sls b/states/dip/install.sls new file mode 100644 index 0000000..4a2d7ab --- /dev/null +++ b/states/dip/install.sls @@ -0,0 +1,20 @@ +--- +{%- from "dip/map.jinja" import dip with context %} +dip-archive-extract: + archive.extracted: + - name: {{ dip.release_dir }}/dip-{{ dip.version }} + - source: {{ dip.mirror }}/{{ dip.version }}/dip-{{ dip.version }}-{{ dip.os }}-{{ dip.arch }}.tar.gz + - skip_verify: True + - enforce_toplevel: False + - if_missing: {{ dip.release_dir }}/dip-{{ dip.version }} + - watch_in: + - service: dip-service + +dip-binary-symlink: + file.symlink: + - name: {{ dip.install_dir }}/dip + - target: {{ dip.release_dir }}/dip-{{ dip.version }} + - require: + - archive: dip-archive-extract + - watch_in: + - service: dip-service \ No newline at end of file diff --git a/states/dip/kernelmap.yaml b/states/dip/kernelmap.yaml new file mode 100644 index 0000000..e368b24 --- /dev/null +++ b/states/dip/kernelmap.yaml @@ -0,0 +1,3 @@ +--- +Linux: + os: "linux" \ No newline at end of file diff --git a/states/dip/map.jinja b/states/dip/map.jinja new file mode 100644 index 0000000..98ba703 --- /dev/null +++ b/states/dip/map.jinja @@ -0,0 +1,14 @@ +{%- import_yaml "dip/defaults.yaml" as default_settings -%} + +{%- import_yaml "dip/kernelmap.yaml" as kernelmap -%} +{%- import_yaml "dip/osarchmap.yaml" as osarchmap -%} + +{%- set defaults = salt['grains.filter_by'](default_settings, + default='dip', + merge=salt['grains.filter_by'](osarchmap, grain='osarch', + merge=salt['grains.filter_by'](kernelmap, grain='kernel') + ) + ) +-%} + +{%- set dip = salt['pillar.get']('dip', default=defaults, merge=True) -%} \ No newline at end of file diff --git a/states/dip/osarchmap.yaml b/states/dip/osarchmap.yaml new file mode 100644 index 0000000..c12e349 --- /dev/null +++ b/states/dip/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 diff --git a/states/dip/service.sls b/states/dip/service.sls new file mode 100644 index 0000000..c94c38f --- /dev/null +++ b/states/dip/service.sls @@ -0,0 +1,14 @@ +--- +{%- from "dip/map.jinja" import dip with context %} +dip-service-file: + file.managed: + - name: /etc/systemd/system/dip.service + - source: salt://dip/dip.service.j2 + - user: root + - group: root + - template: jinja + +dip-service: + service.running: + - name: dip + - enable: True \ No newline at end of file