Implement Mongo Authentication
MODIFY
recipes/mongo.rb
recipes/mongo.rb
@@ -5,7 +5,9 @@ include_recipe 'datadog::dd-agent'
# node.set['datadog']['mongo']['instances'] = [
# {
# 'host' => 'localhost',
-# 'port' => '27017'
+# 'port' => '27017',
+# 'username' => 'someuser',
+# 'password' => 'somepassword'
# }
# ]

MODIFY
spec/integrations/mongo_spec.rb
spec/integrations/mongo_spec.rb
@@ -4,7 +4,10 @@ describe 'datadog::mongo' do
init_config:
instances:
- - server: mongodb://localhost:27017
+ - hosts:
+ - localhost:27017
+ username: someuser
+ password: somepassword
timeout: 60
tags:
- 'env:test'
@@ -25,6 +28,8 @@ describe 'datadog::mongo' do
{
host: 'localhost',
port: '27017',
+ username: 'someuser',
+ password: 'somepassword',
timeout: '60',
tags: ['env:test']
}

MODIFY
templates/default/mongo.yaml.erb
templates/default/mongo.yaml.erb
instances:
<% @instances.each do |i| -%>
- - server: mongodb://<%= i['host']%>:<%= i['port'] %>
+ - hosts:
+ - <%= i['host']%>:<%= i['port'] %>
+ <% if i.key?('username') -%>
+ username: <%= i['username'] %>
+ <% end -%>
+ <% if i.key?('password') -%>
+ password: <%= i['password'] %>
+ <% end -%>
<% if i.key?('timeout') -%>
timeout: <%= i['timeout'] %>
<% end -%>
@@ -35,4 +42,3 @@ instances:
init_config:
# No init_config details needed
-

MODIFY
test/integration/datadog_mongo/serverspec/mongo_spec.rb
test/integration/datadog_mongo/serverspec/mongo_spec.rb
@@ -17,7 +17,10 @@ describe file(AGENT_CONFIG) do
expected = {
'instances' => [
{
- 'server' => 'mongodb://localhost:27017'
+ 'hosts' => 'localhost:27017',
+ 'username' => 'someuser',
+ 'password' => 'somepassword',
+ 'timeout' => 30
}
],
'logs' => nil,

Implement Mongo Authentication (#753)