Skip to content

Commit

Permalink
zabbix_template - enable new update rule to delete missing linked tem…
Browse files Browse the repository at this point in the history
…plates (#66747)

* enable new update rule to delete missing linked templates

New update rule is available from 4.0.16 and 4.4.4 up. Add check for version and enable new update rule.

fixes #66720

* adding fragment file

* Update zabbix_template.py

* Update zabbix_template.py
  • Loading branch information
rockaut authored and ansibot committed Jan 27, 2020
1 parent 99d7f15 commit 055cf91
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
minor_changes:
- zabbix_template - adding new update rule templateLinkage.deleteMissing for newer zabbix versions (https://github.com/ansible/ansible/pull/66747).

8 changes: 8 additions & 0 deletions lib/ansible/modules/monitoring/zabbix/zabbix_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,14 @@ def import_template(self, template_content, template_type='json'):
if LooseVersion(api_version).version[:2] <= LooseVersion('3.2').version:
update_rules['applications']['updateExisting'] = True

# templateLinkage.deleteMissing only available in 4.0 branch higher .16 and higher 4.4.4
# it's not available in 4.2 branches or lower 4.0.16
if LooseVersion(api_version).version[:2] == LooseVersion('4.0').version and \
LooseVersion(api_version).version[:3] >= LooseVersion('4.0.16').version:
update_rules['templateLinkage']['deleteMissing'] = True
if LooseVersion(api_version).version[:3] >= LooseVersion('4.4.4').version:
update_rules['templateLinkage']['deleteMissing'] = True

import_data = {'format': template_type, 'source': template_content, 'rules': update_rules}
self._zapi.configuration.import_(import_data)
except ZabbixAPIException as e:
Expand Down

0 comments on commit 055cf91

Please sign in to comment.