service: Support postgres >= 18 and postgres upgrades

This commit is contained in:
uumas
2026-03-12 00:26:35 +02:00
parent c673aae8dc
commit 470b60f988
3 changed files with 10 additions and 3 deletions

View File

@@ -22,7 +22,8 @@ service_database_type: none
service_database_additional_networks: [] service_database_additional_networks: []
service_database_secret_type: mount service_database_secret_type: mount
service_database_secret_target: "{{ service_database_type }}" service_database_secret_target: "{{ service_database_type }}"
service_postgres_image: docker.io/library/postgres service_postgres_image: docker.io/pgautoupgrade/pgautoupgrade
service_postgres_tag: alpine
service_redis: false service_redis: false
service_additional_containers: [] service_additional_containers: []

View File

@@ -294,7 +294,7 @@ argument_specs:
description: description:
- Postgresql version to use. - Postgresql version to use.
- Can be debian (n) or alpine-based (n-alpine), where n can be major version like 14 or minor like 14.13. - Can be debian (n) or alpine-based (n-alpine), where n can be major version like 14 or minor like 14.13.
- Required if service_database_type is postgres, does nothing otherwise - Ignored if database type is not postgres.
- If a custom postgres image is specified, see that image documentation for supported tags. - If a custom postgres image is specified, see that image documentation for supported tags.
type: str type: str
required: false required: false

View File

@@ -1,6 +1,12 @@
--- ---
_service_database_image: "{{ service_postgres_image }}:{{ service_postgres_tag }}" _service_database_image: "{{ service_postgres_image }}:{{ service_postgres_tag }}"
_service_database_mount_destination: /var/lib/postgresql/data _service_database_mount_destination: >-
{{
'/var/lib/postgresql/data'
if (service_postgres_tag | split('-') | length > 1)
and (service_postgres_tag | split('-') | first) is version('18', '<')
else '/var/lib/postgresql'
}}
_service_database_env: _service_database_env:
POSTGRES_USER: "{{ service_name | replace('-', '_') }}" POSTGRES_USER: "{{ service_name | replace('-', '_') }}"
POSTGRES_PASSWORD_FILE: "/run/secrets/{{ service_database_type }}" POSTGRES_PASSWORD_FILE: "/run/secrets/{{ service_database_type }}"