From 2f632e8615cb28ab478384261abe6f09cef66bef Mon Sep 17 00:00:00 2001 From: = Date: Sat, 2 Jan 2021 10:35:49 +0100 Subject: [PATCH] added minio salt state --- minio/files/minio.service.jinja | 14 ++++++++++++++ minio/init.sls | 3 +++ minio/prereq.sls | 10 ++++++++++ minio/systemd.sls | 20 ++++++++++++++++++++ top.sls | 4 ++++ 5 files changed, 51 insertions(+) create mode 100644 minio/files/minio.service.jinja create mode 100644 minio/init.sls create mode 100644 minio/prereq.sls create mode 100644 minio/systemd.sls diff --git a/minio/files/minio.service.jinja b/minio/files/minio.service.jinja new file mode 100644 index 0000000..e39751c --- /dev/null +++ b/minio/files/minio.service.jinja @@ -0,0 +1,14 @@ +[Unit] +Description=MinIO podman container + +[Service] +Restart=on-failure +ExecStartPre=/usr/bin/rm -f /%t/%n-pid /%t/%n-cid +ExecStart=/usr/bin/podman run --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid --detach -p "9000:9000" -e "MINIO_ACCESS_KEY={{ pillar['minio']['accesskey'] }}" -v "/srv/minio:/data" -e "MINIO_SECRET_KEY={{ pillar['minio']['secretkey'] }}" minio/minio server /data +ExecStop=/usr/bin/sh -c "/usr/bin/podman rm -f `cat /%t/%n-cid`" +KillMode=none +Type=forking +PIDFile=/%t/%n-pid + +[Install] +WantedBy=multi-user.target diff --git a/minio/init.sls b/minio/init.sls new file mode 100644 index 0000000..6fc69a6 --- /dev/null +++ b/minio/init.sls @@ -0,0 +1,3 @@ +include: + - minio.prereq + - minio.systemd diff --git a/minio/prereq.sls b/minio/prereq.sls new file mode 100644 index 0000000..86ab68c --- /dev/null +++ b/minio/prereq.sls @@ -0,0 +1,10 @@ +Create local MinIO storage: + file.directory: + - name: /srv/minio + - user: root + - group: root + - mode: "0755" + +Install podman: + pkg.installed: + - name: podman diff --git a/minio/systemd.sls b/minio/systemd.sls new file mode 100644 index 0000000..a0e8f50 --- /dev/null +++ b/minio/systemd.sls @@ -0,0 +1,20 @@ +Create minio systemd service: + file.managed: + - name: /etc/systemd/system/minio.service + - source: salt://minio/files/minio.service.jinja + - template: jinja + - user: root + - group: root + - mode: "0660" + +SystemD daemon reload: + cmd.run: + - name: systemctl --system daemon-reload + - onchanges: + - file: Create minio systemd service + +start MinIO: + service.running: + - name: minio.service + - onchanges: + - cmd: SystemD daemon reload diff --git a/top.sls b/top.sls index 5e904bf..be2c390 100644 --- a/top.sls +++ b/top.sls @@ -15,3 +15,7 @@ base: 'k3s': - match: nodegroup - k3s + + 'minio:enabled:true': + - match: pillar + - minio