Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions manifests/integrations/ceph.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Class: datadog_agent::integrations::ceph
#
# This class will install the necessary configuration for the ceph integration
#
# Parameters:

# Sample Usage:
#
# class { 'datadog_agent::integrations::ceph' :
# }
#
class datadog_agent::integrations::ceph(
) inherits datadog_agent::params {
include datadog_agent

file { '/etc/sudoers.d/datadog_ceph':
content => "# This file is required for dd ceph \ndd-agent ALL=(ALL) NOPASSWD:/usr/bin/ceph\n"
}

file { "${datadog_agent::params::conf_dir}/ceph.yaml":
ensure => file,
owner => $datadog_agent::params::dd_user,
group => $datadog_agent::params::dd_group,
mode => '0600',
content => template('datadog_agent/agent-conf.d/ceph.yaml.erb'),
require => Package[$datadog_agent::params::package_name],
notify => Service[$datadog_agent::params::service_name]
}
}
31 changes: 31 additions & 0 deletions spec/classes/datadog_agent_integrations_ceph_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
require 'spec_helper'

describe 'datadog_agent::integrations::ceph' 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}/ceph.yaml" }
let(:sudo_conf_file) { '/etc/sudoers.d/datadog_ceph' }

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(/tags:\s+- name:ceph_cluster\s*?[^-]/m) }
it { should contain_file(conf_file).with_content(/^\s*ceph_cmd:\s*\/usr\/bin\/ceph\s*?[^-]/m) }
it { should contain_file(conf_file).with_content(/^\s*use_sudo:\sTrue$/) }
it { should contain_file(sudo_conf_file).with_content(/^dd-agent\sALL=.*NOPASSWD:\/usr\/bin\/ceph$/) }
end

end
13 changes: 13 additions & 0 deletions templates/agent-conf.d/ceph.yaml.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
init_config:

instances:
- tags:
- name:ceph_cluster

ceph_cmd: /usr/bin/ceph

# If your environment requires sudo, please add a line like:
# dd-agent ALL=(ALL) NOPASSWD:/usr/bin/ceph
# to your sudoers file, and uncomment the below option.

use_sudo: True