This repository has been archived on 2023-06-27. You can view files and clone it, but cannot push or open issues or pull requests.
salt-states_old/podman
2023-03-30 09:41:41 +02:00
..
files added run option to container 2023-03-28 15:57:56 +02:00
alertmanager.sls added alertmanager 2022-12-19 10:47:10 +01:00
esphome.sls added esphome 2023-01-13 13:50:54 +01:00
gitea.sls . 2022-11-02 11:18:20 +01:00
gotify.sls . 2022-11-02 11:18:20 +01:00
grafana.sls added grafana 2022-11-29 09:51:05 +01:00
hass.sls added home-assistant 2023-03-28 10:26:23 +02:00
init.sls added gotify alerts on image updates 2022-11-22 14:50:41 +01:00
loki.sls added loki 2023-03-30 09:41:41 +02:00
mariadb.sls added mariadb dump to backup 2022-11-04 09:10:35 +01:00
mosquitto.sls . 2022-11-02 11:18:20 +01:00
nextcloud-cron.sls added nextcloud-cron.sls 2023-03-06 10:22:59 +01:00
nextcloud.sls . 2022-11-02 11:18:20 +01:00
nginx-exporter.sls added nginx-exporter 2023-03-28 15:58:14 +02:00
nodered.sls added rfxcom device 2023-01-05 10:20:40 +01:00
npm.sls . 2022-11-02 11:18:20 +01:00
prometheus.sls added prometheus 2022-11-29 09:14:03 +01:00
README.md added readme 2022-11-04 09:59:12 +01:00
unifi.sls . 2022-11-02 11:18:20 +01:00
unpoller.sls added unpoller 2023-01-19 09:39:31 +01:00
zigbee2mqtt.sls . 2022-11-02 11:18:20 +01:00

podman and container state

Will install the following packages:

  • podman

It will set linger for the user running the podman containers (default user: root) and create user systemd units for that user, create systemd unit files as user and start them.

Each container must have its own state file, named <container-name>.sls and placed in the podman state folder.

podman pillars:

podman:
  user: <podman user, default root if not defined>

container pillars:

containers:
  <container name>:
    image: <path to container image>
    tag: <image tag>
    volumes:
      <volume name>: <mount path>
    env:
      <environment varable name>: <value>
    ports:
      - host: <port number>
      - container: <port number>

Example

podman:
  user: foo
containers:
  mariadb:
    image: docker.io/library/mariadb
    tag: latest
    volumes:
      data: /var/lib/mysql
    env:
      MYSQL_ROOT_PASSWORD: verysecretpassword
    ports:
       - host: 3306
         container: 3306
       - host: 1234
         container 4321
         protocol: udp

Steps done in above example:

  • install podman
  • set linger for user foo
  • Create a firewald service for mariadb and add port 3306/tcp and 1234/ucp
  • add mariadb firewalld service to pillar.container.zone (default is public)
  • Create container controle script /home/foo/bin/mariadb.sh
  • create podman volume named mariadb-data
  • Create a podman container named mariadb
  • Create systemd unit file for container mariadb named mariadb.service
  • start mariadb service

Each container will have a script wrapper for the service and container.

Usage mariadb.sh [options..]
-h,-?, --help           Show help and exit
-p, --pull              pull container image (mariadb:latest)
-v, --volumes           create container volumes
-c, --create            create mariadb containers
-s, --start             start and enables mariadb container
-S, --stop              stop mariadb container
-i, --is-running        check to see if container service is running
-u, --check-update      check if there are image updates avaiable
    --update            perform image update if it exists
-g, --generate-systemd  generate user systemd service unit file