Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed missing item when syncing templates #884

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5476,6 +5476,7 @@ The following parameters are available in the `zabbix::resources::template` defi
* [`delete_missing_graphs`](#-zabbix--resources--template--delete_missing_graphs)
* [`delete_missing_httptests`](#-zabbix--resources--template--delete_missing_httptests)
* [`delete_missing_items`](#-zabbix--resources--template--delete_missing_items)
* [`delete_missing_linkage`](#-zabbix--resources--template--delete_missing_linkage)
* [`delete_missing_templatescreens`](#-zabbix--resources--template--delete_missing_templatescreens)
* [`delete_missing_triggers`](#-zabbix--resources--template--delete_missing_triggers)

Expand Down Expand Up @@ -5551,6 +5552,14 @@ Deletes items from zabbix that are not in the template when set to true

Default value: `false`

##### <a name="-zabbix--resources--template--delete_missing_linkage"></a>`delete_missing_linkage`

Data type: `Boolean`

Delete linked templates when they are no longer present

Default value: `false`

##### <a name="-zabbix--resources--template--delete_missing_templatescreens"></a>`delete_missing_templatescreens`

Data type: `Boolean`
Expand Down Expand Up @@ -5729,6 +5738,7 @@ The following parameters are available in the `zabbix::template` defined type:
* [`delete_missing_graphs`](#-zabbix--template--delete_missing_graphs)
* [`delete_missing_httptests`](#-zabbix--template--delete_missing_httptests)
* [`delete_missing_items`](#-zabbix--template--delete_missing_items)
* [`delete_missing_linkage`](#-zabbix--template--delete_missing_linkage)
* [`delete_missing_templatescreens`](#-zabbix--template--delete_missing_templatescreens)
* [`delete_missing_triggers`](#-zabbix--template--delete_missing_triggers)

Expand Down Expand Up @@ -5796,6 +5806,14 @@ Deletes items from zabbix that are not in the template when set to true

Default value: `false`

##### <a name="-zabbix--template--delete_missing_linkage"></a>`delete_missing_linkage`

Data type: `Boolean`

Delete linked templates when they are no longer present

Default value: `false`

##### <a name="-zabbix--template--delete_missing_templatescreens"></a>`delete_missing_templatescreens`

Data type: `Boolean`
Expand Down Expand Up @@ -6193,6 +6211,7 @@ The following parameters are available in the `zabbix_template` type.
* [`delete_missing_graphs`](#-zabbix_template--delete_missing_graphs)
* [`delete_missing_httptests`](#-zabbix_template--delete_missing_httptests)
* [`delete_missing_items`](#-zabbix_template--delete_missing_items)
* [`delete_missing_linkage`](#-zabbix_template--delete_missing_linkage)
* [`delete_missing_templatescreens`](#-zabbix_template--delete_missing_templatescreens)
* [`delete_missing_triggers`](#-zabbix_template--delete_missing_triggers)
* [`provider`](#-zabbix_template--provider)
Expand Down Expand Up @@ -6220,6 +6239,10 @@ Delete web scenarios from zabbix which are not in the template.

Delete items from zabbix which are not in the template.

##### <a name="-zabbix_template--delete_missing_linkage"></a>`delete_missing_linkage`

Delete linked templates when they are no longer present.

##### <a name="-zabbix_template--delete_missing_templatescreens"></a>`delete_missing_templatescreens`

Delete templateScreens from zabbix which are not in the template.
Expand Down
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 @@ -51,7 +51,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 @@ -66,6 +66,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
Loading