File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99# Sample Usage:
1010#
1111# class { 'datadog_agent::integrations::haproxy' :
12- # url => 'http://localhost:8080',
13- # creds => { username => 'admin',
14- # password => 'password',
15- # },
12+ # url => 'http://localhost:8080',
13+ # creds => { username => 'admin',
14+ # password => 'password',
15+ # },
16+ # options => { collect_aggregates_only => 'False' },
1617# }
1718#
1819class datadog_agent::integrations::haproxy (
1920 $creds = {},
2021 $url = " http://${::ipaddress} :8080" ,
22+ $options = {},
2123 $instances = undef ,
2224) inherits datadog_agent::params {
2325 include datadog_agent
2426
2527 if !$instances and $url {
2628 $_instances = [{
27- ' creds' => $creds ,
28- ' url' => $url ,
29+ ' creds' => $creds ,
30+ ' url' => $url ,
31+ ' options' => $options ,
2932 }]
3033 } elsif !$instances {
3134 $_instances = []
Original file line number Diff line number Diff line change 5555 end
5656 end
5757
58+ context 'with options set' do
59+ let ( :params ) { {
60+ options : {
61+ 'optionk' => 'optionv' ,
62+ } ,
63+ } }
64+ it { should contain_file ( conf_file ) . with_content ( %r{optionk: optionv} ) }
65+ end
66+
5867 context 'with instances set' do
5968 let ( :params ) { {
6069 instances : [
6170 {
62- 'url' => 'http://foo.bar:8421' ,
63- 'creds' => {
71+ 'url' => 'http://foo.bar:8421' ,
72+ 'creds' => {
6473 'username' => 'foo' ,
6574 'password' => 'bar' ,
66- }
75+ } ,
76+ 'options' => {
77+ 'optionk1' => 'optionv1' ,
78+ } ,
6779 } ,
6880 {
69- 'url' => 'http://shoe.baz:1248' ,
70- 'creds' => {
81+ 'url' => 'http://shoe.baz:1248' ,
82+ 'creds' => {
7183 'username' => 'shoe' ,
7284 'password' => 'baz' ,
73- }
85+ } ,
86+ 'options' => {
87+ 'optionk2' => 'optionv2' ,
88+ } ,
7489 } ,
7590 ]
7691 } }
7792 it { should contain_file ( conf_file ) . with_content ( %r{url: http://foo.bar:8421} ) }
7893 it { should contain_file ( conf_file ) . with_content ( %r{username: foo} ) }
7994 it { should contain_file ( conf_file ) . with_content ( %r{password: bar} ) }
95+ it { should contain_file ( conf_file ) . with_content ( %r{optionk1: optionv1} ) }
8096 it { should contain_file ( conf_file ) . with_content ( %r{url: http://shoe.baz:1248} ) }
8197 it { should contain_file ( conf_file ) . with_content ( %r{username: shoe} ) }
8298 it { should contain_file ( conf_file ) . with_content ( %r{password: baz} ) }
99+ it { should contain_file ( conf_file ) . with_content ( %r{optionk2: optionv2} ) }
83100 end
84101end
Original file line number Diff line number Diff line change @@ -13,4 +13,9 @@ instances:
1313 <%= k %> : <%= v %>
1414 <%- end -%>
1515 <%- end -%>
16+ <%- if instance['options'] -%>
17+ <%- instance['options'].each do |k, v| -%>
18+ <%= k %> : <%= v %>
19+ <%- end -%>
20+ <%- end -%>
1621<% end -%>
You can’t perform that action at this time.
0 commit comments