Skip to content

Commit

Permalink
prevent provider from making changes every puppet run
Browse files Browse the repository at this point in the history
  • Loading branch information
j-russell committed Aug 9, 2013
1 parent 144ec63 commit 7fd5e54
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
3 changes: 1 addition & 2 deletions lib/puppet/provider/sensu_check/json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,12 @@ def check_args
end

def custom
conf['checks'][resource[:name]].each { |k, v| conf['checks'][resource[:name]][k] = v.to_s }
conf['checks'][resource[:name]].reject { |k,v| check_args.include?(k) }
end

def custom=(value)
conf['checks'][resource[:name]].delete_if { |k,v| not check_args.include?(k) }
value.each { |k, v| value[k] = to_type(v) }
conf['checks'][resource[:name]].delete_if { |k,v| not check_args.include?(k) }
conf['checks'][resource[:name]].merge!(value)
end

Expand Down
25 changes: 25 additions & 0 deletions lib/puppet/type/sensu_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,31 @@ def should_to_s(hash = @should)
hash.keys.sort.map {|key| "#{key} => #{hash[key]}"}.join(", ")
end

def insync?(is)
if defined? @should[0]
if is == @should[0].each { |k, v| value[k] = to_type(v) }
true
else
false
end
else
true
end
end

def to_type(value)
case value
when true, 'true', 'True', :true
true
when false, 'false', 'False', :false
false
when /^([0-9])+$/
value.to_i
else
value
end
end

defaultto {}
end

Expand Down

0 comments on commit 7fd5e54

Please sign in to comment.