ansible-collections / community.zabbix

Zabbix Ansible modules
http://galaxy.ansible.com/community/zabbix
Other
329 stars 285 forks source link

community.zabbix.zabbix_server: Error in "PostgreSQL | Create TimescaleDB hypertables" task in zabbix 7.0 #1331

Closed oit933 closed 4 months ago

oit933 commented 4 months ago
SUMMARY

I create a new zabbix-server 7.0 with timescaledb. I think the error is due to the fact that in zabbix 7.0 the path to the timescaledb database schema has changed:

# ls -l /usr/share/zabbix-sql-scripts/postgresql:
drwxr-xr-x 2 root root       3 Jul  2 12:18 option-patches
-rw-r--r-- 1 root root  211730 Jun  3 05:55 proxy.sql
-rw-r--r-- 1 root root 4086457 Jun  3 05:55 server.sql.gz
drwxr-xr-x 3 root root       4 Jul  2 12:18 timescaledb

# ls -l /usr/share/zabbix-sql-scripts/postgresql/timescaledb:
drwxr-xr-x 4 root root    4 Jul  2 12:18 option-patches
-rw-r--r-- 1 root root 4867 Jun  3 05:54 schema.sql
ISSUE TYPE
COMPONENT NAME

community.zabbix.zabbix_server

ANSIBLE VERSION
ansible [core 2.16.7]
  config file = /home/user/ansible/environments/production/ansible.cfg
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/user/.local/lib/python3.12/site-packages/ansible
  ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/user/.local/bin/ansible
  python version = 3.12.3 (main, Apr 23 2024, 09:16:07) [GCC 13.2.1 20240417] (/usr/bin/python3)
  jinja version = 3.1.3
  libyaml = True
CONFIGURATION
ANSIBLE_FORCE_COLOR(/home/user/ansible/environments/production/ansible.cfg) = True
ANSIBLE_PIPELINING(/home/user/ansible/environments/production/ansible.cfg) = True
CALLBACKS_ENABLED(/home/user/ansible/environments/production/ansible.cfg) = ['ansible.posix.profile_tasks']
CONFIG_FILE() = /home/user/ansible/environments/production/ansible.cfg
DEFAULT_FILTER_PLUGIN_PATH(/home/user/ansible/environments/production/ansible.cfg) = ['/home/user/ansible/plugins/filter']
DEFAULT_FORCE_HANDLERS(/home/user/ansible/environments/production/ansible.cfg) = True
DEFAULT_GATHERING(/home/user/ansible/environments/production/ansible.cfg) = smart
DEFAULT_HASH_BEHAVIOUR(/home/user/ansible/environments/production/ansible.cfg) = merge
DEFAULT_MANAGED_STR(/home/user/ansible/environments/production/ansible.cfg) = This file is managed by Ansible.%n
template: {file}
from: {uid}@{host}
DEFAULT_REMOTE_USER(/home/user/ansible/environments/production/ansible.cfg) = root
DEFAULT_ROLES_PATH(/home/user/ansible/environments/production/ansible.cfg) = ['/home/user/ansible/roles']
DEFAULT_STDOUT_CALLBACK(/home/user/ansible/environments/production/ansible.cfg) = yaml
DEFAULT_VAULT_ID_MATCH(/home/user/ansible/environments/production/ansible.cfg) = true
DEFAULT_VAULT_PASSWORD_FILE(/home/user/ansible/environments/production/ansible.cfg) = /home/user/ansible/vault_password
INJECT_FACTS_AS_VARS(/home/user/ansible/environments/production/ansible.cfg) = True
INTERPRETER_PYTHON(/home/user/ansible/environments/production/ansible.cfg) = /usr/bin/python3
OS / ENVIRONMENT / Zabbix Version

debian 12 / community.zabbix=3.0.2 / Zabbix-Server 7.0.0 / postgresql 16.3 / timescaledb 2.14.2

STEPS TO REPRODUCE
- hosts: zabbix-server
  vars:
    ansible_httpapi_port: 443
    ansible_httpapi_use_ssl: true
    ansible_httpapi_validate_certs: false
    ansible_zabbix_url_path: ""
  roles:
    - role: community.zabbix.zabbix_server
      vars:
        zabbix_server_database: pgsql
        zabbix_server_database_long: postgresql
        zabbix_server_dbhost: "192.168.5.20"
        zabbix_server_dbname: zabbix
        zabbix_server_dbuser: zabbix
        zabbix_server_dbpassword: zabbix
        zabbix_server_dbport: 5432
        zabbix_server_dbpassword_hash_method: scram-sha-256
        zabbix_server_database_creation: false
        zabbix_server_install_database_client: true
        zabbix_server_database_sqlload: true
        zabbix_server_database_timescaledb: true
EXPECTED RESULTS

The role has been successfully applied

ACTUAL RESULTS
fatal: [zabbix-server]: FAILED! => changed=true 
  cmd: |-
    set -euxo pipefail
    cd /usr/share/zabbix-sql-scripts/postgresql &&
    if [ -f timescaledb.sql.gz ]; then zcat timescaledb.sql.gz > /etc/timescaledb.sql ; else cp -p timescaledb.sql /etc/timescaledb.sql ; fi
    cat /etc/timescaledb.sql | psql -h '192.168.5.20' -U 'zabbix' -d 'zabbix' -p '5432'
    touch /etc/zabbix/timescaledb.done
    rm -f /tmp/timescaledb.sql
  delta: '0:00:00.037601'
  end: '2024-07-08 07:46:17.181483'
  msg: non-zero return code
  rc: 1
  start: '2024-07-08 07:46:17.143882'
  stderr: |-
    + cd /usr/share/zabbix-sql-scripts/postgresql
    + '[' -f timescaledb.sql.gz ']'
    + cp -p timescaledb.sql /etc/timescaledb.sql
    cp: cannot stat 'timescaledb.sql': No such file or directory
  stderr_lines: <omitted>
  stdout: ''
  stdout_lines: <omitted>
BGmot commented 4 months ago

Did you install timescaledb package manually?

oit933 commented 4 months ago

Yes, I installed postgresql and timescaledb according to the documentation: https://docs.timescale.com/self-hosted/latest/install/installation-linux/