ansible-collections / community.zabbix

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

zabbix_proxy fails to load SQL on Ubuntu 20.04 LTS #474

Closed apiening closed 2 years ago

apiening commented 3 years ago
SUMMARY

The task [community.zabbix.zabbix_proxy : Get the file for schema.sql] fails on Ubuntu 20.04 LTS. The schema could not be selected from /usr/share/doc/zabbix-proxy-mysql because it is at another location. From what I see in the task, it should be sufficient to set the variable datafiles_path to /usr/share/doc/zabbix-sql-scripts/mysql.

ISSUE TYPE
COMPONENT NAME

community.zabbix.zabbix_proxy : Get the file for schema.sql

ANSIBLE VERSION
ansible [core 2.11.5]
  config file = /myhome/.ansible.cfg
  configured module search path = ['/myhome/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/Cellar/ansible/4.6.0/libexec/lib/python3.9/site-packages/ansible
  ansible collection location = /myhome/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.9.7 (default, Sep  3 2021, 12:37:55) [Clang 12.0.5 (clang-1205.0.22.9)]
  jinja version = 3.0.1
  libyaml = True
OS / ENVIRONMENT / Zabbix Version

zabbix_proxy_version: 5.2 zabbix_proxy_database: mysql zabbix_proxy_database_long: mysql

STEPS TO REPRODUCE

Apply the role to a Ubuntu 20.04 LTS system with the vars given in the section above.

Example playbook:

---
- hosts: all
  collections:
    - community.zabbix
  tasks:
    - name: Install Zabbix proxy
      import_role:
        name: zabbix_proxy
EXPECTED RESULTS

SQL schema from /usr/share/doc/zabbix-sql-scripts/mysql should be selected and loaded into the DB.

ACTUAL RESULTS
fatal: [testhost.local]: FAILED! => changed=false
  cmd: ls -1 /usr/share/doc/zabbix-proxy-mysql/schema.sq*
  delta: '0:00:00.001849'
  end: '2021-10-04 18:43:29.022441'
  msg: non-zero return code
  rc: 2
  start: '2021-10-04 18:43:29.020592'
  stderr: 'ls: cannot access ''/usr/share/doc/zabbix-proxy-mysql/schema.sq*'': No such file or directory'
  stderr_lines: <omitted>
  stdout: ''
  stdout_lines: <omitted>
miettal commented 3 years ago

it seems schema.sql path was changed in 5.2 from /usr/share/doc/zabbix-proxy-mysql to /usr/share/doc/zabbix-sql-scripts/mysql

but actual code is judging "grater than 5.4" or not. I think this is mistake, its have to be ↓

diff --git a/roles/zabbix_proxy/tasks/Debian.yml b/roles/zabbix_proxy/tasks/Debian.yml
index e84b8aa..447b6dd 100644
--- a/roles/zabbix_proxy/tasks/Debian.yml
+++ b/roles/zabbix_proxy/tasks/Debian.yml
@@ -20,23 +20,23 @@
     - init
     - config

-- name: "Debian | Set some facts for Zabbix >= 3.0 && < 5.4"
+- name: "Debian | Set some facts for Zabbix >= 3.0 && < 5.2"
   set_fact:
     apache_log: apache2
     datafiles_path: /usr/share/doc/zabbix-proxy-{{ zabbix_proxy_database }}
   when:
     - zabbix_version is version('3.0', '>=')
-    - zabbix_version is version('5.4', '<')
+    - zabbix_version is version('5.2', '<')
   tags:
     - zabbix-proxy
     - init
     - config

-- name: "Debian | Set some facts for Zabbix >= 5.4"
+- name: "Debian | Set some facts for Zabbix >= 5.2"
   set_fact:
     datafiles_path: /usr/share/doc/zabbix-sql-scripts/{{ zabbix_proxy_database_long }}
   when:
-    - zabbix_version is version('5.4', '>=')
+    - zabbix_version is version('5.2', '>=')
   tags:
     - zabbix-server
     - init
neogan74 commented 3 years ago

Yes it seems so. Last findings perfectly correct.

apiening commented 3 years ago

Thank you very much for your investigation.

I also tried to dig a little bit into this and I found that I had the zabbix-proxy 5.4 package installed. And I think that happened because the variable zabbix_proxy_version: 5.2 was not set on my first run because of a typo in my host_vars file. When the playbook was applied again, the zabbix proxy installation was not downgraded to version 5.2 which is reasonable to me.

Then I removed the zabbix-proxy package from the system (it was a clean install anyway) and applied the playbook with the given variables again. This time it worked without any issues.

I'm afraid I ran into this issue just because the package was installed with a newer version.

One idea regarding this is to get the version of the installed zabbix-proxy package as a fact and use this to build the SQL path instead of depending on the variable.

miettal commented 3 years ago

Then I removed the zabbix-proxy package from the system (it was a clean install anyway) and applied the playbook with the given variables again. This time it worked without any issues.

it was good!

it seems schema.sql path was changed in 5.2 from /usr/share/doc/zabbix-proxy-mysql to /usr/share/doc/zabbix-sql-scripts/mysql

Sorry, this is a misunderstanding.

dj-wasabi commented 2 years ago

Closes this issue as this was not related to the code.