Skip to content

Commit 02f8a0f

Browse files
remicalixtetruthbk
authored andcommitted
Add 'site' option support (DataDog#464)
* Add 'site' option support * Move default site to params * Ensure dd_url is empty by default for agent 6 * Add spec test for new site option
1 parent 15a865e commit 02f8a0f

4 files changed

Lines changed: 27 additions & 3 deletions

File tree

manifests/init.pp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
# $dd_url:
77
# The host of the Datadog intake server to send agent data to.
88
# Defaults to https://app.datadoghq.com.
9+
# $datadog_site:
10+
# The site of the Datadog intake to send Agent data to. Defaults to 'datadoghq.com',
11+
# set to 'datadoghq.eu' to send data to the EU site.
12+
# This option is only available with agent version >= 6.6.0.
913
# $host:
1014
# $api_key:
1115
# Your DataDog API Key. Please replace with your key value.
@@ -203,7 +207,8 @@
203207
#
204208
#
205209
class datadog_agent(
206-
$dd_url = 'https://app.datadoghq.com',
210+
$dd_url = '',
211+
$datadog_site = $datadog_agent::params::datadog_site,
207212
$host = '',
208213
$api_key = 'your_API_key',
209214
$collect_ec2_tags = false,
@@ -308,6 +313,7 @@
308313
# lint:endignore
309314

310315
validate_legacy(String, 'validate_string', $dd_url)
316+
validate_legacy(String, 'validate_string', $datadog_site)
311317
validate_legacy(String, 'validate_string', $host)
312318
validate_legacy(String, 'validate_string', $api_key)
313319
validate_legacy(Array, 'validate_array', $tags)
@@ -502,6 +508,11 @@
502508
require => File['/etc/dd-agent'],
503509
}
504510

511+
if ($dd_url == '') {
512+
$_dd_url = 'https://app.datadoghq.com'
513+
} else {
514+
$_dd_url = $dd_url
515+
}
505516
concat::fragment{ 'datadog header':
506517
target => '/etc/dd-agent/datadog.conf',
507518
content => template('datadog_agent/datadog_header.conf.erb'),
@@ -623,6 +634,7 @@
623634
$_agent_config = {
624635
'api_key' => $api_key,
625636
'dd_url' => $dd_url,
637+
'site' => $datadog_site,
626638
'cmd_port' => $cmd_port,
627639
'collect_ec2_tags' => $collect_ec2_tags,
628640
'conf_path' => $datadog_agent::params::conf6_dir,

manifests/params.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# Sample Usage:
1616
#
1717
class datadog_agent::params {
18+
$datadog_site = 'datadoghq.com'
1819
$agent5_enable = false
1920
$conf_dir = '/etc/dd-agent/conf.d'
2021
$conf6_dir = '/etc/datadog-agent/conf.d'

spec/classes/datadog_agent_spec.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,10 @@
894894
'content' => /^collect_ec2_tags: false\n/,
895895
)}
896896
it { should contain_file('/etc/datadog-agent/datadog.yaml').with(
897-
'content' => /^dd_url: \"{0,1}https:\/\/app.datadoghq.com\"{0,1}\n/,
897+
'content' => /^dd_url: ''\n/,
898+
)}
899+
it { should contain_file('/etc/datadog-agent/datadog.yaml').with(
900+
'content' => /^site: datadoghq.com\n/,
898901
)}
899902
it { should contain_file('/etc/datadog-agent/datadog.yaml').with(
900903
'content' => /^enable_metadata_collection: true\n/,
@@ -960,6 +963,14 @@
960963
'content' => /^collect_ec2_tags: true\n/,
961964
)}
962965
end
966+
context 'datadog EU' do
967+
let(:params) {{
968+
:datadog_site => 'datadoghq.eu',
969+
}}
970+
it { should contain_file('/etc/datadog-agent/datadog.yaml').with(
971+
'content' => /^site: datadoghq.eu\n/,
972+
)}
973+
end
963974
context 'forward statsd settings set' do
964975
let(:params) {{
965976
:statsd_forward_host => 'foo',

templates/datadog_header.conf.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[Main]
55

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

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

0 commit comments

Comments
 (0)