ansible-collections / community.zabbix

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

Zabbix 5.0 support #45

Closed apiening closed 4 years ago

apiening commented 4 years ago
SUMMARY

Zabbix 5.0.0 has been released: https://www.zabbix.com/release_notes

The README.md file states:

As a main priority, this collection aims to cover all of the currently supported Zabbix releases, which are noted on the Zabbix Life Cycle & Release Policy page.

I'm curious if there has been some progress made towards supporting Zabbix 5.0 or if there is some scheduling in place.

ISSUE TYPE
COMPONENT NAME

Supported Zabbix Versions

ADDITIONAL INFORMATION

I know that version 5.0.0 has just been released. From what I extracted from the release notes there are no breaking changes. The client is aimed to be a drop-in-replacement where config compatibility is preserved. An upgrade of the server is supported, too: https://www.zabbix.com/documentation/current/manual/installation/upgrade

D3DeFi commented 4 years ago

Thanks for opening this issue @apiening

I was thinking about this yesterday as I've seen the release announcement, but haven't had any time to actually look at it any closer.

To be honest, we haven't established any roadmap yet for this collection repo and most of the work is done with best effort reactive to issues as they arise.

I will kick into our CI and make it spin containers for 5.0 as well to see what errors we get. There will be probably some misses as not all of the modules have integration tests written yet.

Until then, please feel free to open a new issue (or PR if you are up to it) if you find any bug

sky-joker commented 4 years ago

Thank you @apiening for reporting.

@D3DeFi

I tried zabbix integration test with zabbix 5.0 in my lab and the following module integration tests are errors occurred.

The above errors are investigating now.

It can't zabbix 5.0 run using current docker-compose file because It was changed listen port for a container from 80 to 8080 by zabbix developer.
So, If @D3DeFi agrees, I can PR for a fix to docker-compose file to do zabbix 5.0 work.

D3DeFi commented 4 years ago

Thank you @apiening for reporting.

@D3DeFi

I tried zabbix integration test with zabbix 5.0 in my lab and the following module integration tests are errors occurred.

* zabbix_host

* zabbix_proxy

* zabbix_template

The above errors are investigating now.

It can't zabbix 5.0 run using current docker-compose file because It was changed listen port for a container from 80 to 8080 by zabbix developer. So, If @D3DeFi agrees, I can PR for a fix to docker-compose file to do zabbix 5.0 work.

Please, go ahead and open the PR. We can even have it failing CI until errors in integration tests are under investigation.

D3DeFi commented 4 years ago

@sky-joker have you started working on failing zabbix_ modules? I am asking, because if not, I can start working on #46 and fix the issues you've reported at the same time.

sky-joker commented 4 years ago

I haven't started a detailed investigation yet. I looked over the integration test result for zabbix_host, changed occurs when performing the same task that has not been parameters changed. The configuration comparison process does not seem to work well.

@D3DeFi Can you handle https://github.com/ansible-collections/community.zabbix/issues/46 ?

apiening commented 4 years ago

As far as I can see https://github.com/ansible-collections/community.zabbix/issues/46 has been closed since the component zabbix_host does work with Zabbix 5.0 when the details parameters are set accordingly.

I have updated my Zabbix server instance to 5.0 (docker-compose based installation) and I would like to configure some clients now. Since I have used https://galaxy.ansible.com/dj-wasabi/zabbix-agent in the past to deploy 4.4 Agents I wonder if it is possible to deploy 5.0 agents with ansible yet? The previously mentioned roles git repo has been set to RO. As far as I understand this, the API-part to manage the zabbix configuration has been replaced by this ansible-collection. But this collection does not offer the actual rollout of the Zabbix agent itself (Installing the agent packages, configure the agent settings) am I right? I wonder if this functionality would be merged into this collection as well, or if there would be another ansible role required to do the agent rollout.

I would like to setup some Zabbix 5.0 clients with ansible on my systems and to do some testing. Is there a way to start with a dev branch or are we not quite there yet?

D3DeFi commented 4 years ago

