Skip to content

Commit

Permalink
Merge pull request DataDog#143 from DataDog/jaime/gphat_pr_2
Browse files Browse the repository at this point in the history
Puppet Agent - more options, hiera tags.
  • Loading branch information
truthbk committed Nov 13, 2015
2 parents af9f224 + baecf44 commit 1edb7ed
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
23 changes: 22 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
# The Agent will try to collect instance metadata for EC2 and GCE instances.
# $tags
# Optional array of tags.
# $hiera_tags
# Boolean to grab tags from hiera to allow merging
# $facts_to_tags
# Optional array of facts' names that you can use to define tags following
# the scheme: "fact_name:fact_value".
Expand Down Expand Up @@ -59,8 +61,13 @@
# $extra_template
# Optional, append this extra template file at the end of
# the default datadog.conf template
# $skip_apt_key_trusting
# Skip trusting the apt key. Default is false. Useful if you have a
# separate way of adding keys.
# $skip_ssl_validation
# Skip SSL validation.
# $use_curl_http_client
# Uses the curl HTTP client for the forwarder
# Actions:
#
# Requires:
Expand All @@ -86,6 +93,7 @@
$collect_ec2_tags = false,
$collect_instance_metadata = true,
$tags = [],
$hiera_tags = false,
$facts_to_tags = [],
$puppet_run_reports = false,
$puppetmaster_user = 'puppet',
Expand All @@ -99,6 +107,7 @@
$dogstatsd_port = 8125,
$statsd_forward_host = '',
$statsd_forward_port = 8125,
$statsd_histogram_percentiles = '0.95',
$proxy_host = '',
$proxy_port = '',
$proxy_user = '',
Expand All @@ -107,13 +116,16 @@
$extra_template = '',
$ganglia_host = '',
$ganglia_port = 8651,
$skip_ssl_validation = false
$skip_ssl_validation = false,
$skip_apt_key_trusting = false,
$use_curl_http_client = false
) inherits datadog_agent::params {

validate_string($dd_url)
validate_string($host)
validate_string($api_key)
validate_array($tags)
validate_bool($hiera_tags)
validate_array($dogstreams)
validate_array($facts_to_tags)
validate_bool($puppet_run_reports)
Expand All @@ -122,6 +134,7 @@
validate_bool($log_to_syslog)
validate_string($log_level)
validate_integer($dogstatsd_port)
validate_string($statsd_histogram_percentiles)
validate_string($proxy_host)
validate_string($proxy_port)
validate_string($proxy_user)
Expand All @@ -131,6 +144,14 @@
validate_string($ganglia_host)
validate_integer($ganglia_port)
validate_bool($skip_ssl_validation)
validate_bool($skip_apt_key_trusting)
validate_bool($use_curl_http_client)

if $hiera_tags {
$local_tags = hiera_array('datadog_agent::tags')
} else {
$local_tags = $tags
}

include datadog_agent::params
case upcase($log_level) {
Expand Down
10 changes: 6 additions & 4 deletions manifests/ubuntu.pp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@
before => File['/etc/apt/sources.list.d/datadog.list'],
}

exec { 'datadog_key':
command => "/usr/bin/apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys ${apt_key}",
unless => "/usr/bin/apt-key list | grep ${apt_key} | grep expires",
before => File['/etc/apt/sources.list.d/datadog.list'],
if !$::datadog_agent::skip_apt_key_trusting {
exec { 'datadog_key':
command => "/usr/bin/apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys ${apt_key}",
unless => "/usr/bin/apt-key list | grep ${apt_key} | grep expires",
before => File['/etc/apt/sources.list.d/datadog.list'],
}
}

file { '/etc/apt/sources.list.d/datadog.list':
Expand Down
6 changes: 4 additions & 2 deletions templates/datadog.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ hostname: <%= @host %>
# Set the host's tags
#tags: mytag0, mytag1
<%
tag_list = @tags
tag_list = @local_tags
@facts_to_tags.each do |f|
value = scope.lookupvar(f)
if not value.nil?
Expand Down Expand Up @@ -104,7 +104,7 @@ non_local_traffic: <%= @non_local_traffic %>

# Select the Tornado HTTP Client in the forwarder
# Default to the simple http client
# use_curl_http_client: False
use_curl_http_client: <%= @use_curl_http_client %>

# The loopback address the Forwarder and Dogstatsd will bind.
# Optional, it is mainly used when running the agent on Openshift
Expand Down Expand Up @@ -152,6 +152,8 @@ dogstatsd_port : <%= @dogstatsd_port %>
## by the dogstatsd_interval) before being sent to the server. Defaults to 'yes'
# dogstatsd_normalize : yes

histogram_percentiles: <%= @statsd_histogram_percentiles %>

# If you want to forward every packet received by the dogstatsd server
# to another statsd server, uncomment these lines.
# WARNING: Make sure that forwarded packets are regular statsd packets and not "dogstatsd" packets,
Expand Down

0 comments on commit 1edb7ed

Please sign in to comment.