commit 50dcfec65a7a1784ff2f2028cb7eb265e49075c2 Author: Peter Leurs Date: Fri Aug 15 23:23:00 2025 +0200 initial commit diff --git a/appinfo.yml b/appinfo.yml new file mode 100644 index 0000000..3573a00 --- /dev/null +++ b/appinfo.yml @@ -0,0 +1,30 @@ +mainunit: zabbix-server.service +mainunitfile: zabbix-server.service.j2 +ports: + - web +templatefiles: + - src: compose.yml.j2 + dest: ~/compose.yml +exports: + web: + sites: + - proxyaddress: "http://127.0.0.1:{{ ports.web }}" + publicname: "{{ config.domainname }}" +configdefinition: + description: Zabbix config + type: object + additionalProperties: false + properties: + domainname: + type: string + description: The url that is used for the site + required: + - domainname +const: + image: + # Zabbix 7 (LTS) can't yet handle postgres 17 + postgres: docker.io/library/postgres:16.6 + # version 7.0.7 has a bug: https://support.zabbix.com/browse/ZBX-25765 + zabbix: docker.io/zabbix/zabbix-server-pgsql:7.0.6-ubuntu + web: docker.io/zabbix/zabbix-web-nginx-pgsql:7.0.6-ubuntu + diff --git a/compose.yml.j2 b/compose.yml.j2 new file mode 100644 index 0000000..229d00f --- /dev/null +++ b/compose.yml.j2 @@ -0,0 +1,61 @@ +version: '3' + +# We put everything in a seperate network so it doesn't matter +# that the passwords in this file are simple and known - you can't access it. +networks: + zabbix: {} + +services: + postgres-server: + image: {{ const.image.postgres }} + container_name: postgres-server + environment: + - POSTGRES_PASSWORD=postgres + - PGDATA=/data/pgdata + restart: always + volumes: + - {{ homedir }}/data:/data + - /etc/timezone:/etc/timezone:ro + - /etc/localtime:/etc/localtime:ro + - {{ homedir }}/appdefinition/dbsetup.sh:/docker-entrypoint-initdb.d/dbsetup.sh + healthcheck: + test: psql -U postgres -c "select version();" || exit 1 + interval: 5s + timeout: 2s + retries: 3 + zabbix: + image: {{ const.image.zabbix }} + container_name: zabbix + restart: always + volumes: + - /etc/timezone:/etc/timezone:ro + - /etc/localtime:/etc/localtime:ro + environment: + - POSTGRES_USER=zabbix + - POSTGRES_PASSWORD=zabbix + - POSTGRES_DB=zabbix + - DB_SERVER_HOST=postgres-server + - TZ=Europe/Brussels + depends_on: + postgres-server: + condition: service_healthy + restart: true + init: true + web: + image: {{ const.image.web }} + container_name: web + environment: + - POSTGRES_USER=zabbix + - POSTGRES_PASSWORD=zabbix + - POSTGRES_DB=zabbix + - DB_SERVER_HOST=postgres-server + - ZBX_SERVER_HOST=zabbix + - PHP_TZ=Europe/Brussels + - TZ=Europe/Brussels + restart: always + depends_on: + postgres-server: + condition: service_healthy + restart: true + ports: + - '127.0.0.1:{{ ports.web }}:8080' diff --git a/dbsetup.sh b/dbsetup.sh new file mode 100644 index 0000000..6680128 --- /dev/null +++ b/dbsetup.sh @@ -0,0 +1,16 @@ +#!/bin/bash +set -e + +# This file is executed INSIDE the postgres container, but only the very first time +# the database is created. If any side-effects of this script need to be performed +# again, execute into the container and try again. There is no need for authentication +# inside the container, the connection is trusted + +psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL + CREATE USER zabbix WITH PASSWORD 'zabbix'; + CREATE DATABASE zabbix; + GRANT ALL PRIVILEGES ON DATABASE zabbix TO zabbix; +EOSQL +psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname zabbix <<-EOSQL + GRANT ALL PRIVILEGES ON SCHEMA public TO zabbix; +EOSQL diff --git a/readme b/readme new file mode 100644 index 0000000..54cc52d --- /dev/null +++ b/readme @@ -0,0 +1,3 @@ +Work in progress. +Still needs a ppm template to be added. +Contact me if you're using the project! \ No newline at end of file diff --git a/zabbix-server.service.j2 b/zabbix-server.service.j2 new file mode 100644 index 0000000..1ad33fd --- /dev/null +++ b/zabbix-server.service.j2 @@ -0,0 +1,17 @@ +[Unit] +Description=Podman Compose based service +After=network.target + +[Service] +Type=exec +# If started incorrectly: stop it first (ie when started without systemd, systemd will know something is started +# and will not do anything when start is called on a unit that already is running) +ExecStartPre=-/usr/bin/podman-compose -f {{ homedir }}/compose.yml down +ExecStartPre={{ ppmbinary }} setup --do-not-enable-units +ExecStart=/usr/bin/podman-compose -f {{ homedir }}/compose.yml up +ExecStop=/usr/bin/podman-compose -f {{ homedir }}/compose.yml down +Restart=always +WorkingDirectory={{ homedir }} + +[Install] +WantedBy=default.target