diff --git a/inventory/hosts.yml b/inventory/hosts.yml index 32f7c04..1ddda98 100644 --- a/inventory/hosts.yml +++ b/inventory/hosts.yml @@ -16,6 +16,8 @@ all: ansible_host: 192.168.180.190 timescaledb: ansible_host: 192.168.150.130 + vectordb: + ansible_host: 192.168.150.131 harvester: ansible_host: 192.168.150.175 n8n: diff --git a/playbooks/captica-automation-vector-database.yml b/playbooks/captica-automation-vector-database.yml new file mode 100644 index 0000000..46972e5 --- /dev/null +++ b/playbooks/captica-automation-vector-database.yml @@ -0,0 +1,78 @@ +- hosts: "leh01" + name: Create container + vars: + lxc_id: 130 + lxc_name: vectordb + lxc_domain: leh01.local + lxc_template: "local:vztmpl/debian-12-standard_12.2-1_amd64.tar.zst" + lxc_mac: CC:CC:CC:15:01:31 + lxc_ip: 192.168.150.131 + lxc_bridge: vmbr150 + lxc_vlan: "" + lxc_disk: datapool:32 + lxc_cpu: 2 + lxc_memory: 2048 + lxc_swap: 1024 + lxc_ssh_pub_key: ~/.ssh/id_ed25519_ansible.pub + roles: + - lxc-container + +- hosts: "vectordb" + vars: + hostname: vectordb + lxc_ip: 192.168.150.131 + tools_install_users: + - root + - ansible + ssh_pubkeys_root: + - "../files/ssh/root.pub" + ssh_pubkeys_ansible: + - "../files/ssh/id_ed25519_ansible.pub" + roles: + - linux-base-install + - zsh + - vim + - fzf + +- hosts: "vectordb" + vars: + hostname: vectordb + lxc_ip: 192.168.150.131 + tools_install_users: + - root + - ansible + tasks: + - import_tasks: "../roles/common/tasks/common.yml" + +- hosts: "vectordb" + vars: + lxc_ip: 192.168.150.131 + postgresql_admin_password: captica + postgresql_allowed_hosts: + - '0.0.0.0/0' + timescaledb_database_name: vectordb + timescaledb_database_schema: captica + timescaledb_database_user: captica + timescaledb_database_password: captica + tools_install_users: + - ansible + - root + roles: + - timescaledb + +- hosts: "vectordb" + vars: + lxc_ip: 192.168.150.131 + postgresql_version: 16 + postgresql_admin_password: captica + postgresql_allowed_hosts: + - '0.0.0.0/0' + timescaledb_database_name: vectordb + timescaledb_database_schema: captica + timescaledb_database_user: captica + timescaledb_database_password: captica + tools_install_users: + - ansible + - root + tasks: + - import_tasks: "../roles/common/tasks/postgres_vector.yml" \ No newline at end of file diff --git a/roles/common/tasks/postgres_vector.yml b/roles/common/tasks/postgres_vector.yml new file mode 100644 index 0000000..f130048 --- /dev/null +++ b/roles/common/tasks/postgres_vector.yml @@ -0,0 +1,38 @@ +- 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: pgvector + db: "{{ timescaledb_database_name }}" + state: present + login_user: "postgres" + login_password: "{{ postgresql_admin_password }}" + login_host: "{{ lxc_ip }}" \ No newline at end of file