forked from DataDog/puppet-datadog-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
datadog integration for twemproxy, options for haproxy (DataDog#326)
* add instances parameter * building config from instances * spec test for instances set * adding datadog integration for twemproxy * add options to haproxy integration * following instances pattern for twemproxy integration * fix twemproxy template typo * fix twemproxy template typo * fix twemproxy param error * fix spec test
- Loading branch information
Showing
6 changed files
with
147 additions
and
12 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
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,53 @@ | ||
# Class: datadog_agent::integrations::twemproxy | ||
# | ||
# This class will install the necessary configuration for the twemproxy aka nutcracker integration | ||
# | ||
# Parameters: | ||
# $host: | ||
# The host twemproxy is running on. Defaults to '127.0.0.1' | ||
# $port | ||
# The twemproxy password for the datadog user. Defaults to 22222 | ||
# | ||
# Sample Usage: | ||
# | ||
# class { 'datadog_agent::integrations::twemproxy' : | ||
# instances => [ | ||
# { | ||
# 'host' => 'localhost', | ||
# 'port' => '22222', | ||
# }, | ||
# { | ||
# 'host' => 'localhost', | ||
# 'port' => '22223', | ||
# }, | ||
# ] | ||
# } | ||
# | ||
class datadog_agent::integrations::twemproxy( | ||
$host = 'localhost', | ||
$port = '22222', | ||
$instances = undef, | ||
) inherits datadog_agent::params { | ||
include datadog_agent | ||
|
||
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, | ||
owner => $datadog_agent::params::dd_user, | ||
group => $datadog_agent::params::dd_group, | ||
mode => '0600', | ||
content => template('datadog_agent/agent-conf.d/twemproxy.yaml.erb'), | ||
require => Package[$datadog_agent::params::package_name], | ||
notify => Service[$datadog_agent::params::service_name] | ||
} | ||
} |
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
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,46 @@ | ||
require 'spec_helper' | ||
|
||
describe 'datadog_agent::integrations::twemproxy' do | ||
let(:facts) {{ | ||
operatingsystem: 'Ubuntu', | ||
}} | ||
let(:conf_dir) { '/etc/dd-agent/conf.d' } | ||
let(:dd_user) { 'dd-agent' } | ||
let(:dd_group) { 'root' } | ||
let(:dd_package) { 'datadog-agent' } | ||
let(:dd_service) { 'datadog-agent' } | ||
let(:conf_file) { "#{conf_dir}/twemproxy.yaml" } | ||
|
||
it { should compile.with_all_deps } | ||
it { should contain_file(conf_file).with( | ||
owner: dd_user, | ||
group: dd_group, | ||
mode: '0600', | ||
)} | ||
it { should contain_file(conf_file).that_requires("Package[#{dd_package}]") } | ||
it { should contain_file(conf_file).that_notifies("Service[#{dd_service}]") } | ||
|
||
context 'with default parameters' do | ||
it { should contain_file(conf_file).with_content(%r{host: localhost}) } | ||
it { should contain_file(conf_file).with_content(%r{port: 22222}) } | ||
end | ||
|
||
context 'with parameters set' do | ||
let(:params) {{ | ||
instances: [ | ||
{ | ||
'host' => 'twemproxy1', | ||
'port' => '1234', | ||
}, | ||
{ | ||
'host' => 'twemproxy2', | ||
'port' => '4567', | ||
} | ||
] | ||
}} | ||
it { should contain_file(conf_file).with_content(%r{host: twemproxy1}) } | ||
it { should contain_file(conf_file).with_content(%r{port: 1234}) } | ||
it { should contain_file(conf_file).with_content(%r{host: twemproxy2}) } | ||
it { should contain_file(conf_file).with_content(%r{port: 4567}) } | ||
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
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,11 @@ | ||
# | ||
# MANAGED BY PUPPET | ||
# | ||
|
||
init_config: | ||
|
||
instances: | ||
<%- (Array(@_instances)).each do |instance| -%> | ||
- host: <%= instance['host'] %> | ||
port: <%= instance['port'] %> | ||
<% end -%> |