Skip to content

Commit

Permalink
Fixed missing item when syncing templates
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabian1976 committed Sep 19, 2023
1 parent 86a35ad commit 731eb44
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/puppet/provider/zabbix_template/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def create
updateExisting: true
},
templateLinkage: {
createMissing: true
createMissing: true,
deleteMissing: (@resource[:delete_missing_linkage].nil? ? false : @resource[:delete_missing_linkage])
},
templates: {
createMissing: true,
Expand Down
4 changes: 4 additions & 0 deletions lib/puppet/type/zabbix_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ def change_to_s(currentvalue, newvalue)
desc 'Delete items from zabbix which are not in the template.'
end

newparam(:delete_missing_linkage, boolean: true) do
desc 'Delete linked templates when they are no longer present.'
end

newparam(:delete_missing_templatescreens, boolean: true) do
desc 'Delete templateScreens from zabbix which are not in the template.'
end
Expand Down
3 changes: 3 additions & 0 deletions manifests/resources/template.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# @param delete_missing_graphs Deletes graphs from zabbix that are not in the template when set to true
# @param delete_missing_httptests Deletes web-scenarios from zabbix that are not in the template when set to true
# @param delete_missing_items Deletes items from zabbix that are not in the template when set to true
# @param delete_missing_linkage Delete linked templates when they are no longer present
# @param delete_missing_templatescreens Deletes template-screens from zabbix that are not in the template when set to true
# @param delete_missing_triggers Deletes triggers from zabbix that are not in the template when set to true
define zabbix::resources::template (
Expand All @@ -20,6 +21,7 @@
Boolean $delete_missing_graphs = false,
Boolean $delete_missing_httptests = false,
Boolean $delete_missing_items = false,
Boolean $delete_missing_linkage = false,
Boolean $delete_missing_templatescreens = false,
Boolean $delete_missing_triggers = false,
) {
Expand All @@ -39,6 +41,7 @@
delete_missing_graphs => $delete_missing_graphs,
delete_missing_httptests => $delete_missing_httptests,
delete_missing_items => $delete_missing_items,
delete_missing_linkage => $delete_missing_linkage,
delete_missing_templatescreens => $delete_missing_templatescreens,
delete_missing_triggers => $delete_missing_triggers,
}
Expand Down
3 changes: 3 additions & 0 deletions manifests/template.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# @param delete_missing_graphs Deletes graphs from zabbix that are not in the template when set to true
# @param delete_missing_httptests Deletes web-scenarios from zabbix that are not in the template when set to true
# @param delete_missing_items Deletes items from zabbix that are not in the template when set to true
# @param delete_missing_linkage Delete linked templates when they are no longer present
# @param delete_missing_templatescreens Deletes template-screens from zabbix that are not in the template when set to true
# @param delete_missing_triggers Deletes triggers from zabbix that are not in the template when set to true
# @example
Expand All @@ -23,6 +24,7 @@
Boolean $delete_missing_graphs = false,
Boolean $delete_missing_httptests = false,
Boolean $delete_missing_items = false,
Boolean $delete_missing_linkage = false,
Boolean $delete_missing_templatescreens = false,
Boolean $delete_missing_triggers = false,
) {
Expand All @@ -35,6 +37,7 @@
delete_missing_graphs => $delete_missing_graphs,
delete_missing_httptests => $delete_missing_httptests,
delete_missing_items => $delete_missing_items,
delete_missing_linkage => $delete_missing_linkage,
delete_missing_templatescreens => $delete_missing_templatescreens,
delete_missing_triggers => $delete_missing_triggers,
}
Expand Down

0 comments on commit 731eb44

Please sign in to comment.