Skip to content

Commit 5a70b44

Browse files
committed
following instances pattern for twemproxy integration
1 parent 0040520 commit 5a70b44

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

manifests/integrations/twemproxy.pp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# Sample Usage:
1212
#
1313
# class { 'datadog_agent::integrations::twemproxy' :
14-
# servers => [
14+
# instances => [
1515
# {
1616
# 'host' => 'localhost',
1717
# 'port' => '22222',
@@ -24,11 +24,22 @@
2424
# }
2525
#
2626
class datadog_agent::integrations::twemproxy(
27-
$servers = [{'host' => 'localhost', 'port' => '22222'}]
27+
$host = 'localhost',
28+
$port = '22222',
29+
$instances = [],
2830
) inherits datadog_agent::params {
2931
include datadog_agent
3032

31-
validate_array($servers)
33+
if !$instances and $host {
34+
$_instances = [{
35+
'host' => $host,
36+
'port' => $port,
37+
}]
38+
} elsif !$instances{
39+
$_instances = []
40+
} else {
41+
$_instances = $instances
42+
}
3243

3344
file { "${datadog_agent::params::conf_dir}/twemproxy.yaml":
3445
ensure => file,

templates/agent-conf.d/twemproxy.yaml.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
init_config:
66

77
instances:
8-
<% @servers.each do |server| -%>
8+
<% @instances.each do |server| -%>
99
- host: <%= server['host'] %>
1010
port: <%= server['port'] %>
1111
<% end -%>

0 commit comments

Comments
 (0)