Skip to content

Commit

Permalink
Add pgvectorscale extension (#762)
Browse files Browse the repository at this point in the history
  • Loading branch information
vitabaks authored Sep 19, 2024
1 parent 278ba61 commit 4619568
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 0 deletions.
2 changes: 2 additions & 0 deletions automation/molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,13 @@
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)
enable_pgvectorscale: "{{ 'true' if ansible_distribution_release in ['bookworm', 'jammy', 'noble'] else 'false' }}" # only deb packages are available
# 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: "vectorscale", db: "postgres" }
- { ext: "pg_search", db: "postgres", schema: "paradedb" }
- { ext: "pg_analytics", db: "postgres" }
# - { ext: "", db: "" }
Expand Down
44 changes: 44 additions & 0 deletions automation/roles/packages/tasks/extensions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,55 @@
retries: 3
when:
- (enable_pgvector | default(false)| bool) or
(enable_pgvectorscale | 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

# pgvectorscale - https://github.com/timescale/pgvectorscale
# (if 'enable_pgvectorscale' is 'true')
- block:
- name: Looking up the latest version of pgvectorscale
ansible.builtin.set_fact:
pgvectorscale_version: >-
{{
(lookup('url', 'https://api.github.com/repos/timescale/pgvectorscale/releases/latest', split_lines=False)
| from_json).get('tag_name')
| replace('v', '')
}}
when: pgvectorscale_version | default('latest') == 'latest'

- name: Download pgvectorscale archive
ansible.builtin.get_url:
url: "{{ pgvectorscale_repo }}/{{ pgvectorscale_archive }}"
dest: "/tmp/{{ pgvectorscale_archive }}"
timeout: 60
validate_certs: false

- name: Extract pgvectorscale package
ansible.builtin.unarchive:
src: "/tmp/{{ pgvectorscale_archive }}"
dest: "/tmp/"
remote_src: true

# Debian (only deb packages are available)
- name: "Install pgvectorscale v{{ pgvectorscale_version }} package"
ansible.builtin.apt:
deb: "/tmp/{{ pgvectorscale_package }}"
register: apt_status
until: apt_status is success
delay: 5
retries: 3
vars:
pgvectorscale_repo: "https://github.com/timescale/pgvectorscale/releases/download/{{ pgvectorscale_version }}"
pgvectorscale_archive: "pgvectorscale-{{ pgvectorscale_version }}-pg{{ pg_version | default(postgresql_version) }}-amd64.zip" # yamllint disable rule:line-length
pgvectorscale_package: "pgvectorscale-postgresql-{{ pg_version | default(postgresql_version) }}_{{ pgvectorscale_version }}-Linux_amd64.deb" # yamllint disable rule:line-length
when:
- enable_pgvectorscale | default(false) | bool
- ansible_os_family == "Debian"
- ansible_distribution_release in ['bookworm', 'jammy', 'noble']

# ParadeDB (pg_search, pg_analytics) - https://github.com/paradedb/paradedb
# (if 'enable_paradedb' or 'enable_pg_search', 'enable_pg_analytics' is 'true')
- block:
Expand Down
20 changes: 20 additions & 0 deletions automation/roles/pre-checks/tasks/extensions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,26 @@
- (enable_timescale | default(false) | bool) or (enable_timescaledb | default(false) | bool)
- postgresql_version | string is version(timescale_minimal_pg_version | default(12) | string, '<')

- name: Timescale (pgvectorscale) | Checking PostgreSQL version
run_once: true
ansible.builtin.fail:
msg:
- "The current PostgreSQL version ({{ postgresql_version }}) is not supported by the pgvectorscale."
- "PostgreSQL version must be {{ pgvectorscale_minimal_pg_version | default(15) }} or higher."
when:
- enable_pgvectorscale | default(false) | bool
- postgresql_version | string is version(pgvectorscale_minimal_pg_version | default(15) | string, '<')

- name: Timescale (pgvectorscale) | Checking supported operating system and version
run_once: true
ansible.builtin.fail:
msg:
- "pgvectorscale is not supported on {{ ansible_distribution }} {{ ansible_distribution_release }}."
- "Supported OS: Debian (bookworm), Ubuntu (jammy, noble)."
when:
- enable_pgvectorscale | default(false) | bool
- not (ansible_os_family == "Debian" and ansible_distribution_release in ['bookworm', 'jammy', 'noble'])

- name: ParadeDB | Checking PostgreSQL version
run_once: true
ansible.builtin.fail:
Expand Down
3 changes: 3 additions & 0 deletions automation/vars/Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ system_packages:
- acl
- dnsutils
- moreutils
- unzip
- tar
- zstd

install_perf: false # or 'true' to install "perf" (Linux profiling with performance counters) and "FlameGraph".

Expand Down
3 changes: 3 additions & 0 deletions automation/vars/RedHat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ system_packages:
- acl
- bind-utils
- moreutils
- unzip
- tar
- zstd

install_perf: false # or 'true' to install "perf" (Linux profiling with performance counters) and "FlameGraph".

Expand Down

0 comments on commit 4619568

Please sign in to comment.