[puppet] parametrize dogapi version for puppet reporting.
diff --git a/manifests/init.pp b/manifests/init.pp
index b74054e..f57675f 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -341,6 +341,7 @@
class { 'datadog_agent::reports':
api_key => $api_key,
puppetmaster_user => $puppetmaster_user,
+ dogapi_version => $datadog_agent::params::dogapi_version,
hostname_extraction_regex => $hostname_extraction_regex,
}
}
diff --git a/manifests/reports.pp b/manifests/reports.pp
index c9e2baa..7ffd20c 100644
--- a/manifests/reports.pp
+++ b/manifests/reports.pp
@@ -16,6 +16,7 @@
class datadog_agent::reports(
$api_key,
$puppetmaster_user,
+ $dogapi_version,
$hostname_extraction_regex = nil
) {
@@ -48,7 +49,7 @@
}
package{'dogapi':
- ensure => $datadog_agent::params::dogapi_version,
+ ensure => $dogapi_version,
provider => $gemprovider,
}
diff --git a/spec/classes/datadog_agent_reports_spec.rb b/spec/classes/datadog_agent_reports_spec.rb
index 4d72a82..a5026ee 100644
--- a/spec/classes/datadog_agent_reports_spec.rb
+++ b/spec/classes/datadog_agent_reports_spec.rb
@@ -1,15 +1,15 @@
require 'spec_helper'
describe 'datadog_agent::reports' do
- let(:params) do
- {
- api_key: 'notanapikey',
- hostname_extraction_regex: nil,
- puppetmaster_user: 'puppet'
- }
- end
-
context 'all supported operating systems' do
+ let(:params) do
+ {
+ api_key: 'notanapikey',
+ hostname_extraction_regex: nil,
+ puppetmaster_user: 'puppet',
+ dogapi_version: 'installed'
+ }
+ end
ALL_OS.each do |operatingsystem|
describe "datadog_agent class common actions on #{operatingsystem}" do
let(:facts) do
@@ -53,4 +53,45 @@
end
end
end
+ context 'specific dogapi version' do
+ let(:params) do
+ {
+ api_key: 'notanapikey',
+ hostname_extraction_regex: nil,
+ puppetmaster_user: 'puppet',
+ dogapi_version: '1.2.2'
+ }
+ end
+ describe "datadog_agent class dogapi version override" do
+ let(:facts) do
+ {
+ operatingsystem: 'Debian',
+ osfamily: 'debian'
+ }
+ end
+
+ it { should contain_class('ruby').with_rubygems_update(false) }
+ it { should contain_class('ruby::params') }
+ it { should contain_package('ruby').with_ensure('installed') }
+ it { should contain_package('rubygems').with_ensure('installed') }
+
+ it do
+ should contain_package('ruby-dev')\
+ .with_ensure('installed')\
+ .that_comes_before('Package[dogapi]')
+ end
+
+ it do
+ should contain_package('dogapi')\
+ .with_ensure('1.2.2')
+ .with_provider('gem')
+ end
+
+ it do
+ should contain_file('/etc/dd-agent/datadog.yaml')\
+ .with_owner('puppet')\
+ .with_group('root')
+ end
+ end
+ end
end