Skip to content

Commit e0e7f09

Browse files
author
Darren Gipson
committed
Merge branch 'xenon8/puppet-8-upgrade' of https://github.com/xenon8/puppet-datadog-agent into xenon8/puppet-8-upgrade
2 parents 660afb4 + ff83c8a commit e0e7f09

9 files changed

Lines changed: 114 additions & 29 deletions

File tree

Gemfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,20 @@ group :development do
4646
gem "metadata-json-lint", '~> 3.0.3', require: false
4747
gem "voxpupuli-puppet-lint-plugins", '~> 4.0', require: false
4848
gem "dependency_checker", '= 0.3.0', require: false
49+
gem 'puppet-lint', '~> 3.4.0', require: false
4950
else
50-
gem "facterdb", '~> 3.4.0', require: false
51+
gem "facterdb", '~> 3.4.0', require: false
5152
gem "test-kitchen", '~> 3.7.0'
5253
gem "rubocop", '~> 1.50.0', require: false
5354
gem "rubocop-rspec", '= 2.19.0', require: false
54-
gem "rspec-puppet-facts", '~> 5.2.0', require: false
55+
gem "rspec-puppet-facts", '~> 5.2.0', require: false
5556
gem "rubocop-performance", '= 1.16.0', require: false
5657
gem "librarian-puppet", '~> 5.0'
5758
gem "io-console", '= 0.7.2', require: false
5859
gem "metadata-json-lint", '~> 4.0', require: false
5960
gem "voxpupuli-puppet-lint-plugins", '~> 5.0', require: false
6061
gem "dependency_checker", '~> 1.0.0', require: false
62+
gem 'puppet-lint', '~> 4.3.0', require: false
6163
end
6264
end
6365
group :development, :release_prep do

Gemfile.lock

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ GEM
2323
aws-eventstream (~> 1, >= 1.0.2)
2424
base64 (0.2.0)
2525
bcrypt_pbkdf (1.0.1)
26+
bcrypt_pbkdf (1.0.1-x64-mingw32)
2627
bigdecimal (3.1.9)
2728
bindata (2.5.0)
2829
bolt (4.0.0)
@@ -91,7 +92,6 @@ GEM
9192
fast_gettext (2.4.0)
9293
prime
9394
ffi (1.17.1)
94-
ffi (1.17.1-arm64-darwin)
9595
forwardable (1.3.3)
9696
getoptlong (0.2.1)
9797
gettext (3.5.1)
@@ -223,18 +223,6 @@ GEM
223223
puppet-resource_api (~> 1.5)
224224
scanf (~> 1.0)
225225
semantic_puppet (~> 1.0)
226-
puppet (8.10.0-universal-darwin)
227-
CFPropertyList (>= 3.0.6, < 4)
228-
concurrent-ruby (~> 1.0)
229-
deep_merge (~> 1.0)
230-
facter (>= 4.3.0, < 5)
231-
fast_gettext (>= 2.1, < 4)
232-
getoptlong (~> 0.2.0)
233-
locale (~> 2.1)
234-
multi_json (~> 1.13)
235-
puppet-resource_api (~> 1.5)
236-
scanf (~> 1.0)
237-
semantic_puppet (~> 1.0)
238226
puppet-blacksmith (7.1.0)
239227
puppet-modulebuilder (~> 1.0)
240228
rest-client (~> 2.0)
@@ -247,7 +235,7 @@ GEM
247235
rb-readline (>= 0.5.5)
248236
table_print (>= 1.0.0)
249237
tty-pager (~> 0.14)
250-
puppet-lint (4.2.4)
238+
puppet-lint (4.3.0)
251239
puppet-lint-absolute_classname-check (4.0.0)
252240
puppet-lint (>= 3.0, < 5)
253241
puppet-lint-anchor-check (2.0.0)
@@ -337,6 +325,12 @@ GEM
337325
http-cookie (>= 1.0.2, < 2.0)
338326
mime-types (>= 1.16, < 4.0)
339327
netrc (~> 0.8)
328+
rest-client (2.1.0-x64-mingw32)
329+
ffi (~> 1.9)
330+
http-accept (>= 1.7.0, < 2.0)
331+
http-cookie (>= 1.0.2, < 2.0)
332+
mime-types (>= 1.16, < 4.0)
333+
netrc (~> 0.8)
340334
retryable (3.0.5)
341335
rexml (3.4.1)
342336
rgen (0.10.2)
@@ -534,6 +528,7 @@ DEPENDENCIES
534528
puppet
535529
puppet-blacksmith (~> 7.0)
536530
puppet-debugger (~> 1.0)
531+
puppet-lint (~> 4.3.0)
537532
puppet-strings (~> 4.0)
538533
puppet_litmus (~> 1.0)
539534
puppetlabs_spec_helper (~> 8.0)

