-
Notifications
You must be signed in to change notification settings - Fork 289
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simple type to manage the dashboard configuration
- Loading branch information
Showing
2 changed files
with
104 additions
and
0 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,63 @@ | ||
require 'json' | ||
|
||
Puppet::Type.type(:sensu_dashboard_config).provide(:json) do | ||
def initialize(*args) | ||
super | ||
|
||
@conf = JSON.parse(File.read('/etc/sensu/config.json')) | ||
end | ||
|
||
def flush | ||
File.open('/etc/sensu/config.json', 'w') do |f| | ||
f.puts JSON.pretty_generate(@conf) | ||
end | ||
end | ||
|
||
def create | ||
@conf['dashboard'] = {} | ||
self.port = resource[:port] | ||
self.host = resource[:host] | ||
self.user = resource[:user] | ||
self.password = resource[:password] | ||
end | ||
|
||
def destroy | ||
@conf.delete 'dashboard' | ||
end | ||
|
||
def exists? | ||
@conf.has_key? 'dashboard' | ||
end | ||
|
||
def port | ||
@conf['dashboard']['port'].to_s | ||
end | ||
|
||
def port=(value) | ||
@conf['dashboard']['port'] = value.to_i | ||
end | ||
|
||
def host | ||
@conf['dashboard']['host'] | ||
end | ||
|
||
def host=(value) | ||
@conf['dashboard']['host'] = value | ||
end | ||
|
||
def user | ||
@conf['dashboard']['user'] | ||
end | ||
|
||
def user=(value) | ||
@conf['dashboard']['user'] = value | ||
end | ||
|
||
def password | ||
@conf['dashboard']['password'] | ||
end | ||
|
||
def password=(value) | ||
@conf['dashboard']['password'] = 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,41 @@ | ||
Puppet::Type.newtype(:sensu_dashboard_config) do | ||
@doc = "" | ||
|
||
ensurable do | ||
newvalue(:present) do | ||
provider.create | ||
end | ||
|
||
newvalue(:absent) do | ||
provider.destroy | ||
end | ||
|
||
defaultto :present | ||
end | ||
|
||
newparam(:name) do | ||
desc "This value has no effect, set it to what ever you want." | ||
end | ||
|
||
newproperty(:port) do | ||
desc "The port that the Sensu Dashboard should listen on" | ||
|
||
defaultto '5671' | ||
end | ||
|
||
newproperty(:host) do | ||
desc "The hostname that the Sensu Dashboard should listen on" | ||
|
||
defaultto 'localhost' | ||
end | ||
|
||
newproperty(:user) do | ||
desc "The username to use when connecting to the Sensu Dashboard" | ||
|
||
defaultto 'sensu' | ||
end | ||
|
||
newproperty(:password) do | ||
desc "The password to use when connecting to the Sensu Dashboard" | ||
end | ||
end |