chore(postgresql): migrate to standardized container image variable structure

This commit is contained in:
Jan Christian Grünhage 2023-03-09 19:04:41 +01:00
parent ee42621a3c
commit 6e455089e4
4 changed files with 29 additions and 12 deletions

View file

@ -34,11 +34,11 @@ This is an example for specifying the official PostGIS image:
```yaml
postgresql_version: "13"
postgis_version: "3.1"
postgresql_container_image_name: "docker.io/postgis/postgis"
postgresql_container_image_repository: "docker.io/postgis/postgis"
postgresql_container_image_tag: "{{ postgresql_version }}-{{ postgis_version }}-{{ postgresql_container_distro }}"
```
You could also override the entire `postgresql_container_image` variable.
You could also override the entire `postgresql_container_image_reference` variable.
## Dependencies
Docker needs to be installed and configured.

View file

@ -6,17 +6,34 @@ postgresql_socket_path: "{{ postgresql_base_path }}/sockets"
postgresql_config_path: "{{ postgresql_base_path }}/config"
postgresql_connect_socket: true
postgresql_container_image_name: "docker.io/postgres"
postgresql_container_version: "13.4"
postgresql_container_distro: "alpine"
postgresql_container_image_tag: >-
postgresql_container_image_reference: >-
{{
postgresql_container_version
}}{{
('-' + postgresql_container_distro) if postgresql_container_distro else ''
postgresql_container_image_repository
+ ':'
+ postgresql_container_image_tag | default(
postgresql_container_version
+ (('-' + postgresql_container_distro)
if postgresql_container_distro
else ''
)
)
}}
postgresql_container_image: >-
{{ postgresql_container_image_name }}:{{ postgresql_container_image_tag }}
postgresql_container_image_repository: >-
{{
(
container_registries[postgresql_container_image_registry]
| default(postgresql_container_image_registry)
)
+ '/'
+ postgresql_container_image_namespace | default('')
+ postgresql_container_image_name
}}
postgresql_container_image_registry: "docker.io"
postgresql_container_image_name: "postgres"
postgresql_container_name: "postgresql"
postgresql_container_labels: {}
postgresql_container_ports: >-

View file

@ -25,7 +25,7 @@
- name: "Initialize PostgreSQL container"
community.docker.docker_container:
name: "{{ postgresql_container_name }}"
image: "{{ postgresql_container_image }}"
image: "{{ postgresql_container_image_reference }}"
ports: "{{ postgresql_container_ports }}"
volumes: "{{ postgresql_container_init_volumes }}"
labels: "{{ postgresql_container_labels_complete }}"

View file

@ -9,7 +9,7 @@
- name: "Ensure PostgreSQL container image is pulled"
community.docker.docker_image:
name: "{{ postgresql_container_image }}"
name: "{{ postgresql_container_image_reference }}"
force_source: "{{ postgresql_container_pull }}"
source: "pull"
state: "present"
@ -89,7 +89,7 @@
- name: "Ensure PostgreSQL container is started"
community.docker.docker_container:
name: "{{ postgresql_container_name }}"
image: "{{ postgresql_container_image }}"
image: "{{ postgresql_container_image_reference }}"
ports: "{{ postgresql_container_ports }}"
volumes: "{{ postgresql_container_volumes_complete }}"
labels: "{{ postgresql_container_labels_complete }}"