-
Notifications
You must be signed in to change notification settings - Fork 262
/
Copy pathmongo.pp
141 lines (138 loc) · 5.02 KB
/
mongo.pp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# Class: datadog_agent::integrations::mongo
#
# This class will install the necessary configuration for the mongo integration
#
# NOTE: In newer versions of the Datadog Agent, the ssl parameters will be deprecated in favor the tls variants
#
# Parameters:
# $hosts
# Array of hosts host (and optional port number) where the mongod instance is running
# $dbm
# Enable the Database Monitoring feature
# $database_autodiscovery
# Enable the Database Autodiscovery feature
# $reported_database_hostname
# Optional database hostname override the mongodb hostname detected by the Agent from mongodb admin command serverStatus
# $additional_metrics
# Optional array of additional metrics
# $database
# Optionally specify database to query. Defaults to 'admin'
# $password
# Optionally specify password for connection
# $ssl
# Optionally enable SSL for connection
# $ssl_ca_certs
# Optionally specify path to SSL Certificate Authority certificates
# $ssl_cert_reqs
# Optionally require SSL client certificate for connection
# $ssl_certfile
# Optionally specify path to SSL certificate for connection
# $ssl_keyfile
# Optionally specify path to SSL private key for connection
# $tls
# Optionally enable TLS for connection
# $tls_ca_file
# Optionally specify path to SSL/TLS Certificate Authority certificates
# $tls_allow_invalid_certificates
# Optionally require SSL/TLS client certificate for connection
# $tls_certificate_key_file
# Optionally specify path to combined SSL/TLS key and certificate for connection
# $tags
# Optional array of tags
# $username
# Optionally specify username for connection
# $host:
# Deprecated use $hosts instead
# The host mongo is running on. Defaults to '127.0.0.1'
# $port
# Deprecated use $hosts instead
# The port mongo is running on. Defaults to 27017
#
# Sample Usage (Older Agent Versions):
#
# class { 'datadog_agent::integrations::mongo' :
# servers => [
# {
# 'additional_metrics' => ['top'],
# 'database' => 'database_name',
# 'host' => 'localhost',
# 'password' => 'mongo_password',
# 'port' => '27017',
# 'ssl' => true,
# 'ssl_ca_certs' => '/path/to/ca.pem',
# 'ssl_cert_reqs' => 'CERT_REQUIRED',
# 'ssl_certfile' => '/path/to/client.pem',
# 'ssl_keyfile' => '/path/to/key.pem',
# 'tags' => ['optional_tag1', 'optional_tag2'],
# 'username' => 'mongo_username',
# },
# {
# 'host' => 'localhost',
# 'port' => '27018',
# 'tags' => [],
# 'additional_metrics' => [],
# 'collections' => [],
# },
# ]
# }
#
# Sample Usage (Newer Agent Versions):
#
# class { 'datadog_agent::integrations::mongo' :
# servers => [
# {
# 'additional_metrics' => ['top'],
# 'database' => 'database_name',
# 'hosts' => ['localhost:27017'],
# 'password' => 'mongo_password',
# 'tls' => true,
# 'tls_ca_file' => '/path/to/ca.pem',
# 'tls_allow_invalid_certificates' => false,
# 'tls_certificate_key_file' => '/path/to/combined.pem',
# 'tags' => ['optional_tag1', 'optional_tag2'],
# 'username' => 'mongo_username',
# 'dbm' => true,
# 'database_autodiscovery' => {'enabled' => true},
# 'reported_database_hostname' => 'mymongodbhost',
# },
# {
# 'hosts' => ['localhost:27017'],
# 'tags' => [],
# 'additional_metrics' => [],
# 'collections' => [],
# },
# ]
# }
#
class datadog_agent::integrations::mongo(
Array $servers = [{'host' => 'localhost', 'port' => '27017'}]
) inherits datadog_agent::params {
require ::datadog_agent
$legacy_dst = "${datadog_agent::params::legacy_conf_dir}/mongo.yaml"
if $::datadog_agent::_agent_major_version > 5 {
$dst_dir = "${datadog_agent::params::conf_dir}/mongo.d"
file { $legacy_dst:
ensure => 'absent'
}
file { $dst_dir:
ensure => directory,
owner => $datadog_agent::dd_user,
group => $datadog_agent::params::dd_group,
mode => $datadog_agent::params::permissions_directory,
require => Package[$datadog_agent::params::package_name],
notify => Service[$datadog_agent::params::service_name]
}
$dst = "${dst_dir}/conf.yaml"
} else {
$dst = $legacy_dst
}
file { $dst:
ensure => file,
owner => $datadog_agent::dd_user,
group => $datadog_agent::params::dd_group,
mode => $datadog_agent::params::permissions_protected_file,
content => template('datadog_agent/agent-conf.d/mongo.yaml.erb'),
require => Package[$datadog_agent::params::package_name],
notify => Service[$datadog_agent::params::service_name]
}
}