Skip to content

Commit a07c1f4

Browse files
authored
Merge pull request #213 from cristianjuve/cristian/add-riak-integration
Riak integration files
2 parents 35a44b9 + 70109f1 commit a07c1f4

3 files changed

Lines changed: 128 additions & 0 deletions

File tree

manifests/integrations/riak.pp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Class: datadog_agent::integrations::riak
2+
#
3+
# This class will install the necessary configuration for the riak integration
4+
#
5+
# Parameters:
6+
# $url:
7+
# The URL for riak
8+
# $tags
9+
# Optional array of tags
10+
#
11+
# Sample Usage:
12+
#
13+
# include 'datadog_agent::integrations::riak'
14+
#
15+
# OR
16+
#
17+
# class { 'datadog_agent::integrations::riak' :
18+
# url => 'http://localhost:8098/stats',
19+
# }
20+
#
21+
class datadog_agent::integrations::riak(
22+
$url = 'http://localhost:8098/stats',
23+
$tags = [],
24+
) inherits datadog_agent::params {
25+
include datadog_agent
26+
27+
validate_string($url)
28+
validate_array($tags)
29+
30+
file {
31+
"${datadog_agent::params::conf_dir}/riak.yaml":
32+
ensure => file,
33+
owner => $datadog_agent::params::dd_user,
34+
group => $datadog_agent::params::dd_group,
35+
mode => '0644',
36+
content => template('datadog_agent/agent-conf.d/riak.yaml.erb'),
37+
require => Package[$datadog_agent::params::package_name],
38+
notify => Service[$datadog_agent::params::service_name]
39+
}
40+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
require 'spec_helper'
2+
3+
describe 'datadog_agent::integrations::riak' do
4+
let(:facts) {{
5+
operatingsystem: 'Ubuntu',
6+
}}
7+
let(:conf_dir) { '/etc/dd-agent/conf.d' }
8+
let(:dd_user) { 'dd-agent' }
9+
let(:dd_group) { 'root' }
10+
let(:dd_package) { 'datadog-agent' }
11+
let(:dd_service) { 'datadog-agent' }
12+
let(:conf_file) { "#{conf_dir}/riak.yaml" }
13+
14+
it { should compile.with_all_deps }
15+
it { should contain_file(conf_file).with(
16+
owner: dd_user,
17+
group: dd_group,
18+
mode: '0644',
19+
)}
20+
it { should contain_file(conf_file).that_requires("Package[#{dd_package}]") }
21+
it { should contain_file(conf_file).that_notifies("Service[#{dd_service}]") }
22+
23+
context 'with default parameters' do
24+
it { should contain_file(conf_file).with_content(%r{url: http://localhost:8098/stats}) }
25+
it { should contain_file(conf_file).without_content(%r{tags: }) }
26+
end
27+
28+
context 'with parameters set' do
29+
let(:params) {{
30+
url: 'http://foo.bar.baz:8098/stats',
31+
tags: %w{ foo bar baz },
32+
}}
33+
it { should contain_file(conf_file).with_content(%r{url: http://foo.bar.baz:8098/stats}) }
34+
it { should contain_file(conf_file).with_content(/tags:\s+- foo\s+- bar\s+- baz\s*?[^-]/m) }
35+
end
36+
context 'with tags parameter single value' do
37+
let(:params) {{
38+
tags: 'foo',
39+
}}
40+
it { should_not compile }
41+
42+
skip "this is currently unimplemented behavior" do
43+
it { should contain_file(conf_file).with_content(/tags:\s+- foo\s*?[^-]/m) }
44+
end
45+
end
46+
context 'with tags parameter array' do
47+
let(:params) {{
48+
tags: %w{ foo bar baz },
49+
}}
50+
it { should contain_file(conf_file).with_content(/tags:\s+- foo\s+- bar\s+- baz\s*?[^-]/m) }
51+
end
52+
context 'with tags parameter empty values' do
53+
context 'mixed in with other tags' do
54+
let(:params) {{
55+
tags: [ 'foo', '', 'baz' ]
56+
}}
57+
it { should contain_file(conf_file).with_content(/tags:\s+- foo\s+- baz\s*?[^-]/m) }
58+
end
59+
60+
context 'single element array of an empty string' do
61+
let(:params) {{
62+
tags: [''],
63+
}}
64+
65+
skip("undefined behavior")
66+
end
67+
68+
context 'single value empty string' do
69+
let(:params) {{
70+
tags: '',
71+
}}
72+
73+
skip("doubly undefined behavior")
74+
end
75+
end
76+
end
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
init_config:
2+
3+
instances:
4+
- url: <%= @url %>
5+
<% if @tags and ! @tags.empty? -%>
6+
tags:
7+
<%- Array(@tags).each do |tag| -%>
8+
<%- if tag != '' -%>
9+
- <%= tag %>
10+
<%- end -%>
11+
<%- end -%>
12+
<% end -%>

0 commit comments

Comments
 (0)