From 54b8fea753fef00d967a2952c2db2a6d43c8fd67 Mon Sep 17 00:00:00 2001 From: Vitaliy Kukharik Date: Sun, 8 Oct 2023 23:40:36 +0300 Subject: [PATCH] Extension Auto-Setup: postgis --- molecule/default/converge.yml | 1 + roles/packages/tasks/extensions.yml | 27 +++++++++++++++++++++++---- roles/pre-checks/tasks/extensions.yml | 2 +- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml index e14915a45..a8bce79b1 100644 --- a/molecule/default/converge.yml +++ b/molecule/default/converge.yml @@ -30,6 +30,7 @@ enable_pg_cron: true enable_pgaudit: true enable_pgvector: true + enable_postgis: true - name: Set variables for PostgreSQL Cluster update test ansible.builtin.set_fact: diff --git a/roles/packages/tasks/extensions.yml b/roles/packages/tasks/extensions.yml index 1246218f8..17575dc6d 100644 --- a/roles/packages/tasks/extensions.yml +++ b/roles/packages/tasks/extensions.yml @@ -15,7 +15,7 @@ until: package_status is success delay: 5 retries: 3 - when: (enable_timescale | default(false)| bool) or (enable_timescaledb | default(false)| bool) + when: (enable_timescale | default(false) | bool) or (enable_timescaledb | default(false) | bool) tags: timescaledb, timescale # pg_repack (if 'enable_pg_repack' is 'true') @@ -33,7 +33,7 @@ delay: 5 retries: 3 when: - - enable_pg_repack | default(false)| bool + - enable_pg_repack | default(false) | bool - not (ansible_os_family == 'RedHat' and (postgresql_version is version('10', '<=') or postgresql_version is version('16', '>='))) tags: pg_repack @@ -53,7 +53,7 @@ delay: 5 retries: 3 when: - - enable_pg_cron | default(false)| bool + - enable_pg_cron | default(false) | bool - not (ansible_os_family == 'RedHat' and postgresql_version is version('10', '<=')) tags: pg_cron @@ -80,7 +80,7 @@ delay: 5 retries: 3 when: - - enable_pgaudit | default(false)| bool + - enable_pgaudit | default(false) | bool - not (ansible_os_family == 'RedHat' and (postgresql_version is version('10', '<=') or postgresql_version is version('16', '>='))) tags: pgaudit @@ -105,4 +105,23 @@ (ansible_os_family == 'RedHat' and postgresql_version is version('12', '>=')) tags: pgvector +# postgis (if 'enable_postgis' is 'true') +- name: Install postgis package + ansible.builtin.package: + name: >- + {% if ansible_os_family == 'Debian' %} + postgresql-{{ postgresql_version }}-postgis-3 + {% elif ansible_os_family == 'RedHat' and postgresql_version == "16" %} + postgis34_{{ postgresql_version }} + {% else %} + postgis33_{{ postgresql_version }} + {% endif %} + state: present + register: package_status + until: package_status is success + delay: 5 + retries: 3 + when: enable_postgis | default(false) | bool + tags: postgis + ... diff --git a/roles/pre-checks/tasks/extensions.yml b/roles/pre-checks/tasks/extensions.yml index 833055c63..edb2586a3 100644 --- a/roles/pre-checks/tasks/extensions.yml +++ b/roles/pre-checks/tasks/extensions.yml @@ -49,7 +49,7 @@ if item not in shared_preload_libraries_item.value.split(',') else shared_preload_libraries_item.value) ~ (item if item not in shared_preload_libraries_item.value.split(',') else '') }} - loop: "{{ extensions }}" + loop: "{{ extensions | default([]) | unique }}" when: extensions | default([]) | length > 0 ...