- name: "Install pgvector extension postgresql-{{ postgresql_version }}-pgvector"

  tags:
    - install
    - timescaledb_install
  apt:
    pkg:
      - "postgresql-{{ postgresql_version }}-pgvector"
    state: latest
    update_cache: yes

- name: "Stop postgresql service"
  tags:
    - install
    - timescaledb_install
  systemd:
    name: postgresql
    state: stopped

- name: "Start postgresql service"
  tags:
    - install
    - timescaledb_install
  systemd:
    name: postgresql
    state: started

- name: "Create pgvector functions on database {{ timescaledb_database_name }}"
  tags:
    - install
    - timescaledb_install
  postgresql_ext:
    name: vector
    db: "{{ timescaledb_database_name }}"
    state: present
    login_user: "postgres"
    login_password: "{{ postgresql_admin_password }}"
    login_host: "{{ lxc_ip }}"