Skip to content

Commit

Permalink
following instances pattern for twemproxy integration
Browse files Browse the repository at this point in the history
  • Loading branch information
swwolf committed Jun 28, 2017
1 parent 0040520 commit 5a70b44
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
17 changes: 14 additions & 3 deletions manifests/integrations/twemproxy.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# Sample Usage:
#
# class { 'datadog_agent::integrations::twemproxy' :
# servers => [
# instances => [
# {
# 'host' => 'localhost',
# 'port' => '22222',
Expand All @@ -24,11 +24,22 @@
# }
#
class datadog_agent::integrations::twemproxy(
$servers = [{'host' => 'localhost', 'port' => '22222'}]
$host = 'localhost',
$port = '22222',
$instances = [],
) inherits datadog_agent::params {
include datadog_agent

validate_array($servers)
if !$instances and $host {
$_instances = [{
'host' => $host,
'port' => $port,
}]
} elsif !$instances{
$_instances = []
} else {
$_instances = $instances
}

file { "${datadog_agent::params::conf_dir}/twemproxy.yaml":
ensure => file,
Expand Down
2 changes: 1 addition & 1 deletion templates/agent-conf.d/twemproxy.yaml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
init_config:

instances:
<% @servers.each do |server| -%>
<% @instances.each do |server| -%>
- host: <%= server['host'] %>
port: <%= server['port'] %>
<% end -%>

0 comments on commit 5a70b44

Please sign in to comment.