Skip to content

Commit ed172a2

Browse files
committed
Added a define that wraps the agent integration command
1 parent 3e08d06 commit ed172a2

3 files changed

Lines changed: 70 additions & 0 deletions

File tree

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,22 @@ Once the `datadog_agent` module is installed on your `puppetserver`/`puppetmaste
147147
}
148148
```
149149
150+
Installing and pinning specific versions of integrations
151+
--------------------------------------------------------
152+
153+
You can specify a given integration and version number to be installed by using `datadog_agent::install_integration`. This will use the `datadog-agent integration` command to ensure a specific integration is installed or uninstalled.
154+
155+
```
156+
datadog_agent::install_integration { "mongo-1.9":
157+
ensure => present,
158+
integration_name => 'datadog-mongo',
159+
version => '1.9.0',
160+
}
161+
```
162+
163+
The field `ensure` can be either `present` (default) or `absent`, the later being useful to remove a previously pinned version of an integration.
164+
165+
150166
Reporting
151167
---------
152168
Ensure `dogapi-rb` is available on your system as explained earlier.

manifests/install_integration.pp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
define datadog_agent::install_integration (
2+
Enum['present', 'absent'] $ensure = 'present',
3+
String $integration_name = undef,
4+
String $version = undef,
5+
){
6+
7+
include datadog_agent
8+
9+
if $ensure == 'present' {
10+
$command = 'install'
11+
} else {
12+
$command = 'remove'
13+
}
14+
15+
exec { "${command} ${integration_name}==${version}":
16+
command => "/opt/datadog-agent/bin/agent/agent integration ${command} ${integration_name}==${version}",
17+
user => 'dd-agent',
18+
require => Package[$datadog_agent::params::package_name],
19+
}
20+
21+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
require 'spec_helper'
2+
3+
describe "datadog_agent::install_integration" do
4+
5+
describe "installing an integration" do
6+
let(:pre_condition) { "class {'::datadog_agent': }" }
7+
let (:title) { "test" }
8+
let (:params) {{
9+
:integration_name => "datadog-mongo",
10+
:version => "1.9.0",
11+
}}
12+
13+
it { should compile }
14+
15+
it { is_expected.to contain_exec("install datadog-mongo==1.9.0").with_command("/opt/datadog-agent/bin/agent/agent integration install datadog-mongo==1.9.0") }
16+
17+
end
18+
19+
describe "removing an integration" do
20+
let(:pre_condition) { "class {'::datadog_agent': }" }
21+
let (:title) { "test" }
22+
let (:params) {{
23+
:integration_name => "datadog-mongo",
24+
:version => "1.9.0",
25+
:ensure => "absent",
26+
}}
27+
28+
it { should compile }
29+
30+
it { is_expected.to contain_exec("remove datadog-mongo==1.9.0").with_command("/opt/datadog-agent/bin/agent/agent integration remove datadog-mongo==1.9.0") }
31+
32+
end
33+
end

0 commit comments

Comments
 (0)