Skip to content

Commit aae4cf8

Browse files
stamaktruthbk
authored andcommitted
Add parameters to ceph integration (#322)
Closes: #321
1 parent cc4d7ad commit aae4cf8

3 files changed

Lines changed: 34 additions & 2 deletions

File tree

manifests/integrations/ceph.pp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,24 @@
33
# This class will install the necessary configuration for the ceph integration
44
#
55
# Parameters:
6+
# $tags
7+
# Optional array of tags
8+
# $ceph_cmd
9+
# Optional ceph cmd
610

711
# Sample Usage:
812
#
913
# class { 'datadog_agent::integrations::ceph' :
1014
# }
1115
#
1216
class datadog_agent::integrations::ceph(
17+
$tags = [ 'name:ceph_cluster' ],
18+
$ceph_cmd = '/usr/bin/ceph',
1319
) inherits datadog_agent::params {
1420
include datadog_agent
1521

22+
validate_array($tags)
23+
1624
file { '/etc/sudoers.d/datadog_ceph':
1725
content => "# This file is required for dd ceph \ndd-agent ALL=(ALL) NOPASSWD:/usr/bin/ceph\n"
1826
}

spec/classes/datadog_agent_integrations_ceph_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,24 @@
2828
it { should contain_file(sudo_conf_file).with_content(/^dd-agent\sALL=.*NOPASSWD:\/usr\/bin\/ceph$/) }
2929
end
3030

31+
context 'with specified tag' do
32+
let(:params) {{
33+
tags: ['name:my_ceph_cluster'],
34+
}}
35+
it { should contain_file(conf_file).with_content(/tags:\s+- name:my_ceph_cluster\s*?[^-]/m) }
36+
it { should contain_file(conf_file).with_content(/^\s*ceph_cmd:\s*\/usr\/bin\/ceph\s*?[^-]/m) }
37+
it { should contain_file(conf_file).with_content(/^\s*use_sudo:\sTrue$/) }
38+
it { should contain_file(sudo_conf_file).with_content(/^dd-agent\sALL=.*NOPASSWD:\/usr\/bin\/ceph$/) }
39+
end
40+
41+
context 'with specified ceph_cmd' do
42+
let(:params) {{
43+
ceph_cmd: '/usr/local/myceph',
44+
}}
45+
it { should contain_file(conf_file).with_content(/tags:\s+- name:ceph_cluster\s*?[^-]/m) }
46+
it { should contain_file(conf_file).with_content(/^\s*ceph_cmd:\s*\/usr\/local\/myceph\s*?[^-]/m) }
47+
it { should contain_file(conf_file).with_content(/^\s*use_sudo:\sTrue$/) }
48+
it { should contain_file(sudo_conf_file).with_content(/^dd-agent\sALL=.*NOPASSWD:\/usr\/bin\/ceph$/) }
49+
end
50+
3151
end

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
init_config:
22

33
instances:
4+
<% if @tags and ! @tags.empty? -%>
45
- tags:
5-
- name:ceph_cluster
6+
<%- @tags.each do |tag| -%>
7+
- <%= tag %>
8+
<%- end -%>
9+
<% end -%>
610

7-
ceph_cmd: /usr/bin/ceph
11+
ceph_cmd: <%= @ceph_cmd %>
812

913
# If your environment requires sudo, please add a line like:
1014
# dd-agent ALL=(ALL) NOPASSWD:/usr/bin/ceph

0 commit comments

Comments
 (0)