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

Update to zabbix 50 #131

Merged
merged 10 commits into from
Jul 26, 2020
Merged

Conversation

dj-wasabi
Copy link
Contributor

SUMMARY

Update to zabbix 50

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME
ADDITIONAL INFORMATION

@dj-wasabi dj-wasabi marked this pull request as draft July 14, 2020 19:27
@codecov
Copy link

codecov bot commented Jul 14, 2020

Codecov Report

Merging #131 into master will increase coverage by 0.59%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #131      +/-   ##
==========================================
+ Coverage   78.66%   79.25%   +0.59%     
==========================================
  Files          18       18              
  Lines        2737     2594     -143     
  Branches      624      618       -6     
==========================================
- Hits         2153     2056      -97     
+ Misses        396      357      -39     
+ Partials      188      181       -7     
Impacted Files Coverage Δ
...ions/community/zabbix/plugins/module_utils/base.py 81.81% <0.00%> (-3.90%) ⬇️
...munity/zabbix/plugins/modules/zabbix_group_info.py 80.76% <0.00%> (-1.38%) ⬇️
...s/community/zabbix/plugins/module_utils/helpers.py 72.41% <0.00%> (-0.92%) ⬇️
.../community/zabbix/plugins/module_utils/wrappers.py 71.42% <0.00%> (-0.80%) ⬇️
...s/community/zabbix/plugins/modules/zabbix_group.py 79.16% <0.00%> (-0.29%) ⬇️
...ns/community/zabbix/plugins/modules/zabbix_host.py 82.92% <0.00%> (-0.24%) ⬇️
...ommunity/zabbix/plugins/modules/zabbix_template.py 76.09% <0.00%> (+0.54%) ⬆️
...ns/community/zabbix/plugins/modules/zabbix_user.py 89.22% <0.00%> (+2.31%) ⬆️
...community/zabbix/plugins/modules/zabbix_service.py 86.13% <0.00%> (+2.80%) ⬆️
...s/community/zabbix/plugins/modules/zabbix_proxy.py 90.16% <0.00%> (+3.35%) ⬆️
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 922c034...0a3f84e. Read the comment docs.

@dj-wasabi dj-wasabi marked this pull request as ready for review July 16, 2020 11:52
@dj-wasabi dj-wasabi requested review from D3DeFi and sky-joker July 16, 2020 11:53
Copy link
Contributor

@D3DeFi D3DeFi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Nice work :)

@sky-joker
Copy link
Contributor

Hi @dj-wasabi

Thank you for this patch!
I'm working on tests some roles.
I executed the zabbix_web role occurs the following error with RHEL8.

TASK [community.zabbix.zabbix_web : RedHat | Install zabbix-web dependency (Zabbix 5.x)] *******************************************************************************
FAILED - RETRYING: RedHat | Install zabbix-web dependency (Zabbix 5.x) (3 retries left).
FAILED - RETRYING: RedHat | Install zabbix-web dependency (Zabbix 5.x) (2 retries left).
FAILED - RETRYING: RedHat | Install zabbix-web dependency (Zabbix 5.x) (1 retries left).
fatal: [192.168.0.21]: FAILED! => {"attempts": 3, "changed": false, "msg": "Failed to download metadata for repo 'zabbix-frontend': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried", "rc": 1, "results": []}

The above cause was a repo file.

[root@zabbix-role ~]# cat /etc/yum.repos.d/zabbix-frontend.repo
[zabbix-frontend]
baseurl = http://repo.zabbix.com/zabbix/5.0/rhel/8/$basearch/frontend/
gpgcheck = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
name = Zabbix Official Repository - $basearch

I tried to the following URL, to the accessed page is 404 not found page.

http://repo.zabbix.com/zabbix/5.0/rhel/8/x86_64/frontend/

So, I think frontend is unnecessary.

FYI
I used the playbook for tests is the following.

---
- name: role test
  hosts: all
  gather_facts: yes
  become: yes
  vars:
    zabbix_server_version: 5.0
  roles:

    - geerlingguy.apache
    - community.zabbix.zabbix_web

@sky-joker
Copy link
Contributor

I tried to install zabbix web with zabbix_web role to RHEL7 occurs the following scl rpm errors.