@apiening we are unfortunately not there yet. 5.0 release came just as we are in the process of "consuming" zabbix roles from @dj-wasabi into this collection.

There is a project open for this migration as was discussed in #16 and dj-wasabi/ansible-zabbix-agent#341

@dj-wasabi - any thoughts on when other zabbix roles may make it as a PRs into this collection?

apiening commented 4 years ago

Since I'm a little bit under time pressure and I didn't want to deploy my zabbix agents manually (without ansible) I tried to setup a zabbix agent version 5.0 with the role zabbix-agent from the devel-roles-migration branch. With just some minor modifications, it worked so far.

In case there are other impatient ones around, here is what I did:

  1. I did a git clone git@github.com:ansible-collections/community.zabbix.git zabbix in the folder collections/ansible_collections/community under where my playbook is located.
  2. In the newly cloned repository in the folder zabbix I did a git checkout devel-roles-migratio to switch to the dev branch.
  3. I edited the file collections/ansible_collections/community/zabbix/roles/zabbix-agent/vars/zabbix.yml and added the sign key for the 5.0 repository for debian buster which is the distro I'm using on the target system, so that the head of the file looks like this:
    
    ---

sign_keys: "50": buster: sign_key: E709712C

Then I was able to install / setup the zabbix client 5.0 with the following playbook:

I noticed that the apt repository seems to be removed and re-added on each run of the playbook. So the setup is not idempotent and I haven't really tried to find out why this is. Other than that, it seems to work for me without any issues. I'm aware that this is an incomplete and hacky way and not the final ported playbook. That being said, it looks to me that the changes required to setup the 5.0 version of the zabbix-agent instead of the 4.4 version are pretty minimal.

D3DeFi commented 4 years ago

Sorry @apiening that it is taking us so long and thanks for posting this workaround. Just a minor correction - devel-roles-migration branch is no longer valid. All roles were merged to the master already and this collection will be very soon released as a 0.2.0.

I believe that 5.0 support for zabbix_agent role is planned for a near future.

dj-wasabi commented 4 years ago

Hi @apiening

I am currently working on getting the CI work with the Ansible roles. Once I have finished that, I will be working on getting the roles to work with Zabbix 5.0. So no worries, it will be coming. :)

Regards, Werner

apiening commented 4 years ago

Hi @D3DeFi and @dj-wasabi,

thank you for the update: Can't wait for the release.

As soon as there's something ready to be testet I would like to give it a try. I expect that the vars might change or have a different prefix, but that should not be an issue. Once we confirmed that the roles are working, we may provide a simple upgrade.md which points out what users have to do when they have used the roles from @dj-wasabi before and wants to migrate to this collection.

With kind regards Andreas

D3DeFi commented 4 years ago

Once we confirmed that the roles are working, we may provide a simple upgrade.md which points out what users have to do when they have used the roles from @dj-wasabi before and wants to migrate to this collection.

That is indeed planned in #77 and 0.2.0 should be now live :)

raph-topo commented 4 years ago

Hello, Are there updates on Zabbix 5.0 support? Do you need help on this?

I did not manage to reproduce @apiening's workaround with 0.2.0. (edit: I did.)

apiening commented 4 years ago

Hi @raph-topo,

I have cloned your fork and replaced my own modified version with it and gave it a try. The role that needs to be imported is named zabbix_agent now, instead of zabbix-agent like in my example which was based on an outdated branch (please notice the underscore). Other than that, it worked for me!

Here is the complete playbook I used to do the test:

---
- hosts: all
  collections:
    - community.zabbix
  tasks:
    - name: Import zabbix-agent role
      import_role:
        name: zabbix_agent
    - name: Ensure host is monitored by Zabbix.
      zabbix_host:
        server_url: https://zabbix.myserver.com
        login_user: Admin
        login_password: "verysecurepassword"
        host_name: '{{ inventory_hostname }}'
        host_groups:
          - Linux servers
        link_templates:
          - Template OS Linux by Zabbix agent
        status: enabled
        state: present
        interfaces:
          - type: 1
            main: 1
            dns: '{{ inventory_hostname }}'
      delegate_to: localhost

