Skip to content

Commit

Permalink
Run Timescale schema during an upgrade
Browse files Browse the repository at this point in the history
In the case that timescale has already been enabled, and we're
upgrading from 6.x to 7.x, the auditlog should also get converted.
(Which it was not in the 6.x schemas)
  • Loading branch information
eb4x committed Jul 18, 2024
1 parent 5c4909d commit fab5893
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion roles/zabbix_server/tasks/initialize-pgsql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,20 @@
query: "SELECT db_extension FROM config WHERE db_extension = 'timescaledb'"
register: _config_db_extension

# NOTE: Zabbix 7.0 adds a hypertable for auditlog.
- name: "PostgreSQL | Check for auditlog hypertable"
community.postgresql.postgresql_query:
login_user: "{{ zabbix_server_dbuser }}"
login_password: "{{ zabbix_server_dbpassword }}"
login_host: "{{ zabbix_server_dbhost }}"
port: "{{ zabbix_server_dbport }}"
db: "{{ zabbix_server_dbname }}"
query: "SELECT hypertable_name FROM timescaledb_information.hypertables WHERE hypertable_name = 'auditlog'"
register: _hypertable_auditlog

- name: "PostgreSQL | Create TimescaleDB hypertables"
when: (_config_db_extension.query_result | length == 0)
when: (_config_db_extension.query_result | length == 0) or
(zabbix_server_version is version('7.0', '>=') and _hypertable_auditlog.query_result | length == 0)
community.postgresql.postgresql_db:
login_user: "{{ zabbix_server_dbuser }}"
login_password: "{{ zabbix_server_dbpassword }}"
Expand Down

0 comments on commit fab5893

Please sign in to comment.