Skip to content

Commit 073edff

Browse files
author
Thom Duran
committed
Add api bind param
1 parent 3b86e55 commit 073edff

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed

lib/puppet/provider/sensu_api_config/json.rb

+18-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def flush
3030
# Returns nothing.
3131
def create
3232
conf['api'] = {}
33+
self.bind = resource[:bind]
3334
self.port = resource[:port]
3435
self.host = resource[:host]
3536
self.user = resource[:user] unless resource[:user].nil?
@@ -50,14 +51,30 @@ def exists?
5051
conf.has_key? 'api'
5152
end
5253

54+
55+
# Public: Retrieve the bind IP that the API is bound on the server
56+
#
57+
# Returns the String bind IP
58+
59+
def bind
60+
conf['api']['bind']
61+
end
62+
63+
# Public: Set the IP that bind will use.
64+
#
65+
# Returns nothing.
66+
67+
def bind=(value)
68+
conf['api']['bind'] = value
69+
end
70+
5371
# Public: Retrieve the port number that the API is configured to listen on.
5472
#
5573
# Returns the String port number.
5674
def port
5775
conf['api']['port'].to_s
5876
end
5977

60-
6178
def config_file
6279
"#{resource[:base_path]}/api.json"
6380
end

lib/puppet/type/sensu_api_config.rb

+6
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ def initialize(*args)
3838
defaultto 'localhost'
3939
end
4040

41+
newproperty(:bind) do
42+
desc "The bind IP that sensu will bind to"
43+
44+
defaultto '0.0.0.0'
45+
end
46+
4147
newparam(:base_path) do
4248
desc "The base path to the client config file"
4349
defaultto '/etc/sensu/conf.d/'

manifests/api/config.pp

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
sensu_api_config { $::fqdn:
2525
ensure => $ensure,
26+
bind => $sensu::api_bind,
2627
host => $sensu::api_host,
2728
port => $sensu::api_port,
2829
user => $sensu::api_user,

manifests/init.pp

+4
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@
9191
# Integer. Redis port to be used by sensu
9292
# Default: 6379
9393
#
94+
# [*api_bind*]
95+
# String. IP to bind api service
96+
# Default: 0.0.0.0
9497
# [*api_host*]
9598
# String. Hostname of the sensu api service
9699
# Default: localhost
@@ -187,6 +190,7 @@
187190
$rabbitmq_ssl_cert_chain = undef,
188191
$redis_host = 'localhost',
189192
$redis_port = 6379,
193+
$api_bind = '0.0.0.0',
190194
$api_host = 'localhost',
191195
$api_port = 4567,
192196
$api_user = undef,

0 commit comments

Comments
 (0)