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
2022-11-29 09:14:03 +01:00
..
files added gotify alerts on image updates 2022-11-22 14:50:41 +01:00
gitea.sls . 2022-11-02 11:18:20 +01:00
gotify.sls . 2022-11-02 11:18:20 +01:00
init.sls added gotify alerts on image updates 2022-11-22 14:50:41 +01: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.sls . 2022-11-02 11:18:20 +01:00
nodered.sls added nodered container 2022-11-16 08:25:16 +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
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