community.zabbix
                                
                                
                                
                                    community.zabbix copied to clipboard
                            
                            
                            
                        Implement zabbix_template's unlink/unlink and clear technique for linked templates to zabbix_host module
SUMMARY
I would love to see the possibility to control whether a template that is linked to an existing host in Zabbix and NOT listed in the "link_templates" attribute of the zabbix_host module gets "unlinked" or "unlinked and cleared". If I have understood the documenation and source code of both the zabbix_host and the zabbix_template modules correctly, this functionality is already implemented in the zabbix_template module: if there is a template linked to the template in question, but not listed in zabbix_template's "link_templates" attribute, it's going to be unlinked. If this same template is additionally listed in the "unlink_templates" attribute, it's getting not only unlinked from the template in question, it's also getting cleared. Currently, if I understand the code of zabbix_host correctly, there is only the possibility to "unlink and clear" a template from a host, because there is no "clear_templates" attribute and the clear is implicit.
ISSUE TYPE
- Feature Idea
 
COMPONENT NAME
zabbix_host
ADDITIONAL INFORMATION
Very useful in large scale migrations where to change several hosts to change from one to another template (updated template, new version) wihtout deleting all existing data.
Thank you for the feature idea @fibbs.
This should be doable without huge effort. However we would change existing functionality by introducing clear_templates module parameter and changing link_templates to match what zabbix_template does as someone may rely on the existing functionality already.
@sky-joker what do you think? Can we proceed with mirroring zabbix_template or we rather handle the situation differently (causing inconsistency between these two modules) for example by introducing clear_templates as a boolean value defaulting to True?
Hey! Is there a chance to implement this? It would be really useful to be able to unlink and clear while removing hosts with zabbix_host state:absent. Greetings,
This would be really nice, and I agree with the proposal of @D3DeFi to add just a variable clear_templates defaulted to True to avoid any breaking change.
Hey folks, I'll be happy to merge such PR. Unfortunately I don't have many opportunities to code it myself atm.