Error: Package: zabbix-web-deps-scl-5.0.2-1.el7.noarch (zabbix-frontend)
           Requires: rh-php72-php-gd
Error: Package: zabbix-web-deps-scl-5.0.2-1.el7.noarch (zabbix-frontend)
           Requires: rh-php72
Error: Package: zabbix-web-pgsql-scl-5.0.2-1.el7.noarch (zabbix-frontend)
           Requires: rh-php72-php-pgsql
Error: Package: zabbix-web-deps-scl-5.0.2-1.el7.noarch (zabbix-frontend)
           Requires: rh-php72-php-mbstring
Error: Package: zabbix-web-deps-scl-5.0.2-1.el7.noarch (zabbix-frontend)
           Requires: rh-php72-php-bcmath
Error: Package: zabbix-web-deps-scl-5.0.2-1.el7.noarch (zabbix-frontend)
           Requires: rh-php72-php-xml
Error: Package: zabbix-web-deps-scl-5.0.2-1.el7.noarch (zabbix-frontend)
           Requires: rh-php72-php-ldap
Error: Package: zabbix-web-deps-scl-5.0.2-1.el7.noarch (zabbix-frontend)
           Requires: rh-php72-php-fpm
**********************************************************************
yum can be configured to try to resolve such errors by temporarily enabling
disabled repos and searching for missing dependencies.
To enable this functionality please set 'notify_only=0' in /etc/yum/pluginconf.d/search-disabled-repos.conf
**********************************************************************

Error: Package: zabbix-web-deps-scl-5.0.2-1.el7.noarch (zabbix-frontend)
           Requires: rh-php72-php-gd
Error: Package: zabbix-web-deps-scl-5.0.2-1.el7.noarch (zabbix-frontend)
           Requires: rh-php72
Error: Package: zabbix-web-pgsql-scl-5.0.2-1.el7.noarch (zabbix-frontend)
           Requires: rh-php72-php-pgsql
Error: Package: zabbix-web-deps-scl-5.0.2-1.el7.noarch (zabbix-frontend)
           Requires: rh-php72-php-mbstring
Error: Package: zabbix-web-deps-scl-5.0.2-1.el7.noarch (zabbix-frontend)
           Requires: rh-php72-php-bcmath
Error: Package: zabbix-web-deps-scl-5.0.2-1.el7.noarch (zabbix-frontend)
           Requires: rh-php72-php-xml
Error: Package: zabbix-web-deps-scl-5.0.2-1.el7.noarch (zabbix-frontend)
           Requires: rh-php72-php-ldap
Error: Package: zabbix-web-deps-scl-5.0.2-1.el7.noarch (zabbix-frontend)
           Requires: rh-php72-php-fpm
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

I resolved the above errors by the following repos enabled.

https://access.redhat.com/discussions/3677111

In the RHEL7, maybe not necessary of a centos-release-scl repo.

@sky-joker
Copy link
Contributor

Oops, Sorry, I was wrong.
I see that zabbix_web does not support 5.0.

https://github.com/ansible-collections/community.zabbix/blob/d66056b48aad2fa7b2d57a172a45799b8303cb9f/docs/ZABBIX_WEB_ROLE.md

@sky-joker
Copy link
Contributor

sky-joker commented Jul 19, 2020

I found some problems after executing tests for the zabbix_proxy role.

combination table

OS DB zabbix Test Result
RHEL8 MariaDB 5.0 failed
RHEL8 PostgreSQL 5.0 failed
RHEL7 MariaDB 5.0 failed
RHEL7 PostgreSQL 5.0 succeeded

Error that occur with combination of RHEL7 and MySQL MariaDB

TASK [zabbix_proxy : MySQL | Create database and import file] **************************************************************************************************
[DEPRECATION WARNING]: evaluating zabbix_database_sqlload as a bare variable, this behaviour will go away and you might need to add |bool to the expression in
the future. Also see CONDITIONAL_BARE_VARS configuration toggle.. This feature will be removed in version 2.12. Deprecation warnings can be disabled by setting
 deprecation_warnings=False in ansible.cfg.
fatal: [192.168.0.23 -> 192.168.0.23]: FAILED! => {"changed": false, "msg": "\ngzip: stdout: Broken pipe\n"}

