-
Notifications
You must be signed in to change notification settings - Fork 290
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
install handler scripts and config files
- Loading branch information
1 parent
5fa1eba
commit 297350d
Showing
8 changed files
with
179 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
require 'rubygems' if RUBY_VERSION < '1.9.0' && Puppet.features.rubygems? | ||
require 'json' if Puppet.features.json? | ||
|
||
Puppet::Type.type(:sensu_handler_config).provide(:json) do | ||
confine :feature => :json | ||
|
||
def initialize(*args) | ||
super | ||
|
||
begin | ||
@conf = JSON.parse(File.read("/etc/sensu/conf.d/#{resource[:name]}.json")) | ||
rescue | ||
@conf = {} | ||
end | ||
end | ||
|
||
def flush | ||
File.open("/etc/sensu/conf.d/#{resource[:name]}.json", 'w') do |f| | ||
f.puts JSON.pretty_generate(@conf) | ||
end | ||
end | ||
|
||
def create | ||
@conf[resource[:name]] = {} | ||
self.config = resource[:config] | ||
end | ||
|
||
def destroy | ||
@conf = nil | ||
end | ||
|
||
def exists? | ||
@conf.has_key?(resource[:name]) | ||
end | ||
|
||
def config | ||
@conf[resource[:name]] | ||
end | ||
|
||
def config=(value) | ||
@conf[resource[:name]] = value | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
Puppet::Type.newtype(:sensu_handler_config) do | ||
@doc = "" | ||
|
||
def initialize(*args) | ||
super | ||
end | ||
|
||
ensurable do | ||
newvalue(:present) do | ||
provider.create | ||
end | ||
|
||
newvalue(:absent) do | ||
provider.destroy | ||
end | ||
|
||
defaultto :present | ||
end | ||
|
||
newparam(:name) do | ||
desc "The key name of the handler" | ||
end | ||
|
||
newproperty(:config) do | ||
desc "Configuration for the handler" | ||
end | ||
|
||
autorequire(:package) do | ||
['sensu'] | ||
end | ||
|
||
autorequire(:file) do | ||
['/etc/sensu/handlers'] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters