Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bgmot pg timescaledb #1337

Merged
merged 4 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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