Commit 55d4957 1 parent ae7d6da commit 55d4957 Copy full SHA for 55d4957
File tree 2 files changed +76
-0
lines changed
provider/sensu_redis_config
2 files changed +76
-0
lines changed Original file line number Diff line number Diff line change
1
+ require 'json'
2
+
3
+ Puppet ::Type . type ( :sensu_redis_config ) . provide ( :json ) do
4
+ def initialize ( *args )
5
+ super
6
+
7
+ @conf = JSON . parse ( File . read ( '/etc/sensu/config.json' ) )
8
+ end
9
+
10
+ def flush
11
+ File . open ( '/etc/sensu/config.json' , 'w' ) do |f |
12
+ f . puts JSON . pretty_generate ( @conf )
13
+ end
14
+ end
15
+
16
+ def create
17
+ @conf [ 'redis' ] = { }
18
+ self . port = resource [ :port ]
19
+ self . host = resource [ :host ]
20
+ end
21
+
22
+ def destroy
23
+ @conf . delete 'redis'
24
+ end
25
+
26
+ def exists?
27
+ @conf . has_key? 'redis'
28
+ end
29
+
30
+ def port
31
+ @conf [ 'redis' ] [ 'port' ] . to_s
32
+ end
33
+
34
+ def port = ( value )
35
+ @conf [ 'redis' ] [ 'port' ] = value . to_i
36
+ end
37
+
38
+ def host
39
+ @conf [ 'redis' ] [ 'host' ]
40
+ end
41
+
42
+ def host = ( value )
43
+ @conf [ 'redis' ] [ 'host' ] = value
44
+ end
45
+ end
Original file line number Diff line number Diff line change
1
+ Puppet ::Type . newtype ( :sensu_redis_config ) do
2
+ @doc = ""
3
+
4
+ ensurable do
5
+ newvalue ( :present ) do
6
+ provider . create
7
+ end
8
+
9
+ newvalue ( :absent ) do
10
+ provider . destroy
11
+ end
12
+
13
+ defaultto :present
14
+ end
15
+
16
+ newparam ( :name ) do
17
+ desc "This value has no effect, set it to what ever you want."
18
+ end
19
+
20
+ newproperty ( :port ) do
21
+ desc "The port that Redis is listening on"
22
+
23
+ defaultto '6379'
24
+ end
25
+
26
+ newproperty ( :host ) do
27
+ desc "The hostname that Redis is listening on"
28
+
29
+ defaultto 'localhost'
30
+ end
31
+ end
You can’t perform that action at this time.
0 commit comments