Skip to content

Commit

Permalink
Extension Auto-Setup: postgis
Browse files Browse the repository at this point in the history
  • Loading branch information
vitabaks committed Oct 8, 2023
1 parent 73cc874 commit 54b8fea
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
1 change: 1 addition & 0 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
27 changes: 23 additions & 4 deletions roles/packages/tasks/extensions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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
Expand All @@ -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

Expand All @@ -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
Expand All @@ -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

...
2 changes: 1 addition & 1 deletion roles/pre-checks/tasks/extensions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

...

0 comments on commit 54b8fea

Please sign in to comment.