Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
# $dd_url:
# The host of the Datadog intake server to send agent data to.
# Defaults to https://app.datadoghq.com.
# $datadog_site:
# The site of the Datadog intake to send Agent data to. Defaults to 'datadoghq.com',
# set to 'datadoghq.eu' to send data to the EU site.
# This option is only available with agent version >= 6.6.0.
# $host:
# $api_key:
# Your DataDog API Key. Please replace with your key value.
Expand Down Expand Up @@ -203,7 +207,8 @@
#
#
class datadog_agent(
$dd_url = 'https://app.datadoghq.com',
$dd_url = '',
$datadog_site = $datadog_agent::params::datadog_site,
$host = '',
$api_key = 'your_API_key',
$collect_ec2_tags = false,
Expand Down Expand Up @@ -308,6 +313,7 @@
# lint:endignore

validate_legacy(String, 'validate_string', $dd_url)
validate_legacy(String, 'validate_string', $datadog_site)
validate_legacy(String, 'validate_string', $host)
validate_legacy(String, 'validate_string', $api_key)
validate_legacy(Array, 'validate_array', $tags)
Expand Down Expand Up @@ -502,6 +508,11 @@
require => File['/etc/dd-agent'],
}

if ($dd_url == '') {
$_dd_url = 'https://app.datadoghq.com'
} else {
$_dd_url = $dd_url
}
concat::fragment{ 'datadog header':
target => '/etc/dd-agent/datadog.conf',
content => template('datadog_agent/datadog_header.conf.erb'),
Expand Down Expand Up @@ -623,6 +634,7 @@
$_agent_config = {
'api_key' => $api_key,
'dd_url' => $dd_url,
'site' => $datadog_site,
Copy link
Copy Markdown
Member

@truthbk truthbk Nov 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the current manifest by default will yield a valid configuration for older A6 agents, unfortunately we need to support them: the problem we have here is that if this puppet manifest is used to install an older Agent6 (pre-site option) say 6.2.x it will yield a configuration with an empty dd_url and site set. It causes no harm to have site set, but the empty dd_url would be a no-no.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unlike A5, A6 has a default value for dd_url: https://github.com/DataDog/datadog-agent/blob/60fc833599c5015c15c741649840dc6bda930275/pkg/config/config.go#L75. That's why a left this parameter empty

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tested, with an empty dd_url, agent 6.2.0 still reports to app.datadoghq.com

Copy link
Copy Markdown
Member

@truthbk truthbk Nov 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is accurate. Older agents DID specify a default for dd_url, apparently an empty string will not override this default vcalue. This was changed with the introduction of site, but this already accounts for that. 👍

'cmd_port' => $cmd_port,
'collect_ec2_tags' => $collect_ec2_tags,
'conf_path' => $datadog_agent::params::conf6_dir,
Expand Down
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# Sample Usage:
#
class datadog_agent::params {
$datadog_site = 'datadoghq.com'
$agent5_enable = false
$conf_dir = '/etc/dd-agent/conf.d'
$conf6_dir = '/etc/datadog-agent/conf.d'
Expand Down
13 changes: 12 additions & 1 deletion spec/classes/datadog_agent_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,10 @@
'content' => /^collect_ec2_tags: false\n/,
)}
it { should contain_file('/etc/datadog-agent/datadog.yaml').with(
'content' => /^dd_url: \"{0,1}https:\/\/app.datadoghq.com\"{0,1}\n/,
'content' => /^dd_url: ''\n/,
)}
it { should contain_file('/etc/datadog-agent/datadog.yaml').with(
'content' => /^site: datadoghq.com\n/,
)}
it { should contain_file('/etc/datadog-agent/datadog.yaml').with(
'content' => /^enable_metadata_collection: true\n/,
Expand Down Expand Up @@ -960,6 +963,14 @@
'content' => /^collect_ec2_tags: true\n/,
)}
end
context 'datadog EU' do
let(:params) {{
:datadog_site => 'datadoghq.eu',
}}
it { should contain_file('/etc/datadog-agent/datadog.yaml').with(
'content' => /^site: datadoghq.eu\n/,
)}
end
context 'forward statsd settings set' do
let(:params) {{
:statsd_forward_host => 'foo',
Expand Down
2 changes: 1 addition & 1 deletion templates/datadog_header.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[Main]

# The host of the Datadog intake server to send agent data to
dd_url: <%= @dd_url %>
dd_url: <%= @_dd_url %>

# If you need a proxy to connect to the Internet, provide the settings here
<% if @proxy_host.empty? -%>
Expand Down