From 714fd72b2cc4bd654778784654feb376d936ac78 Mon Sep 17 00:00:00 2001 From: Vitaliy Kukharik <37010174+vitabaks@users.noreply.github.com> Date: Tue, 17 Sep 2024 16:59:22 +0300 Subject: [PATCH] ParadeDB (pg_search, pg_analytics) (#758) --- automation/molecule/default/converge.yml | 9 + .../roles/packages/tasks/extensions.yml | 226 ++++++++++++----- .../roles/pre-checks/tasks/extensions.yml | 55 ++++- automation/roles/upgrade/tasks/packages.yml | 230 +----------------- 4 files changed, 216 insertions(+), 304 deletions(-) diff --git a/automation/molecule/default/converge.yml b/automation/molecule/default/converge.yml index 98d8ea6ac..364fe814b 100644 --- a/automation/molecule/default/converge.yml +++ b/automation/molecule/default/converge.yml @@ -61,6 +61,15 @@ enable_pg_wait_sampling: true enable_pg_partman: true enable_citus: "{{ 'false' if ansible_distribution_version == '24.04' else 'true' }}" # TODO Ubuntu 24.04 + enable_paradedb: "{{ 'false' if ansible_distribution_release == 'bullseye' else 'true' }}" # pg_search and pg_analytics (no packages for debian 11) + # create extension + postgresql_schemas: + - { schema: "paradedb", db: "postgres", owner: "postgres" } # pg_search must be installed in the paradedb schema. + postgresql_extensions: + - { ext: "vector", db: "postgres" } + - { ext: "pg_search", db: "postgres", schema: "paradedb" } + - { ext: "pg_analytics", db: "postgres" } + # - { ext: "", db: "" } - name: Set variables for PostgreSQL Cluster update test ansible.builtin.set_fact: diff --git a/automation/roles/packages/tasks/extensions.yml b/automation/roles/packages/tasks/extensions.yml index b87d8e576..ab40ee471 100644 --- a/automation/roles/packages/tasks/extensions.yml +++ b/automation/roles/packages/tasks/extensions.yml @@ -9,10 +9,10 @@ loop: "{{ timescaledb_package }}" vars: timescaledb_package: >- - [{% if postgresql_version | int >= 11 %} - "timescaledb-2-postgresql-{{ postgresql_version }}" + [{% if pg_version | default(postgresql_version) | int >= 11 %} + "timescaledb-2-postgresql-{{ pg_version | default(postgresql_version) }}" {% else %} - "timescaledb-postgresql-{{ postgresql_version }}" + "timescaledb-postgresql-{{ pg_version | default(postgresql_version) }}" {% endif %}] register: package_status until: package_status is success @@ -29,16 +29,16 @@ loop: "{{ citus_package }}" vars: citus_package: >- - [{% if ansible_os_family == 'Debian' and postgresql_version | int >= 14 %} - "postgresql-{{ postgresql_version }}-citus-{{ citus_version | default('12.1') }}" - {% elif ansible_os_family == 'Debian' and postgresql_version | int == 13 %} - "postgresql-{{ postgresql_version }}-citus-11.3" - {% elif ansible_os_family == 'Debian' and postgresql_version | int == 12 %} - "postgresql-{{ postgresql_version }}-citus-10.2" - {% elif ansible_os_family == 'Debian' and postgresql_version | int == 11 %} - "postgresql-{{ postgresql_version }}-citus-10.0" + [{% if ansible_os_family == 'Debian' and pg_version | default(postgresql_version) | int >= 14 %} + "postgresql-{{ pg_version | default(postgresql_version) }}-citus-{{ citus_version | default('12.1') }}" + {% elif ansible_os_family == 'Debian' and pg_version | default(postgresql_version) | int == 13 %} + "postgresql-{{ pg_version | default(postgresql_version) }}-citus-11.3" + {% elif ansible_os_family == 'Debian' and pg_version | default(postgresql_version) | int == 12 %} + "postgresql-{{ pg_version | default(postgresql_version) }}-citus-10.2" + {% elif ansible_os_family == 'Debian' and pg_version | default(postgresql_version) | int == 11 %} + "postgresql-{{ pg_version | default(postgresql_version) }}-citus-10.0" {% else %} - "citus_{{ postgresql_version }}" + "citus_{{ pg_version | default(postgresql_version) }}" {% endif %}] register: package_status until: package_status is success @@ -46,8 +46,8 @@ retries: 3 when: - enable_citus | default(false) | bool - - (ansible_os_family == 'Debian' and postgresql_version | int >= 11) or - (ansible_os_family == 'RedHat' and postgresql_version | int >= 12) + - (ansible_os_family == 'Debian' and pg_version | default(postgresql_version) | int >= 11) or + (ansible_os_family == 'RedHat' and pg_version | default(postgresql_version) | int >= 12) tags: citus # pg_repack (if 'enable_pg_repack' is 'true') @@ -58,9 +58,9 @@ vars: pg_repack_package: >- {% if ansible_os_family == 'Debian' %} - postgresql-{{ postgresql_version }}-repack + postgresql-{{ pg_version | default(postgresql_version) }}-repack {% else %} - pg_repack_{{ postgresql_version }} + pg_repack_{{ pg_version | default(postgresql_version) }} {% endif %} register: package_status until: package_status is success @@ -77,9 +77,9 @@ vars: pg_cron_package: >- {% if ansible_os_family == 'Debian' %} - postgresql-{{ postgresql_version }}-cron + postgresql-{{ pg_version | default(postgresql_version) }}-cron {% else %} - pg_cron_{{ postgresql_version }} + pg_cron_{{ pg_version | default(postgresql_version) }} {% endif %} register: package_status until: package_status is success @@ -96,19 +96,19 @@ vars: pgaudit_package: >- {% if ansible_os_family == 'Debian' %} - postgresql-{{ postgresql_version }}-pgaudit - {% elif ansible_os_family == 'RedHat' and postgresql_version | int >= 16 %} - pgaudit_{{ postgresql_version }} - {% elif ansible_os_family == 'RedHat' and postgresql_version | int == 15 %} - pgaudit17_{{ postgresql_version }} - {% elif ansible_os_family == 'RedHat' and postgresql_version | int == 14 %} - pgaudit16_{{ postgresql_version }} - {% elif ansible_os_family == 'RedHat' and postgresql_version | int == 13 %} - pgaudit15_{{ postgresql_version }} - {% elif ansible_os_family == 'RedHat' and postgresql_version | int == 12 %} - pgaudit14_{{ postgresql_version }} - {% elif ansible_os_family == 'RedHat' and postgresql_version | int == 11 %} - pgaudit13_{{ postgresql_version }} + postgresql-{{ pg_version | default(postgresql_version) }}-pgaudit + {% elif ansible_os_family == 'RedHat' and pg_version | default(postgresql_version) | int >= 16 %} + pgaudit_{{ pg_version | default(postgresql_version) }} + {% elif ansible_os_family == 'RedHat' and pg_version | default(postgresql_version) | int == 15 %} + pgaudit17_{{ pg_version | default(postgresql_version) }} + {% elif ansible_os_family == 'RedHat' and pg_version | default(postgresql_version) | int == 14 %} + pgaudit16_{{ pg_version | default(postgresql_version) }} + {% elif ansible_os_family == 'RedHat' and pg_version | default(postgresql_version) | int == 13 %} + pgaudit15_{{ pg_version | default(postgresql_version) }} + {% elif ansible_os_family == 'RedHat' and pg_version | default(postgresql_version) | int == 12 %} + pgaudit14_{{ pg_version | default(postgresql_version) }} + {% elif ansible_os_family == 'RedHat' and pg_version | default(postgresql_version) | int == 11 %} + pgaudit13_{{ pg_version | default(postgresql_version) }} {% endif %} register: package_status until: package_status is success @@ -117,28 +117,6 @@ when: enable_pgaudit | default(false) | bool tags: pgaudit -# pgvector (if 'enable_pgvector' is 'true') -- name: Install pgvector package - ansible.builtin.package: - name: "{{ pgvector_package }}" - state: present - vars: - pgvector_package: >- - {% if ansible_os_family == 'Debian' %} - postgresql-{{ postgresql_version }}-pgvector - {% else %} - pgvector_{{ postgresql_version }} - {% endif %} - register: package_status - until: package_status is success - delay: 5 - retries: 3 - when: - - enable_pgvector | default(false)| bool - - (ansible_os_family == 'Debian' and postgresql_version | int >= 11) or - (ansible_os_family == 'RedHat' and postgresql_version | int >= 12) - tags: pgvector - # postgis (if 'enable_postgis' is 'true') - name: Install postgis package ansible.builtin.package: @@ -147,11 +125,11 @@ vars: postgis_package: >- {% if ansible_os_family == 'Debian' %} - postgresql-{{ postgresql_version }}-postgis-3 - {% elif ansible_os_family == 'RedHat' and postgresql_version | int == 16 %} - postgis34_{{ postgresql_version }} + postgresql-{{ pg_version | default(postgresql_version) }}-postgis-3 + {% elif ansible_os_family == 'RedHat' and pg_version | default(postgresql_version) | int == 16 %} + postgis34_{{ pg_version | default(postgresql_version) }} {% else %} - postgis33_{{ postgresql_version }} + postgis33_{{ pg_version | default(postgresql_version) }} {% endif %} register: package_status until: package_status is success @@ -168,9 +146,9 @@ vars: pgrouting_package: >- {% if ansible_os_family == 'Debian' %} - postgresql-{{ postgresql_version }}-pgrouting + postgresql-{{ pg_version | default(postgresql_version) }}-pgrouting {% else %} - pgrouting_{{ postgresql_version }} + pgrouting_{{ pg_version | default(postgresql_version) }} {% endif %} register: package_status until: package_status is success @@ -188,9 +166,9 @@ vars: pg_stat_kcache_package: >- {% if ansible_os_family == 'Debian' %} - postgresql-{{ postgresql_version }}-pg-stat-kcache + postgresql-{{ pg_version | default(postgresql_version) }}-pg-stat-kcache {% else %} - pg_stat_kcache_{{ postgresql_version }} + pg_stat_kcache_{{ pg_version | default(postgresql_version) }} {% endif %} register: package_status until: package_status is success @@ -207,9 +185,9 @@ vars: pg_wait_sampling_package: >- {% if ansible_os_family == 'Debian' %} - postgresql-{{ postgresql_version }}-pg-wait-sampling + postgresql-{{ pg_version | default(postgresql_version) }}-pg-wait-sampling {% else %} - pg_wait_sampling_{{ postgresql_version }} + pg_wait_sampling_{{ pg_version | default(postgresql_version) }} {% endif %} register: package_status until: package_status is success @@ -226,9 +204,9 @@ vars: pg_partman_package: >- {% if ansible_os_family == 'Debian' %} - postgresql-{{ postgresql_version }}-partman + postgresql-{{ pg_version | default(postgresql_version) }}-partman {% else %} - pg_partman_{{ postgresql_version }} + pg_partman_{{ pg_version | default(postgresql_version) }} {% endif %} register: package_status until: package_status is success @@ -237,4 +215,122 @@ when: enable_pg_partman | default(false) | bool tags: pg_partman +# pgvector (if 'enable_pgvector' or 'enable_paradedb' is 'true') +- name: Install pgvector package + ansible.builtin.package: + name: "{{ pgvector_package }}" + state: present + vars: + pgvector_package: >- + {% if ansible_os_family == 'Debian' %} + postgresql-{{ pg_version | default(postgresql_version) }}-pgvector + {% else %} + pgvector_{{ pg_version | default(postgresql_version) }} + {% endif %} + register: package_status + until: package_status is success + delay: 5 + retries: 3 + when: + - (enable_pgvector | default(false)| bool) or + (enable_paradedb | default(false) | bool) + - (ansible_os_family == 'Debian' and pg_version | default(postgresql_version) | int >= 11) or + (ansible_os_family == 'RedHat' and pg_version | default(postgresql_version) | int >= 12) + tags: pgvector + +# ParadeDB (pg_search, pg_analytics) - https://github.com/paradedb/paradedb +# (if 'enable_paradedb' or 'enable_pg_search', 'enable_pg_analytics' is 'true') +- block: + # pg_search + - block: + - name: Looking up the latest version of pg_search + ansible.builtin.set_fact: + pg_search_version: >- + {{ + (lookup('url', 'https://api.github.com/repos/paradedb/paradedb/releases/latest', split_lines=False) + | from_json).get('tag_name') + | replace('v', '') + }} + when: pg_search_version | default('latest') == 'latest' + + # Debian + - name: "Install pg_search v{{ pg_search_version }} package" + ansible.builtin.apt: + deb: "{{ pg_search_package }}" + register: apt_status + until: apt_status is success + delay: 5 + retries: 3 + vars: + pg_search_repo: "https://github.com/paradedb/paradedb/releases/download/v{{ pg_search_version }}/" + pg_search_package: "{{ pg_search_repo }}/postgresql-{{ pg_version | default(postgresql_version) }}-pg-search_{{ pg_search_version }}-1PARADEDB-{{ ansible_distribution_release }}_amd64.deb" # yamllint disable rule:line-length + when: + - ansible_os_family == "Debian" + - ansible_distribution_release in ['bookworm', 'jammy', 'noble'] + + # RedHat + - name: "Install pg_search v{{ pg_search_version }} package" + ansible.builtin.dnf: + name: "{{ pg_search_package }}" + disable_gpg_check: true + register: dnf_status + until: dnf_status is success + delay: 5 + retries: 3 + vars: + pg_search_repo: "https://github.com/paradedb/paradedb/releases/download/v{{ pg_search_version }}/" + pg_search_package: "{{ pg_search_repo }}/pg_search_{{ pg_version | default(postgresql_version) }}-{{ pg_search_version }}-1PARADEDB.el{{ ansible_distribution_major_version }}.x86_64.rpm" # yamllint disable rule:line-length + when: + - ansible_os_family == "RedHat" + - ansible_distribution_major_version in ['8', '9'] + when: (enable_paradedb | default(false) | bool) or (enable_pg_search | default(false) | bool) + + # pg_analytics + - block: + - name: Looking up the latest version of pg_analytics + ansible.builtin.set_fact: + pg_analytics_version: >- + {{ + (lookup('url', 'https://api.github.com/repos/paradedb/pg_analytics/releases/latest', split_lines=False) + | from_json).get('tag_name') + | replace('v', '') + }} + when: pg_analytics_version | default('latest') == 'latest' + + # Debian + - name: "Install pg_analytics v{{ pg_analytics_version }} package" + ansible.builtin.apt: + deb: "{{ pg_analytics_package }}" + register: apt_status + until: apt_status is success + delay: 5 + retries: 3 + vars: + pg_analytics_repo: "https://github.com/paradedb/pg_analytics/releases/download/v{{ pg_analytics_version }}/" + pg_analytics_package: "{{ pg_analytics_repo }}/postgresql-{{ pg_version | default(postgresql_version) }}-pg-analytics_{{ pg_analytics_version }}-1PARADEDB-{{ ansible_distribution_release }}_amd64.deb" # yamllint disable rule:line-length + when: + - ansible_os_family == "Debian" + - ansible_distribution_release in ['bookworm', 'jammy', 'noble'] + + # RedHat + - name: "Install pg_analytics v{{ pg_analytics_version }} package" + ansible.builtin.dnf: + name: "{{ pg_analytics_package }}" + disable_gpg_check: true + register: dnf_status + until: dnf_status is success + delay: 5 + retries: 3 + vars: + pg_analytics_repo: "https://github.com/paradedb/pg_analytics/releases/download/v{{ pg_analytics_version }}/" + pg_analytics_package: "{{ pg_analytics_repo }}/pg_analytics_{{ pg_version | default(postgresql_version) }}-{{ pg_analytics_version }}-1PARADEDB.el{{ ansible_distribution_major_version }}.x86_64.rpm" # yamllint disable rule:line-length + when: + - ansible_os_family == "RedHat" + - ansible_distribution_major_version in ['8', '9'] + when: (enable_paradedb | default(false) | bool) or (enable_pg_analytics | default(false) | bool) + when: (enable_paradedb | default(false) | bool) or (enable_pg_search | default(false) | bool) or (enable_pg_analytics | default(false) | bool) + tags: paradedb, pg_search, pg_analytics + +# Note: We use the 'pg_version' variable to be able to reuse this code in the upgrade role. + ... diff --git a/automation/roles/pre-checks/tasks/extensions.yml b/automation/roles/pre-checks/tasks/extensions.yml index 14a1a497f..ed684fecf 100644 --- a/automation/roles/pre-checks/tasks/extensions.yml +++ b/automation/roles/pre-checks/tasks/extensions.yml @@ -1,29 +1,58 @@ # yamllint disable rule:line-length --- +# Extension Auto-Setup: pre-checks and shared_preload_libraries -# TimescaleDB pre-check (if 'enable_timescale' is 'true') +# pre-checks - name: TimescaleDB | Checking PostgreSQL version run_once: true ansible.builtin.fail: msg: - "The current PostgreSQL version ({{ postgresql_version }}) is not supported by the TimescaleDB." - - "PostgreSQL version must be {{ timescale_minimal_pg_version }} or higher." - when: postgresql_version|string is version(timescale_minimal_pg_version|string, '<') + - "PostgreSQL version must be {{ timescale_minimal_pg_version | default(12) }} or higher." + when: + - (enable_timescale | default(false) | bool) or (enable_timescaledb | default(false) | bool) + - postgresql_version | string is version(timescale_minimal_pg_version | default(12) | string, '<') -# Extension Auto-Setup: shared_preload_libraries +- name: ParadeDB | Checking PostgreSQL version + run_once: true + ansible.builtin.fail: + msg: + - "The current PostgreSQL version ({{ postgresql_version }}) is not supported by the ParadeDB (pg_search, pg_analytics)." + - "PostgreSQL version must be {{ paradedb_minimal_pg_version | default(14) }} or higher." + when: + - (enable_paradedb | default(false) | bool) or (enable_pg_search | default(false) | bool) or (enable_pg_analytics | default(false) | bool) + - postgresql_version | string is version(paradedb_minimal_pg_version | default(14) | string, '<') + +- name: ParadeDB | Checking supported operating system and version + run_once: true + ansible.builtin.fail: + msg: + - "ParadeDB (pg_search, pg_analytics) is not supported on {{ ansible_distribution }} {{ ansible_distribution_release }}." + - "Supported OS: Debian (bookworm), Ubuntu (jammy, noble) or RedHat (8, 9)." + when: + - (enable_paradedb | default(false) | bool) or (enable_pg_search | default(false) | bool) or (enable_pg_analytics | default(false) | bool) + - not ( + (ansible_os_family == "Debian" and ansible_distribution_release in ['bookworm', 'jammy', 'noble']) or + (ansible_os_family == "RedHat" and ansible_distribution_major_version in ['8', '9']) + ) + +# shared_preload_libraries - name: Create a list of extensions run_once: true ansible.builtin.set_fact: extensions: >- - {{ (extensions | default([])) - + (['timescaledb'] if ((enable_timescale | default(false) | bool) or (enable_timescaledb | default(false) | bool)) and (postgresql_version is version('15', '<=')) else []) - + (['citus'] if (enable_citus | default(false) | bool) and postgresql_version | int >= 11 else []) - + (['pg_cron'] if (enable_pg_cron | default(false) | bool) else []) - + (['pgaudit'] if (enable_pgaudit | default(false) | bool) else []) - + (['pg_stat_statements'] if (enable_pg_stat_kcache | default(false) | bool) else []) - + (['pg_stat_kcache'] if (enable_pg_stat_kcache | default(false) | bool) else []) - + (['pg_wait_sampling'] if (enable_pg_wait_sampling | default(false) | bool) else []) - + (['pg_partman_bgw'] if (enable_pg_partman | default(false) | bool) else []) + {{ + (extensions | default([])) + + (['timescaledb'] if ((enable_timescale | default(false) | bool) or (enable_timescaledb | default(false) | bool)) else []) + + (['citus'] if ((enable_citus | default(false) | bool) and (postgresql_version | int >= 11)) else []) + + (['pg_cron'] if (enable_pg_cron | default(false) | bool) else []) + + (['pgaudit'] if (enable_pgaudit | default(false) | bool) else []) + + (['pg_stat_statements'] if (enable_pg_stat_kcache | default(false) | bool) else []) + + (['pg_stat_kcache'] if (enable_pg_stat_kcache | default(false) | bool) else []) + + (['pg_wait_sampling'] if (enable_pg_wait_sampling | default(false) | bool) else []) + + (['pg_partman_bgw'] if (enable_pg_partman | default(false) | bool) else []) + + (['pg_search'] if ((enable_paradedb | default(false) | bool) or (enable_pg_search | default(false) | bool)) else []) + + (['pg_analytics'] if ((enable_paradedb | default(false) | bool) or (enable_pg_analytics | default(false) | bool)) else []) }} - name: Add required extensions to 'shared_preload_libraries' (if missing) diff --git a/automation/roles/upgrade/tasks/packages.yml b/automation/roles/upgrade/tasks/packages.yml index b541210cb..2e302d06d 100644 --- a/automation/roles/upgrade/tasks/packages.yml +++ b/automation/roles/upgrade/tasks/packages.yml @@ -33,232 +33,10 @@ delay: 5 retries: 3 -# Extension Auto-Setup: new packages -#################################### - -# TimescaleDB (if 'enable_timescale' is 'true') -- name: "Install TimescaleDB package for PostgreSQL {{ pg_new_version }}" - ansible.builtin.package: - name: "{{ item }}" - state: latest - loop: "{{ timescaledb_package }}" - vars: - timescaledb_package: >- - [{% if pg_new_version | int >= 11 %} - "timescaledb-2-postgresql-{{ pg_new_version }}" - {% else %} - "timescaledb-postgresql-{{ pg_new_version }}" - {% endif %}] - register: package_status - until: package_status is success - delay: 5 - retries: 3 - when: (enable_timescale | default(false) | bool) or (enable_timescaledb | default(false) | bool) - -# Citus (if 'enable_citus' is 'true') -- name: "Install Citus package for PostgreSQL {{ pg_new_version }}" - ansible.builtin.package: - name: "{{ item }}" - state: latest - loop: "{{ citus_package }}" - vars: - citus_package: >- - [{% if ansible_os_family == 'Debian' and pg_new_version | int >= 14 %} - "postgresql-{{ pg_new_version }}-citus-{{ citus_version | default('12.1') }}" - {% elif ansible_os_family == 'Debian' and pg_new_version | int == 13 %} - "postgresql-{{ pg_new_version }}-citus-11.3" - {% elif ansible_os_family == 'Debian' and pg_new_version | int == 12 %} - "postgresql-{{ pg_new_version }}-citus-10.2" - {% elif ansible_os_family == 'Debian' and pg_new_version | int == 11 %} - "postgresql-{{ pg_new_version }}-citus-10.0" - {% else %} - "citus_{{ pg_new_version }}" - {% endif %}] - register: package_status - until: package_status is success - delay: 5 - retries: 3 - when: - - enable_citus | default(false) | bool - - (ansible_os_family == 'Debian' and pg_new_version | int >= 11) or - (ansible_os_family == 'RedHat' and pg_new_version | int >= 12) - -# pg_repack (if 'enable_pg_repack' is 'true') -- name: "Install pg_repack package for PostgreSQL {{ pg_new_version }}" - ansible.builtin.package: - name: "{{ pg_repack_package }}" - state: latest - vars: - pg_repack_package: >- - {% if ansible_os_family == 'Debian' %} - postgresql-{{ pg_new_version }}-repack - {% else %} - pg_repack_{{ pg_new_version }} - {% endif %} - register: package_status - until: package_status is success - delay: 5 - retries: 3 - when: enable_pg_repack | default(false) | bool - -# pg_cron (if 'enable_pg_cron' is 'true') -- name: "Install pg_cron package for PostgreSQL {{ pg_new_version }}" - ansible.builtin.package: - name: "{{ pg_cron_package }}" - state: latest - vars: - pg_cron_package: >- - {% if ansible_os_family == 'Debian' %} - postgresql-{{ pg_new_version }}-cron - {% else %} - pg_cron_{{ pg_new_version }} - {% endif %} - register: package_status - until: package_status is success - delay: 5 - retries: 3 - when: enable_pg_cron | default(false) | bool - -# pgaudit (if 'enable_pgaudit' is 'true') -- name: "Install pgaudit package for PostgreSQL {{ pg_new_version }}" - ansible.builtin.package: - name: "{{ pgaudit_package }}" - state: latest - vars: - pgaudit_package: >- - {% if ansible_os_family == 'Debian' %} - postgresql-{{ pg_new_version }}-pgaudit - {% elif ansible_os_family == 'RedHat' and pg_new_version | int >= 16 %} - pgaudit_{{ pg_new_version }} - {% elif ansible_os_family == 'RedHat' and pg_new_version | int == 15 %} - pgaudit17_{{ pg_new_version }} - {% elif ansible_os_family == 'RedHat' and pg_new_version | int == 14 %} - pgaudit16_{{ pg_new_version }} - {% elif ansible_os_family == 'RedHat' and pg_new_version | int == 13 %} - pgaudit15_{{ pg_new_version }} - {% elif ansible_os_family == 'RedHat' and pg_new_version | int == 12 %} - pgaudit14_{{ pg_new_version }} - {% elif ansible_os_family == 'RedHat' and pg_new_version | int == 11 %} - pgaudit13_{{ pg_new_version }} - {% endif %} - register: package_status - until: package_status is success - delay: 5 - retries: 3 - when: enable_pgaudit | default(false) | bool - -# pgvector (if 'enable_pgvector' is 'true') -- name: "Install pgvector package for PostgreSQL {{ pg_new_version }}" - ansible.builtin.package: - name: "{{ pgvector_package }}" - state: latest +# Install Extensions packages +- name: "Install Extensions packages for PostgreSQL {{ pg_new_version }}" + ansible.builtin.import_tasks: "../../packages/tasks/extensions.yml" vars: - pgvector_package: >- - {% if ansible_os_family == 'Debian' %} - postgresql-{{ pg_new_version }}-pgvector - {% else %} - pgvector_{{ pg_new_version }} - {% endif %} - register: package_status - until: package_status is success - delay: 5 - retries: 3 - when: - - enable_pgvector | default(false)| bool - - (ansible_os_family == 'Debian' and pg_new_version | int >= 11) or - (ansible_os_family == 'RedHat' and pg_new_version | int >= 12) - -# postgis (if 'enable_postgis' is 'true') -- name: "Install postgis package for PostgreSQL {{ pg_new_version }}" - ansible.builtin.package: - name: "{{ postgis_package }}" - state: latest - vars: - postgis_package: >- - {% if ansible_os_family == 'Debian' %} - postgresql-{{ pg_new_version }}-postgis-3 - {% elif ansible_os_family == 'RedHat' and pg_new_version | int == 16 %} - postgis34_{{ pg_new_version }} - {% else %} - postgis33_{{ pg_new_version }} - {% endif %} - register: package_status - until: package_status is success - delay: 5 - retries: 3 - when: enable_postgis | default(false) | bool - -# pgrouting (if 'enable_pgrouting' is 'true') -- name: "Install pgrouting package for PostgreSQL {{ pg_new_version }}" - ansible.builtin.package: - name: "{{ pgrouting_package }}" - state: latest - vars: - pgrouting_package: >- - {% if ansible_os_family == 'Debian' %} - postgresql-{{ pg_new_version }}-pgrouting - {% else %} - pgrouting_{{ pg_new_version }} - {% endif %} - register: package_status - until: package_status is success - delay: 5 - retries: 3 - when: enable_pgrouting | default(false) | bool and - not (ansible_distribution == 'Ubuntu' and ansible_distribution_version is version('20.04', '<=')) - -# pg_stat_kcache (if 'enable_pg_stat_kcache' is 'true') -- name: "Install pg_stat_kcache package for PostgreSQL {{ pg_new_version }}" - ansible.builtin.package: - name: "{{ pg_stat_kcache_package }}" - state: latest - vars: - pg_stat_kcache_package: >- - {% if ansible_os_family == 'Debian' %} - postgresql-{{ pg_new_version }}-pg-stat-kcache - {% else %} - pg_stat_kcache_{{ pg_new_version }} - {% endif %} - register: package_status - until: package_status is success - delay: 5 - retries: 3 - when: enable_pg_stat_kcache | default(false) | bool - -# pg_wait_sampling (if 'enable_pg_wait_sampling' is 'true') -- name: "Install pg_wait_sampling package for PostgreSQL {{ pg_new_version }}" - ansible.builtin.package: - name: "{{ pg_wait_sampling_package }}" - state: latest - vars: - pg_wait_sampling_package: >- - {% if ansible_os_family == 'Debian' %} - postgresql-{{ pg_new_version }}-pg-wait-sampling - {% else %} - pg_wait_sampling_{{ pg_new_version }} - {% endif %} - register: package_status - until: package_status is success - delay: 5 - retries: 3 - when: enable_pg_wait_sampling | default(false) | bool - -# pg_partman (if 'enable_pg_partman' is 'true') -- name: "Install pg_partman package for PostgreSQL {{ pg_new_version }}" - ansible.builtin.package: - name: "{{ pg_partman_package }}" - state: latest - vars: - pg_partman_package: >- - {% if ansible_os_family == 'Debian' %} - postgresql-{{ pg_new_version }}-partman - {% else %} - pg_partman_{{ pg_new_version }} - {% endif %} - register: package_status - until: package_status is success - delay: 5 - retries: 3 - when: enable_pg_partman | default(false) | bool + pg_version: "{{ pg_new_version }}" ...