Skip to content
This repository has been archived by the owner on Nov 6, 2024. It is now read-only.

Commit

Permalink
Add merge_vars attribute to applyservice and allow for multiple Servi…
Browse files Browse the repository at this point in the history
…ce definitions for set by adding service name prefix
  • Loading branch information
gsreynolds committed Jul 7, 2016
1 parent 0505a80 commit f1b3ae1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
10 changes: 9 additions & 1 deletion libraries/resource_applyservice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,14 @@ def icon_image_alt(arg = nil)
)
end

def merge_vars(arg = nil)
set_or_return(
:merge_vars, arg,
:kind_of => Array,
:default => nil
)
end

def custom_vars(arg = nil)
set_or_return(
:custom_vars, arg,
Expand Down Expand Up @@ -259,7 +267,7 @@ def resource_properties(arg = nil)
set_or_return(
:resource_properties, arg,
:kind_of => Array,
:default => %w(import display_name host_name groups check_command max_check_attempts check_period check_interval retry_interval enable_notifications enable_active_checks enable_passive_checks enable_event_handler enable_flapping enable_perfdata event_command flapping_threshold volatile zone command_endpoint notes notes_url action_url icon_image icon_image_alt custom_vars assign_where ignore_where set)
:default => %w(import display_name host_name groups check_command max_check_attempts check_period check_interval retry_interval enable_notifications enable_active_checks enable_passive_checks enable_event_handler enable_flapping enable_perfdata event_command flapping_threshold volatile zone command_endpoint notes notes_url action_url icon_image icon_image_alt merge_vars custom_vars assign_where ignore_where set)
)
end
end
Expand Down
7 changes: 6 additions & 1 deletion templates/default/object.applyservice.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

<% @objects.sort.map do |object, options|%>
apply Service <%= options['set'].nil? ? object.inspect : "for (#{options['set']})" -%> {
apply Service <%= object.inspect -%><%= " for (#{options['set']})" unless options['set'].nil? -%> {
<%- if options['import'] -%>
import <%= options['import'].inspect %>
<%- end -%>
Expand Down Expand Up @@ -91,6 +91,11 @@ apply Service <%= options['set'].nil? ? object.inspect : "for (#{options['set']}
ignore where <%= i %>
<% end -%>
<% end -%>
<% if options['merge_vars'] -%>
<% options['merge_vars'].each do |var| -%>
vars += <%= var %>
<% end -%>
<% end -%>
<% if options['custom_vars'] -%>
<% Hash[options['custom_vars'].sort].each do |var, value| -%>
<% if var && value && value.is_a?(Hash) -%>
Expand Down

0 comments on commit f1b3ae1

Please sign in to comment.