diff --git a/changelogs/fragments/timescaledb70.yml b/changelogs/fragments/timescaledb70.yml new file mode 100644 index 000000000..60c57a7bc --- /dev/null +++ b/changelogs/fragments/timescaledb70.yml @@ -0,0 +1,3 @@ +--- +bugfixes: + - zabbix_server role - fixed creating TimescaleDB hypertables for Zabbix 7.0 diff --git a/molecule/default/create.docker.yml b/molecule/default/create.docker.yml index 19bf77729..142c30277 100644 --- a/molecule/default/create.docker.yml +++ b/molecule/default/create.docker.yml @@ -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 } diff --git a/molecule/zabbix_server/molecule.yml b/molecule/zabbix_server/molecule.yml index 7cb4b2890..d790ad99a 100644 --- a/molecule/zabbix_server/molecule.yml +++ b/molecule/zabbix_server/molecule.yml @@ -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 diff --git a/roles/zabbix_server/tasks/initialize-pgsql.yml b/roles/zabbix_server/tasks/initialize-pgsql.yml index 3cd807812..8c42afd75 100644 --- a/roles/zabbix_server/tasks/initialize-pgsql.yml +++ b/roles/zabbix_server/tasks/initialize-pgsql.yml @@ -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 && @@ -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