manifests/init.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@
799799

800800
if ($facts['os']['name'] == 'Windows') {
801801
file { 'C:/ProgramData/Datadog':
802-
ensure => directory,
802+
ensure => directory,
803803
}
804804

805805
file { 'C:/ProgramData/Datadog/datadog.yaml':

manifests/integrations/mongo.pp

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,20 @@
88
# NOTE: In newer versions of the Datadog Agent, the ssl parameters will be deprecated in favor the tls variants
99
#
1010
# Parameters:
11+
# $hosts
12+
# Array of hosts host (and optional port number) where the mongod instance is running
13+
# $dbm
14+
# Enable the Database Monitoring feature
15+
# $database_autodiscovery
16+
# Enable the Database Autodiscovery feature
17+
# $reported_database_hostname
18+
# Optional database hostname override the mongodb hostname detected by the Agent from mongodb admin command serverStatus
1119
# $additional_metrics
1220
# Optional array of additional metrics
1321
# $database
1422
# Optionally specify database to query. Defaults to 'admin'
15-
# $host:
16-
# The host mongo is running on. Defaults to '127.0.0.1'
1723
# $password
1824
# Optionally specify password for connection
19-
# $port
20-
# The port mongo is running on. Defaults to 27017
2125
# $ssl
2226
# Optionally enable SSL for connection
2327
# $ssl_ca_certs
@@ -40,6 +44,12 @@
4044
# Optional array of tags
4145
# $username
4246
# Optionally specify username for connection
47+
# $host:
48+
# Deprecated use $hosts instead
49+
# The host mongo is running on. Defaults to '127.0.0.1'
50+
# $port
51+
# Deprecated use $hosts instead
52+
# The port mongo is running on. Defaults to 27017
4353
#
4454
# Sample Usage (Older Agent Versions):
4555
#
@@ -76,19 +86,20 @@
7686
# {
7787
# 'additional_metrics' => ['top'],
7888
# 'database' => 'database_name',
79-
# 'host' => 'localhost',
89+
# 'hosts' => ['localhost:27017'],
8090
# 'password' => 'mongo_password',
81-
# 'port' => '27017',
8291
# 'tls' => true,
8392
# 'tls_ca_file' => '/path/to/ca.pem',
8493
# 'tls_allow_invalid_certificates' => false,
8594
# 'tls_certificate_key_file' => '/path/to/combined.pem',
8695
# 'tags' => ['optional_tag1', 'optional_tag2'],
8796
# 'username' => 'mongo_username',
97+
# 'dbm' => true,
98+
# 'database_autodiscovery' => {'enabled' => true},
99+
# 'reported_database_hostname' => 'mymongodbhost',
88100
# },
89101
# {
90-
# 'host' => 'localhost',
91-
# 'port' => '27018',
102+
# 'hosts' => ['localhost:27017'],
92103
# 'tags' => [],
93104
# 'additional_metrics' => [],
94105
# 'collections' => [],

manifests/integrations/redis.pp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,20 @@
1414
# The main redis port.
1515
# $ports
1616
# Array of redis ports: overrides port (optional)
17+
# $ssl
18+
# Enable SSL/TLS encryption for the check (optional)
19+
# $ssl_keyfile
20+
# The path to the client-side private keyfile (optional)
21+
# $ssl_certfile
22+
# The path to the client-side certificate file (optional)
23+
# $ssl_ca_certs
24+
# The path to the ca_certs file (optional)
25+
# $ssl_cert_reqs
26+
# Specifies whether a certificate is required from the
27+
# other side of the connection, and whether it's validated if provided (optional)
28+
# * 0 for ssl.CERT_NONE (certificates ignored)
29+
# * 1 for ssl.CERT_OPTIONAL (not required, but validated if provided)
30+
# * 2 for ssl.CERT_REQUIRED (required and validated)
1731
# $slowlog_max_len
1832
# The max length of the slow-query log (optional)
1933
# $tags
@@ -48,6 +62,11 @@
4862
String $password = '',
4963
Variant[String, Integer] $port = '6379',
5064
Optional[Array] $ports = undef,
65+
Boolean $ssl = false,
66+
String $ssl_keyfile = '',
67+
String $ssl_certfile = '',
68+
String $ssl_ca_certs = '',
69+
Optional[Integer] $ssl_cert_reqs = undef,
5170
Variant[String, Integer] $slowlog_max_len = '',
5271
Array $tags = [],
5372
Array $keys = [],
@@ -69,6 +88,11 @@
6988
'host' => $host,
7089
'password' => $password,
7190
'port' => $instance_port,
91+
'ssl' => $ssl,
92+
'ssl_keyfile' => $ssl_keyfile,
93+
'ssl_certfile' => $ssl_certfile,
94+
'ssl_ca_certs' => $ssl_ca_certs,
95+
'ssl_cert_reqs' => $ssl_cert_reqs,
7296
'slowlog_max_len' => $slowlog_max_len,
7397
'tags' => $tags,
7498
'keys' => $keys,

manifests/redhat.pp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@
7878
}
7979

8080
yumrepo { 'datadog5':
81-
ensure => absent,
81+
ensure => absent,
8282
}
8383

8484
yumrepo { 'datadog6':
85-
ensure => absent,
85+
ensure => absent,
8686
}
8787

8888
yumrepo { 'datadog':
@@ -100,7 +100,7 @@
100100
}
101101
} else {
102102
package { $agent_flavor:
103-
ensure => $agent_version,
103+
ensure => $agent_version,
104104
}
105105
}
106106
}

