Skip to content

Commit 97ae4f7

Browse files
authored
Pass proxy configuration from agent_extra_options to dogapi (DataDog#630)
In case the Agent is configured to use a proxy, use the same proxy when calling dogapi to send puppet reports. Tested by modifying dogapi to log the value of the proxy and checking the value in agent_extra_options got there.
1 parent 32c3746 commit 97ae4f7

4 files changed

Lines changed: 26 additions & 0 deletions

File tree

lib/puppet/reports/datadog_reports.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@
1414
API_KEY = config[:datadog_api_key]
1515
API_URL = config[:api_url]
1616

17+
if ENV['DD_PROXY_HTTP'].nil?
18+
ENV['DD_PROXY_HTTP'] = config[:proxy_http]
19+
end
20+
if ENV['DD_PROXY_HTTPS'].nil?
21+
ENV['DD_PROXY_HTTPS'] = config[:proxy_https]
22+
end
23+
1724
# if need be initialize the regex
1825
if !config[:hostname_extraction_regex].nil?
1926
begin

manifests/init.pp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,15 @@
757757
}
758758

759759
if $puppet_run_reports {
760+
$proxy_config = $agent_extra_options[proxy]
761+
if $proxy_config != undef {
762+
$proxy_http = $proxy_config[http]
763+
$proxy_https = $proxy_config[https]
764+
} else {
765+
$proxy_http = undef
766+
$proxy_https = undef
767+
}
768+
760769
class { 'datadog_agent::reports':
761770
api_key => $api_key,
762771
datadog_site => $datadog_site,
@@ -765,6 +774,8 @@
765774
dogapi_version => $datadog_agent::params::dogapi_version,
766775
puppetmaster_user => $puppetmaster_user,
767776
hostname_extraction_regex => $hostname_extraction_regex,
777+
proxy_http => $proxy_http,
778+
proxy_https => $proxy_https,
768779
}
769780
}
770781

manifests/reports.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
$dogapi_version,
2020
$manage_dogapi_gem = true,
2121
$hostname_extraction_regex = undef,
22+
$proxy_http = undef,
23+
$proxy_https = undef,
2224
$datadog_site = 'datadoghq.com',
2325
$puppet_gem_provider = $datadog_agent::params::gem_provider,
2426
) inherits datadog_agent::params {

templates/datadog-reports.yaml.erb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,9 @@
66
<% if @hostname_extraction_regex -%>
77
:hostname_extraction_regex: '<%= @hostname_extraction_regex %>'
88
<% end -%>
9+
<% if @proxy_http -%>
10+
:proxy_http: <%= @proxy_http %>
11+
<% end -%>
12+
<% if @proxy_https -%>
13+
:proxy_https: <%= @proxy_https %>
14+
<% end -%>

0 commit comments

Comments
 (0)