Skip to content

Commit

Permalink
ParadeDB (pg_search, pg_analytics) (#758)
Browse files Browse the repository at this point in the history
  • Loading branch information
vitabaks authored Sep 17, 2024
1 parent 4290fe6 commit 714fd72
Show file tree
Hide file tree
Showing 4 changed files with 216 additions and 304 deletions.
9 changes: 9 additions & 0 deletions automation/molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
226 changes: 161 additions & 65 deletions automation/roles/packages/tasks/extensions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -29,25 +29,25 @@
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
delay: 5
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')
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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.

...
Loading

0 comments on commit 714fd72

Please sign in to comment.