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