Ad Widget

Collapse

Adding Zabbix templates to host using Ansible, removes existing templates

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • doderlein
    Junior Member
    • Jun 2011
    • 5

    #1

    Adding Zabbix templates to host using Ansible, removes existing templates

    We are using Ansible to install our servers. I've set up an Ansible role to add the host to Zabbix if it doesn't exist. In addition we have other Zabbix roles, like for instance setup monitoring on Apache and PostgreSQL. The problem is that when I add a template through a playbook, all existing templates on the server in Zabbix is gone. So when I run the zabbix-agent playbook, our standard templates are added. When the playbook for monitoring Apache is running and updating the host to add a new template, the previous ones are removed.

    Is it possible to just add templates through playbooks and not remove the existing ones? The same goes for host groups as well. Has anyone managed to do this?

    Regards
  • tim.mooney
    Senior Member
    • Dec 2012
    • 1427

    #2
    My site uses a different configuration management system, so I'm not well-versed in Ansible. However, this is a general problem that I would assume Ansible has a solution for.

    How does Ansible solve the "set problem"? In other words, each template applied to a system is effectively adding an item to a set, in the mathematical and computer science sense. So, what's the method you use in Ansible to collect the members of a set (reminder that they are unique)? Whatever method that is, that's the method you need to investigate for working with templates in Zabbix.

    Comment

    • LenR
      Senior Member
      • Sep 2009
      • 1005

      #3
      With the zabbix API, you would have to get the linked templates, add the new template and return the complete list. Any omitted are unlinked but not cleared.

      I think you would have to have Ansible configured to have the list of all templates for each host or possibly write your own ansible module to do a "add template" as above.

      Comment

      Working...