Error that occur with combination of RHEL8 and MySQL MariaDB

TASK [zabbix_proxy : RedHat | Install Mysql Client package RHEL5 - 6] ******************************************************************************************
[DEPRECATION WARNING]: evaluating zabbix_proxy_install_database_client as a bare variable, this behaviour will go away and you might need to add |bool to the
expression in the future. Also see CONDITIONAL_BARE_VARS configuration toggle.. This feature will be removed in version 2.12. Deprecation warnings can be
disabled by setting deprecation_warnings=False in ansible.cfg.
FAILED - RETRYING: RedHat | Install Mysql Client package RHEL5 - 6 (3 retries left).
FAILED - RETRYING: RedHat | Install Mysql Client package RHEL5 - 6 (2 retries left).
FAILED - RETRYING: RedHat | Install Mysql Client package RHEL5 - 6 (1 retries left).
fatal: [192.168.0.21]: FAILED! => {"attempts": 3, "changed": false, "failures": ["MySQL-python No match for argument: MySQL-python"], "msg": "Depsolve Error occured: \n 問題: problem with installed package mariadb-3:10.3.17-1.module+el8.1.0+3974+90eded84.x86_64\n  - package mariadb-3:10.3.17-1.module+el8.1.0+3974+90eded84.x86_64 conflicts with mysql provided by mysql-8.0.17-3.module+el8.0.0+3898+e09bb8de.x86_64\n  - package mysql-8.0.17-3.module+el8.0.0+3898+e09bb8de.x86_64 conflicts with mariadb provided by mariadb-3:10.3.17-1.module+el8.1.0+3974+90eded84.x86_64\n  - package mariadb-3:10.3.11-1.module+el8+2765+cfa4f87b.x86_64 conflicts with mysql provided by mysql-8.0.17-3.module+el8.0.0+3898+e09bb8de.x86_64\n  - package mysql-8.0.17-3.module+el8.0.0+3898+e09bb8de.x86_64 conflicts with mariadb provided by mariadb-3:10.3.11-1.module+el8+2765+cfa4f87b.x86_64\n  - package mariadb-3:10.3.11-2.module+el8+2885+7b8bb354.x86_64 conflicts with mysql provided by mysql-8.0.17-3.module+el8.0.0+3898+e09bb8de.x86_64\n  - package mysql-8.0.17-3.module+el8.0.0+3898+e09bb8de.x86_64 conflicts with mariadb provided by mariadb-3:10.3.11-2.module+el8+2885+7b8bb354.x86_64\n  - cannot install the best candidate for the job", "rc": 1, "results": []}

Error that occur with combination of RHEL8 and PostgreSQL

TASK [zabbix_proxy : RedHat | Install Ansible PostgreSQL module dependencies] **********************************************************************************
FAILED - RETRYING: RedHat | Install Ansible PostgreSQL module dependencies (3 retries left).
FAILED - RETRYING: RedHat | Install Ansible PostgreSQL module dependencies (2 retries left).
FAILED - RETRYING: RedHat | Install Ansible PostgreSQL module dependencies (1 retries left).
fatal: [192.168.0.21]: FAILED! => {"attempts": 3, "changed": false, "failures": ["python-psycopg2 No match for argument: python-psycopg2"], "msg": "Failed to install some of the specified packages", "rc": 1, "results": []}

In the RHEL8, MySQL-python and python-psycopg2 rpm package were not found.
The zabbix_server, zabbix_agent and zabbix_javagateway role was no problem in my lab :)

@dj-wasabi
Copy link
Contributor Author

@sky-joker

Thanks. Will take a look at it. For CentOS I had to add the following roles:

    - role: geerlingguy.repo-remi
      when: ansible_os_family == 'RedHat'
    - geerlingguy.php-versions
    - geerlingguy.php

I'll find a CentOS 8 Docker image to test on. Not sure why Zabbix decided to change everything again with repos for RHEL8 ..

Just a quick question, why do you had any issues with Zabbix Proxy with MySQL and not with Zabbix Server?

@sky-joker
Copy link
Contributor

sky-joker commented Jul 20, 2020

@dj-wasabi

I found out why, when combined RHEL7 and MariaDB, the error was occurring.
The cause is the MariaDB version a low.
When importing schema.sql file to zabbix_db by manual operation, the following error occurs.