manifests/suse.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,6 @@
9696
}
9797

9898
package { $agent_flavor:
99-
ensure => $agent_version,
99+
ensure => $agent_version,
100100
}
101101
}

spec/classes/datadog_agent_integrations_mongo_spec.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,30 @@
2323
it { is_expected.to contain_file(conf_file).without_content(%r{tags:}) }
2424
end
2525

26+
context 'with one mongo host defined in hosts' do
27+
let(:params) do
28+
{
29+
servers: [
30+
{
31+
'hosts' => ['localhost:27017'],
32+
'username' => 'user',
33+
'password' => 'pass',
34+
'dbm' => true,
35+
'database_autodiscovery' => { 'enabled' => true },
36+
'reported_database_hostname' => 'mongohost',
37+
},
38+
],
39+
}
40+
end
41+
42+
it { is_expected.to contain_file(conf_file).with_content(%r{- hosts:\s+- localhost:27017}) }
43+
it { is_expected.to contain_file(conf_file).with_content(%r{username: user}) }
44+
it { is_expected.to contain_file(conf_file).with_content(%r{password: pass}) }
45+
it { is_expected.to contain_file(conf_file).with_content(%r{dbm: true}) }
46+
it { is_expected.to contain_file(conf_file).with_content(%r{database_autodiscovery:\s+enabled: true}) }
47+
it { is_expected.to contain_file(conf_file).with_content(%r{reported_database_hostname: mongohost}) }
48+
end
49+
2650
context 'with one mongo' do
2751
let(:params) do
2852
{

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,24 @@ init_config:
44

55
instances:
66
<% @servers.each do |server| -%>
7+
<% if !server['hosts'].nil? && server['hosts'].any? -%>
8+
- hosts:
9+
<%- server['hosts'].each do |host| -%>
10+
- <%= host %>
11+
<%- end -%>
12+
<%- if !server['username'].nil? -%>
13+
username: <%= server['username'] %>
14+
<%- end -%>
15+
<%- if !server['password'].nil? -%>
16+
password: <%= server['password'] %>
17+
<%- end -%>
18+
<%- if !server['database'].nil? -%>
19+
database: <%= server['database'] %>
20+
<%- end -%>
21+
<%- end -%>
22+
<% if server['hosts'].nil? -%>
723
- server: mongodb://<%= server['username'] %><%= ":" unless server['password'].nil? %><%= server['password'] %><%= "@" unless server['username'].nil? %><%= server['host'] %>:<%= server['port'] %>/<%= server['database'] %>
24+
<%- end -%>
825
<%- if !server['tags'].nil? && server['tags'].any? -%>
926
tags:
1027
<%- server['tags'].each do |tag| -%>
@@ -50,4 +67,16 @@ instances:
5067
- <%= collection %>
5168
<%- end -%>
5269
<%- end -%>
70+
<%- if !server['dbm'].nil? -%>
71+
dbm: <%= server['dbm'] %>
72+
<%- end -%>
73+
<%- if !server['database_autodiscovery'].nil? -%>
74+
database_autodiscovery:
75+
<%- if !server['database_autodiscovery']['enabled'].nil? -%>
76+
enabled: <%= server['database_autodiscovery']['enabled'] %>
77+
<%- end -%>
78+
<%- end -%>
79+
<%- if !server['reported_database_hostname'].nil? -%>
80+
reported_database_hostname: <%= server['reported_database_hostname'] %>
81+
<%- end -%>
5382
<% end -%>

0 commit comments

Comments
 (0)