Skip to content

Commit

Permalink
Bgmot pg timescaledb (#1337)
Browse files Browse the repository at this point in the history
* Use timescaledb for zabbix-server PostgreSQL molecule tests.

* zabbix_server role: fix creating TimescaleDB hypertables for Zabbix 7.0.

* CHANGELOG fragment added.

* Fix sanity tests.
  • Loading branch information
BGmot authored Jul 10, 2024
1 parent 4ec313e commit 58234c6
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
3 changes: 3 additions & 0 deletions changelogs/fragments/timescaledb70.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
bugfixes:
- zabbix_server role - fixed creating TimescaleDB hypertables for Zabbix 7.0
2 changes: 1 addition & 1 deletion molecule/default/create.docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@
image: "mysql:8.0"
env: { MYSQL_ROOT_PASSWORD: changeme }
pgsql:
image: "postgres:13"
image: "timescale/timescaledb:latest-pg13"
env: { POSTGRES_PASSWORD: changeme }
1 change: 1 addition & 0 deletions molecule/zabbix_server/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ provisioner:
zabbix_server_pgsql_login_user: postgres
zabbix_server_pgsql_login_password: changeme
zabbix_server_pgsql_login_port: 5432
zabbix_server_database_timescaledb: true

verifier:
name: testinfra
25 changes: 24 additions & 1 deletion roles/zabbix_server/tasks/initialize-pgsql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
state: restore
target: /usr/share/zabbix-sql-scripts/postgresql/server.sql.gz

- name: "PostgreSQL | Create TimescaleDB hypertables"
- name: "PostgreSQL | Create TimescaleDB hypertables Zabbix < 7.0"
ansible.builtin.shell: |
set -euxo pipefail
cd /usr/share/zabbix-sql-scripts/postgresql &&
Expand All @@ -110,5 +110,28 @@
become: true
when:
- zabbix_server_database_timescaledb
- zabbix_server_version is version( '7.0', '<')
tags:
- database

- name: "PostgreSQL | Create TimescaleDB hypertables Zabbix >= 7.0"
ansible.builtin.shell: |
set -euxo pipefail
cd /usr/share/zabbix-sql-scripts/postgresql/timescaledb &&
cat schema.sql | psql -h '{{ zabbix_server_dbhost }}' \
-U '{{ zabbix_server_dbuser }}' \
-d '{{ zabbix_server_dbname }}' \
-p '{{ zabbix_server_dbport }}'
touch /etc/zabbix/timescaledb.done
rm -f /tmp/timescaledb.sql
args:
creates: /etc/zabbix/timescaledb.done
executable: /bin/bash
environment:
PGPASSWORD: "{{ zabbix_server_dbpassword }}"
become: true
when:
- zabbix_server_database_timescaledb
- zabbix_server_version is version( '7.0', '>=')
tags:
- database

0 comments on commit 58234c6

Please sign in to comment.