If this works for you as well, may I suggest that you do a PR based on your fork? This would bring us one step in the right direction and it would enable others to test the playbook with the latest Zabbix version which is available for quite a while now.

apiening commented 4 years ago

@raph-topo I should have mentioned, that the following vars are still required to execute the playbook from my previous post successfully. I've put these variables in a host_vars-file:

---
zabbix_agent_version: 5.0
zabbix_version_long: 5.0.1
zabbix_agent_server: ###zabbix-server###
zabbix_agent_serveractive: ###zabbix-server###
zabbix_url: https://###zabbix-server###
zabbix_agent_become_on_localhost: false
raph-topo commented 4 years ago

Thanks for your help, @apiening! I figured out why it did not work… Ansible variable precedence. Now that I moved these variables to group_vars (could also be host_vars indeed), it runs fine, which allowed me to proceed with #121 Actually,

zabbix_agent_version: 5.0
zabbix_agent_server: …

are enough.

dj-wasabi commented 4 years ago

Hi @raph-topo,

I have cloned your fork and replaced my own modified version with it and gave it a try. The role that needs to be imported is named zabbix_agent now, instead of zabbix-agent like in my example which was based on an outdated branch (please notice the underscore). Other than that, it worked for me!

Here is the complete playbook I used to do the test:

---
- hosts: all
  collections:
    - community.zabbix
  tasks:
    - name: Import zabbix-agent role
      import_role:
        name: zabbix_agent
    - name: Ensure host is monitored by Zabbix.
      zabbix_host:
        server_url: https://zabbix.myserver.com
        login_user: Admin
        login_password: "verysecurepassword"
        host_name: '{{ inventory_hostname }}'
        host_groups:
          - Linux servers
        link_templates:
          - Template OS Linux by Zabbix agent
        status: enabled
        state: present
        interfaces:
          - type: 1
            main: 1
            dns: '{{ inventory_hostname }}'
      delegate_to: localhost

If this works for you as well, may I suggest that you do a PR based on your fork? This would bring us one step in the right direction and it would enable others to test the playbook with the latest Zabbix version which is available for quite a while now.

I think the playbook can be much smaller if you would go for this:

Playbook.yml

---
- hosts: all
  collections:
    - community.zabbix
  tasks:
    - name: Import zabbix-agent role
      import_role:
        name: zabbix_agent

group_vars (or host_vars):

zabbix_api_create_hosts: true
zabbix_api_create_hostgroup: true # If the host group doesnt exist
zabbix_api_pass: "verysecurepassword"
zabbix_url: https://zabbix.myserver.com

Now the Ansible Zabbix Agent role will make sure the host is created via the API.

b2ronn commented 4 years ago

for zabbix-proxy5 with sqlite3 db on Centos 8 in collections/ansible_collections/community/zabbix/roles/zabbix_proxy/tasks/RedHat.yml datafiles_path: "/usr/share/doc/zabbix-proxy-{{ zabbix_proxy_database }}-{{ zabbix_version }}*" but on the host I see it on a different path /usr/share/doc/zabbix-proxy-sqlite3/schema.sql.gz

i've added in collections/ansible_collections/community/zabbix/roles/zabbix_proxy/tasks/RedHat.yml

- name: "RedHat | Set facts for Zabbix >= 3.0 and RedHat 8"
  set_fact:
    apache_log: httpd
    datafiles_path: "/usr/share/doc/zabbix-proxy-{{ zabbix_proxy_database }}"
  when:
    - zabbix_version is version_compare('3.0', '>=')
    - ansible_distribution_major_version == '8'
    - zabbix_proxy_database == 'sqlite3'
  tags:
    - zabbix-proxy

and it's work for me

dj-wasabi commented 4 years ago

Hi @b2ronn

Thank you, I will add it to my PR. 👍

Have some issues with PHP on a CentOS 8.. So hopefully I am able to get the PR merged this weekend..

b2ronn commented 4 years ago

Hi @b2ronn

Thank you, I will add it to my PR. 👍

