ansible-collections / community.zabbix

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

community.zabbix.zabbix_host: Add possebility to import yaml host deffinitions #1317

Open sonor3000 opened 1 week ago

sonor3000 commented 1 week ago
SUMMARY

Please add the possebility to import a yaml host definition for the community.zabbix.zabbix_host plugin like it is already there for the community.zabbix.zabbix_template plugin with the template_yaml parameter.

ISSUE TYPE
COMPONENT NAME

community.zabbix.zabbix_template

ADDITIONAL INFORMATION

Withh the community.zabbix.zabbix_template plugin I can create or update templates easily with ansible using the same yaml structure that also Zabbix is able to handle. I can handle those files in git and update templates for different Zabbix instances which is the perfect GitOps aproach to maintain our Zabbix test and prod instance and have all monitoring data also as code in a way also Zabbix is able to understand natively. Changes to a template only means changing the yaml, commit it to the git and run a playbook that updates the template using the template_yaml parameter to import the new or changed template.

I'd like to do the same for all our hosts configured in Zabbix. but unfortunatly it is not possible to import the original yaml definition of a host which was exported as yaml from Zabbix before into another Zabbix instance using the host plugin for ansible. I have to maintain a paralel yaml structure for my hosts in a way that the ansible host plugin can process, but using the yaml structure that would Zabbix create during exporting a host can't be used with the host plugin allthough this would be much more easy and also much mor comfortable.

So having a parameter like the template_yaml thing for the template plugin would be very cool also for the host module / plugin.

Or am I going the totaly wrong way and should I handle my host configurations another way?

My idea is to store the configuration of every host that I want to have in Zabbix in the same format I'd get if I have created the host via the Zabbix GUI and exported it as yaml. If I like to change a host I'd change the yaml, commit it to a git and run a playbook that loops via the host yaml files and performs the changes to the hosts via the Zabbix API. That works perfectly fine for templates, but for hosts I am not able to work this way. Instead I have to configure the hosts in the way that it is fine for the ansible host plugin which is totaly different yaml like I get if I export the same host from Zabbix.

How do you handle your different host definitions in ansible? Is it the wrong approach to use the yaml structure that Zabbix does understand or is it even the wrong approach to handle the hosts I want to configure in Zabbix wit or in ansible? How can I geta GitOps like configuration not only for templates but also for hosts? Or am I able to use the Zabbix yaml structure with the community.zabbix.zabbix_host plugin somehow in my playbooks?