Skip to content

Commit

Permalink
[puppet] parametrize dogapi version for puppet reporting.
Browse files Browse the repository at this point in the history
  • Loading branch information
truthbk committed Jul 28, 2016
1 parent 8c7ad63 commit 7ac92d8
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 9 deletions.
1 change: 1 addition & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
Expand Down
3 changes: 2 additions & 1 deletion manifests/reports.pp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
class datadog_agent::reports(
$api_key,
$puppetmaster_user,
$dogapi_version,
$hostname_extraction_regex = nil
) {

Expand Down Expand Up @@ -48,7 +49,7 @@
}

package{'dogapi':
ensure => $datadog_agent::params::dogapi_version,
ensure => $dogapi_version,
provider => $gemprovider,
}

Expand Down
57 changes: 49 additions & 8 deletions spec/classes/datadog_agent_reports_spec.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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

0 comments on commit 7ac92d8

Please sign in to comment.