Have some issues with PHP on a CentOS 8.. So hopefully I am able to get the PR merged this weekend..

on the existing host, I had no problems with selinux, but on a new minimal installation Centos8 there is an error

    "msg": "Failed to import the required Python library (libsemanage-python) on localhost.localdomain's Python /usr/libexec/platform-python. Please read module documentation and install 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"

need in the collections/ansible_collections/community/zabbix/roles/zabbix_proxy/tasks/RedHat.yml in the task - name: "RedHat | Install related SELinux package to fix issues on RHEL8" to add

      name:
        - policycoreutils
        - checkpolicy
+       - python3-libsemanage
      state: present
    register: zabbix_server_dependencies_installed
    until: zabbix_server_dependencies_installed is succeeded
dj-wasabi commented 4 years ago

Hi @b2ronn

Have created a new pr: https://github.com/ansible-collections/community.zabbix/pull/149 Did you had to make any other additional changes? Then I'll add them too.

stephankn commented 4 years ago

@dj-wasabi why did you add this if-block? https://github.com/ansible-collections/community.zabbix/commit/1ca0fe096e85b5de1edd68a3adddc726abfac61a#diff-44c8f6076009a75ecda31b820dd0e182R62

I tried to set up zabbix_web on Ubuntu 20.04 and it lacks the required php settings. Changing the two lines mentioned above to include version 5.0 includes the php settings and resolves the front-end error.

dj-wasabi commented 4 years ago

Hi @stephankn

It seems that Zabbix is very inconsistent with certain things, this would be another one. Will try to check this weekend. Thank you for making a comment. 👍

b2ronn commented 4 years ago

сouple of questions about the default variables

  1. why do you have different zabbix_repo_yumin different roles? the zabbix agent has a priority: 1 ,but not in other roles, and if I install the Zabbix agent and the Zabbix proxy on the same host, every time the repository files are overwritten.
  2. is it possible to add zabbix_repo_yum_schema: http?

    +zabbix_repo_yum_schema: http
    
    zabbix_repo_yum:
    - name: zabbix
     description: Zabbix Official Repository - $basearch
    -    baseurl: http://repo.zabbix.com/zabbix/{{ zabbix_version }}/rhel/{{ ansible_distribution_major_version }}/$basearch/
    +    baseurl: "{{ zabbix_repo_yum_schema }}://repo.zabbix.com/zabbix/{{ zabbix_version }}/rhel/{{ ansible_distribution_major_version }}/$basearch/"
     gpgcheck: 0
     gpgkey: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
     state: present
    - name: zabbix-non-supported
     description: Zabbix Official Repository non-supported - $basearch
    -    baseurl: http://repo.zabbix.com/non-supported/rhel/{{ ansible_distribution_major_version }}/$basearch/
    +    baseurl: "{{ zabbix_repo_yum_schema }}://repo.zabbix.com/non-supported/rhel/{{ ansible_distribution_major_version }}/$basearch/"
     gpgcheck: 0
     gpgkey: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
     state: present

    because in one envirement I have problems connecting to the repository via http, but without any problems it is available via https. of course I can set zabbix_repo_yum in variables, but it's easier to set one parameter.

dj-wasabi commented 4 years ago

Hi @b2ronn

1) I think because when I started it with them in the "version 1.0.0" of my roles back then they were all the same, but eventually the agent grew apart as there were more people creating PR for the agent and thus also making changes to that syntax.

2) Sure, why not. Do you want to create a PR or shall I do that with the other suggestions in this issue somewhere this weekend?

b2ronn commented 4 years ago

@dj-wasabi . please do you.

b2ronn commented 4 years ago

I've created a new PR for my last comment, because in addition to those changes, I added keys that are not in the templates. https://github.com/ansible-collections/community.zabbix/pull/164

D3DeFi commented 4 years ago

I believe a huge effort was made to provide support for Zabbix 5.0 both in modules and roles, which is now in much better state than it was when this issue was first opened.

If you find any additional problems, please create a new issue. Closing this one, thank you everyone!