[root@localhost ~]# zcat /usr/share/doc/zabbix-proxy-mysql-5.0.2/schema.sql.gz | mysql -u zabbix_proxy -p zabbix_proxy
password:
ERROR 1709 (HY000) at line 348: Index column size too large. The maximum column size is 767 bytes.

How to resolve

I changed to schema.sql using the following command.

[root@localhost ~]# cp /usr/share/doc/zabbix-proxy-mysql-5.0.2/schema.sql.gz .
[root@localhost ~]# gunzip schema.sql.gz
[root@localhost ~]# sed -i "s/InnoDB;/InnoDB ROW_FORMAT=DYNAMIC;/g" schema.sql

And, I was able to import the schema.sql to zabbix_proxy database.

[root@localhost ~]# cat schema.sql | mysql -u zabbix_proxy -p zabbix_proxy

After I rewrote the playbook like the following that I re-execute the zabbix_proxy role was succeeded for tasks.

[root@localhost ~]# vi collections/ansible_collections/community/zabbix/roles/zabbix_proxy/tasks/mysql.yml
(snip)
- name: "MySQL | Create database and import file"
  mysql_db:
    name: "{{ zabbix_proxy_dbname }}"
    encoding: "{{ zabbix_proxy_dbencoding }}"
    collation: "{{ zabbix_proxy_dbcollation }}"
    login_host: "{{ zabbix_proxy_mysql_login_host | default(omit) }}"
    login_user: "{{ zabbix_proxy_mysql_login_user | default(omit) }}"
    login_password: "{{ zabbix_proxy_mysql_login_password | default(omit) }}"
    state: import
    #target: "{{ ls_output_create.stdout }}"
    target: /root/schema.sql
  when:
    - zabbix_database_sqlload
    - not done_file.stat.exists
  delegate_to: "{{ delegated_dbhost }}"
  tags:
    - zabbix-proxy
    - database
(snip)
[root@localhost ~]# mysql -u zabbix_proxy -p -e 'drop database zabbix_proxy;create database zabbix_proxy;'
Enter password:
[root@localhost ~]# ansible-playbook main.yml -i inventory

So, I think to need to change the schema.sql file or upgrade MariaDB.

suggestion

I look like the zabbix_proxy role doesn't have a libsemanage-python install task.
(The zabbix_server and zabbix_web role have a libsemanage-python install task.)
So, the following error occurs.

TASK [community.zabbix.zabbix_proxy : Allow zabbix-proxy to open connections (SELinux)] **************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ImportError: No module named semanage
fatal: [192.168.0.23]: FAILED! => {"changed": false, "msg": "Failed to import the required Python library (libsemanage-python) on zabbix-role2's Python /usr/bin/python. Please read the module documentation and install it in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter"}

I think adding a libsemanage-python task to the zabbix_proxy role would make it better.

@D3DeFi
Copy link
Contributor

D3DeFi commented Jul 21, 2020

Sounds like issue for Zabbix itself that is not very suitable to be handled in the role

@dj-wasabi
Copy link
Contributor Author

Hi @sky-joker

Thanks! I will add the libsemanage-python just like the server|web to the proxy.

Currently strugling with PHP(-FPM) on CentOS 8 right now.. Hopefully i am able to fix it this weekend.

@sky-joker
Copy link
Contributor

sky-joker commented Jul 26, 2020

Thank you @dj-wasabi for fixing some issues.
I checked to haven't error if the using sqlite3 install to RHEL7,8 with the zabbix_proxy role.
And I checked the zabbix_web role work on the CentOS8.

@D3DeFi
Can you please merge this PR and add a 0.3.0 tag?

@D3DeFi
Copy link
Contributor

D3DeFi commented Jul 26, 2020

@D3DeFi
Can you please merge this PR and add a 0.3.0 tag?

Will do later today. Excellent job @dj-wasabi and thank you for thorough testing @sky-joker ! 🚀 🥇

@D3DeFi D3DeFi merged commit 1ca0fe0 into ansible-collections:master Jul 26, 2020
@dj-wasabi
Copy link
Contributor Author

Thank you @sky-joker for testing and @D3DeFi for merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants