From 07fff5edfd6cb646e78f2959e0bb5014305eeb54 Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Sun, 24 Jan 2016 17:54:31 -0500 Subject: [PATCH 01/49] Additional Mongo configuration for SSL, additional metrics, and database connection --- manifests/integrations/mongo.pp | 35 ++++++++++++++++++++++++--- templates/agent-conf.d/mongo.yaml.erb | 23 +++++++++++++++++- 2 files changed, 53 insertions(+), 5 deletions(-) diff --git a/manifests/integrations/mongo.pp b/manifests/integrations/mongo.pp index 678465b3..5cf5895a 100644 --- a/manifests/integrations/mongo.pp +++ b/manifests/integrations/mongo.pp @@ -3,21 +3,48 @@ # This class will install the necessary configuration for the mongo integration # # Parameters: +# $additional_metrics +# Optional array of additional metrics +# $database +# Optionally specify database to query. Defaults to 'admin' # $host: # The host mongo is running on. Defaults to '127.0.0.1' +# $password +# Optionally specify password for connection # $port -# The mongo password for the datadog user. Defaults to 27017 +# The port mongo is running on. Defaults to 27017 +# $ssl +# Optionally enable SSL for connection +# $ssl_ca_certs +# Optionally specify path to SSL Certificate Authority certificates +# $ssl_cert_reqs +# Optionally require SSL client certificate for connection +# $ssl_certfile +# Optionally specify path to SSL certificate for connection +# $ssl_keyfile +# Optionally specify path to SSL private key for connection # $tags # Optional array of tags +# $username +# Optionally specify username for connection # # Sample Usage: # # class { 'datadog_agent::integrations::mongo' : # servers => [ # { -# 'host' => 'localhost', -# 'port' => '27017', -# 'tags' => [], +# 'additional_metrics' => ['top'], +# 'database' => 'database_name', +# 'host' => 'localhost', +# 'password' => 'mongo_password', +# 'port' => '27017', +# 'ssl' => true, +# 'ssl_ca_certs' => '/path/to/ca.pem', +# 'ssl_cert_reqs' => 'CERT_REQUIRED', +# 'ssl_certfile' => '/path/to/client.pem', +# 'ssl_keyfile' => '/path/to/key.pem', +# 'tags' => ['optional_tag1', 'optional_tag2'], +# 'username' => 'mongo_username', # }, # { # 'host' => 'localhost', diff --git a/templates/agent-conf.d/mongo.yaml.erb b/templates/agent-conf.d/mongo.yaml.erb index 1537bcbc..981f821b 100644 --- a/templates/agent-conf.d/mongo.yaml.erb +++ b/templates/agent-conf.d/mongo.yaml.erb @@ -6,11 +6,32 @@ init_config: instances: <% @servers.each do |server| -%> - - server: mongodb://<%= server['host'] %>:<%= server['port'] %> + - server: mongodb://<%= server['username'] %><%= ":" unless server['password'].nil? %><%= server['password'] %><%= "@" unless server['username'].nil? %><%= server['host'] %>:<%= server['port'] %>/<%= server['database'] %> <%- if !server['tags'].nil? && server['tags'].any? -%> tags: <%- server['tags'].each do |tag| -%> - <%= tag %> <%- end -%> <%- end -%> + <%- if !server['ssl'].nil? -%> + ssl: <%= server['ssl'] %> + <%- if !server['ssl_keyfile'].nil? -%> + ssl_keyfile: <%= server['ssl_keyfile'] %> + <%- end -%> + <%- if !server['ssl_certfile'].nil? -%> + ssl_certfile: <%= server['ssl_certfile'] %> + <%- end -%> + <%- if !server['ssl_cert_reqs'].nil? -%> + ssl_cert_reqs: <%= server['ssl_cert_reqs'] %> + <%- end -%> + <%- if !server['ssl_ca_certs'].nil? -%> + ssl_ca_certs: <%= server['ssl_ca_certs'] %> + <%- end -%> + <%- end -%> + <%- if !server['additional_metrics'].nil? && server['additional_metrics'].any? -%> + additional_metrics: + <%- server['additional_metrics'].each do |additional_metric| -%> + - <%= additional_metric %> + <%- end -%> + <%- end -%> <% end -%> From 2da6d092afa8efc36770cfaf23aa643b1d152dcd Mon Sep 17 00:00:00 2001 From: Jonathan Niesen Date: Thu, 17 Dec 2015 23:51:19 -0500 Subject: [PATCH 02/49] Allow multiple instances in the http_check. Adds the ``instances`` parameter to the ``http_check`` class. This parameter defaults to undef. For backwards compatibility, if the ``instances`` array not defined it will be instantiated as an array containing a single hash. The remaining parameters of the class will be used for the key/value pairs in the hash. This will allow us to iterate over the ``instances`` array in the template. --- manifests/integrations/http_check.pp | 18 ++++++++ templates/agent-conf.d/http_check.yaml.erb | 49 +++++++++++----------- 2 files changed, 43 insertions(+), 24 deletions(-) diff --git a/manifests/integrations/http_check.pp b/manifests/integrations/http_check.pp index 87a3e09a..0da8e325 100644 --- a/manifests/integrations/http_check.pp +++ b/manifests/integrations/http_check.pp @@ -86,8 +86,26 @@ $headers = [], $tags = [], $contact = [], + $instances = undef, ) inherits datadog_agent::params { + if $instances == undef { + $instances = [{ + 'url' => $url, + 'username' => $username, + 'password' => $password, + 'timeout' => $timeout, + 'threshold' => $threshold, + 'window' => $window, + 'include_content' => $include_content, + 'collect_response_time' => $collect_response_time, + 'disable_ssl_validation' => $disable_ssl_validation, + 'headers' => $headers, + 'tags' => $tags, + 'contact' => $contact, + }] + } + file { "${datadog_agent::params::conf_dir}/http_check.yaml": ensure => file, owner => $datadog_agent::params::dd_user, diff --git a/templates/agent-conf.d/http_check.yaml.erb b/templates/agent-conf.d/http_check.yaml.erb index 1937a8fb..d63ad134 100644 --- a/templates/agent-conf.d/http_check.yaml.erb +++ b/templates/agent-conf.d/http_check.yaml.erb @@ -1,52 +1,53 @@ init_config: instances: - - name: <%= @name %> - url: <%= @url %> -<% if @timeout -%> - timeout: <%= @timeout %> +<%- (Array(@instances)).each do |instance| -%> + - name: <%= instance['name'] %> + url: <%= instance['url'] %> +<% if instance['timeout'] -%> + timeout: <%= instance['timeout'] %> <% end -%> -<% if @username -%> - username: <%= @username %> +<% if instance['username'] -%> + username: <%= instance['username'] %> <% end -%> -<% if @password -%> - password: <%= @password %> +<% if instance['password'] -%> + password: <%= instance['password'] %> <% end -%> -<% if @threshold -%> - threshold: <%= @threshold %> +<% if instance['threshold'] -%> + threshold: <%= instance['threshold'] %> <% end -%> -<% if @window -%> - window: <%= @window %> +<% if instance['window'] -%> + window: <%= instance['window'] %> <% end -%> -<% if @include_content -%> - include_content: <%= @include_content %> +<% if instance['include_content'] -%> + include_content: <%= instance['include_content'] %> <% end -%> -<% if @collect_response_time -%> - collect_response_time: <%= @collect_response_time %> +<% if instance['collect_response_time'] -%> + collect_response_time: <%= instance['collect_response_time'] %> <% end -%> - disable_ssl_validation: <%= @disable_ssl_validation %> -<% if @headers and ! @headers.empty? -%> + disable_ssl_validation: <%= instance['disable_ssl_validation'] %> +<% if instance['headers'] and ! instance['headers'].empty? -%> headers: - <%- Array(@headers).each do |header| -%> + <%- Array(instance['headers']).each do |header| -%> <%- if header != '' -%> <%= header %> <%- end -%> <%- end -%> <% end -%> -<% if @tags and ! @tags.empty? -%> +<% if instance['tags'] and ! instance['tags'].empty? -%> tags: - <%- Array(@tags).each do |tag| -%> + <%- Array(instance['tags']).each do |tag| -%> <%- if tag != '' -%> - <%= tag %> <%- end -%> <%- end -%> <% end -%> -<% if @contacts and ! @contacts.empty? -%> +<% if instance['contacts'] and ! instance['contacts'].empty? -%> notify: - <%- Array(@contacts).each do |contact| -%> + <%- Array(instance['contacts']).each do |contact| -%> <%- if contact != '' -%> - <%= contact %> <%- end -%> <%- end -%> <% end -%> - +<% end -%> From 3b5795369698394272df1705012ab65dca3b2abf Mon Sep 17 00:00:00 2001 From: David Gibbons Date: Thu, 14 Jan 2016 14:21:45 -0800 Subject: [PATCH 03/49] Move the GPGkey to a parameter. In some environments with blocked egress connectivity, the location of the GPGkey might need to be overwritten to an internal resource. --- manifests/redhat.pp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/manifests/redhat.pp b/manifests/redhat.pp index c01f1e9d..782e0cf1 100644 --- a/manifests/redhat.pp +++ b/manifests/redhat.pp @@ -14,7 +14,8 @@ # Sample Usage: # class datadog_agent::redhat( - $baseurl = "https://yum.datadoghq.com/rpm/${::architecture}/" + $baseurl = "https://yum.datadoghq.com/rpm/${::architecture}/", + $gpgkey = 'https://yum.datadoghq.com/DATADOG_RPM_KEY.public' ) { validate_string($baseurl) @@ -22,7 +23,7 @@ yumrepo {'datadog': enabled => 1, gpgcheck => 1, - gpgkey => 'https://yum.datadoghq.com/DATADOG_RPM_KEY.public', + gpgkey => $gpgkey, descr => 'Datadog, Inc.', baseurl => $baseurl, } From dd331e3bd068483d4a106f7a9d9bfdf75b97e2b1 Mon Sep 17 00:00:00 2001 From: Brian Johnson Date: Wed, 3 Feb 2016 21:25:29 -0800 Subject: [PATCH 04/49] Decouple the yum repo definition from the package. Control management via the manage_repo parameter. This allows for private repos in the case where there might be a network issue between the host and datadog's yum repo. Added some tests for both cases --- manifests/init.pp | 11 ++++++++++- manifests/redhat.pp | 22 ++++++++++++++-------- spec/classes/datadog_agent_redhat_spec.rb | 22 ++++++++++++++++------ 3 files changed, 40 insertions(+), 15 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index e6b04398..beae0ea3 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -48,6 +48,9 @@ # $statsd_forward_port # Set the value of the statsd_forward_port varable. Used to forward all # statsd metrics to another host. +# $manage_repo +# Boolean to indicate whether this module should attempt to manage +# the package repo. Default true. # $proxy_host # Set value of 'proxy_host' variable. Default is blank. # $proxy_port @@ -103,6 +106,7 @@ $log_to_syslog = true, $service_ensure = 'running', $service_enable = true, + $manage_repo = true, $use_mount = false, $dogstatsd_port = 8125, $statsd_forward_host = '', @@ -132,6 +136,7 @@ validate_string($puppetmaster_user) validate_bool($non_local_traffic) validate_bool($log_to_syslog) + validate_bool($manage_repo) validate_string($log_level) validate_integer($dogstatsd_port) validate_string($statsd_histogram_percentiles) @@ -167,7 +172,11 @@ case $::operatingsystem { 'Ubuntu','Debian' : { include datadog_agent::ubuntu } - 'RedHat','CentOS','Fedora','Amazon','Scientific' : { include datadog_agent::redhat } + 'RedHat','CentOS','Fedora','Amazon','Scientific' : { + class { 'datadog_agent::redhat': + manage_repo => $manage_repo, + } + } default: { fail("Class[datadog_agent]: Unsupported operatingsystem: ${::operatingsystem}") } } diff --git a/manifests/redhat.pp b/manifests/redhat.pp index 782e0cf1..951fc2a0 100644 --- a/manifests/redhat.pp +++ b/manifests/redhat.pp @@ -16,16 +16,23 @@ class datadog_agent::redhat( $baseurl = "https://yum.datadoghq.com/rpm/${::architecture}/", $gpgkey = 'https://yum.datadoghq.com/DATADOG_RPM_KEY.public' + $manage_repo = true, ) { - validate_string($baseurl) + validate_bool($manage_repo) + if $manage_repo { + validate_string($baseurl) - yumrepo {'datadog': - enabled => 1, - gpgcheck => 1, - gpgkey => $gpgkey, - descr => 'Datadog, Inc.', - baseurl => $baseurl, + + yumrepo {'datadog': + enabled => 1, + gpgcheck => 1, + gpgkey => $gpgkey, + descr => 'Datadog, Inc.', + baseurl => $baseurl, + } + + Package['datadog-agent'] -> Yumrepo['datadog'] } package { 'datadog-agent-base': @@ -35,7 +42,6 @@ package { 'datadog-agent': ensure => latest, - require => Yumrepo['datadog'], } service { 'datadog-agent': diff --git a/spec/classes/datadog_agent_redhat_spec.rb b/spec/classes/datadog_agent_redhat_spec.rb index 00af62a4..c0cdbb7a 100644 --- a/spec/classes/datadog_agent_redhat_spec.rb +++ b/spec/classes/datadog_agent_redhat_spec.rb @@ -10,14 +10,24 @@ end # it should install the mirror - it do - should contain_yumrepo('datadog') - .with_enabled(1)\ - .with_gpgcheck(1)\ - .with_gpgkey('https://yum.datadoghq.com/DATADOG_RPM_KEY.public')\ - .with_baseurl('https://yum.datadoghq.com/rpm/x86_64/') + context 'with manage_repo => true' do + let(:params){ {:manage_repo => true} } + it do + should contain_yumrepo('datadog') + .with_enabled(1)\ + .with_gpgcheck(1)\ + .with_gpgkey('https://yum.datadoghq.com/DATADOG_RPM_KEY.public')\ + .with_baseurl('https://yum.datadoghq.com/rpm/x86_64/') + end + end + context 'with manage_repo => false' do + let(:params){ {:manage_repo => false} } + it do + should_not contain_yumrepo('datadog') + end end + # it should install the packages it do should contain_package('datadog-agent-base')\ From 6b50a619e6e56e7e724e8d505d7e73a28d434342 Mon Sep 17 00:00:00 2001 From: Bryan Andrews Date: Tue, 15 Mar 2016 10:44:47 -0700 Subject: [PATCH 05/49] added support for apache integration disable_ssl_validation --- manifests/integrations/apache.pp | 10 ++++++---- templates/agent-conf.d/apache.yaml.erb | 3 +++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/manifests/integrations/apache.pp b/manifests/integrations/apache.pp index 5c64a7b5..cb7bce6f 100644 --- a/manifests/integrations/apache.pp +++ b/manifests/integrations/apache.pp @@ -27,14 +27,16 @@ # } # class datadog_agent::integrations::apache ( - $url = 'http://localhost/server-status?auto', - $username = undef, - $password = undef, - $tags = [] + $url = 'http://localhost/server-status?auto', + $username = undef, + $password = undef, + $tags = [], + $disable_ssl_validation = false ) inherits datadog_agent::params { validate_string($url) validate_array($tags) + validate_bool($disable_ssl_validation) file { "${datadog_agent::params::conf_dir}/apache.yaml": ensure => file, diff --git a/templates/agent-conf.d/apache.yaml.erb b/templates/agent-conf.d/apache.yaml.erb index 025851be..f73f04ea 100644 --- a/templates/agent-conf.d/apache.yaml.erb +++ b/templates/agent-conf.d/apache.yaml.erb @@ -2,6 +2,9 @@ init_config: instances: - apache_status_url: <%= @url %> +<% if @disable_ssl_validation -%> + disable_ssl_validation: <%= @disable_ssl_validation %> +<% end -%> <% if @username -%> apache_user: <%= @username %> <% end -%> From 15ef377a508c0fc8396a60509f7f78a8047ed4a9 Mon Sep 17 00:00:00 2001 From: Alan Scherger Date: Thu, 3 Dec 2015 01:33:11 -0600 Subject: [PATCH 06/49] add consul --- manifests/integrations/consul.pp | 28 ++++++++++++++++++ templates/agent-conf.d/consul.yaml.erb | 39 ++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 manifests/integrations/consul.pp create mode 100644 templates/agent-conf.d/consul.yaml.erb diff --git a/manifests/integrations/consul.pp b/manifests/integrations/consul.pp new file mode 100644 index 00000000..70294b99 --- /dev/null +++ b/manifests/integrations/consul.pp @@ -0,0 +1,28 @@ +# Class: datadog_agent::integrations::consul +# +# This class will install the necessary configuration for the consul integration +# +# Parameters: +# $url: +# The URL for consul +# +# Sample Usage: +# +# class { 'datadog_agent::integrations::consul' : +# url => "http://localhost:8500" +# } +# +class datadog_agent::integrations::consul( + $url = 'http://localhost:8500' +) inherits datadog_agent::params { + + file { "${datadog_agent::params::conf_dir}/consul.yaml": + ensure => file, + owner => $datadog_agent::params::dd_user, + group => $datadog_agent::params::dd_group, + mode => '0644', + content => template('datadog_agent/agent-conf.d/consul.yaml.erb'), + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name] + } +} diff --git a/templates/agent-conf.d/consul.yaml.erb b/templates/agent-conf.d/consul.yaml.erb new file mode 100644 index 00000000..47ea0fc8 --- /dev/null +++ b/templates/agent-conf.d/consul.yaml.erb @@ -0,0 +1,39 @@ + +# This check takes no init_config +init_config: + +instances: + # Where your Consul HTTP Server Lives + # Remind to use https instead of http if your Consul setup is configured to do so. + - url: <%= @url %> + + # If Consul setup uses SSL, you might need to set the following options as well. + + # You can specify a local cert to use as client side certificate + # as a single file (containing the private key and the certificate concatenated) + # client_cert_file: '/path/to/client.concatenated.pem' + + # Or as two separate files (for certificate and key): + # client_cert_file: '/path/to/client.cert.pem' + # private_key_file: '/path/to/private.key.pem' + + # Whether to verifiy SSL certificates for HTTPS requests. + # Possible values: True, False or '/path/to/your/trusted_ca_bundle_file' + # ca_bundle_file: '/path/to/trusted_ca_bundle_file' + + # Whether to perform checks against the Consul service Catalog + catalog_checks: yes + + # Whether to enable new leader checks from this agent + # Note: if this is set on multiple agents in the same cluster + # you will receive one event per leader change per agent + new_leader_checks: yes + + # Services to restrict catalog querying to + # The default settings query up to 50 services. So if you have more than + # this many in your Consul service catalog, you will want to fill in the + # whitelist + # service_whitelist: + # - zookeeper + # - gunicorn + # - redis \ No newline at end of file From 54c46d118ad3b38b1c82ee04a04f45b5295aafbb Mon Sep 17 00:00:00 2001 From: Jaime Fullaondo Date: Thu, 7 Apr 2016 13:49:21 -0400 Subject: [PATCH 07/49] [spec] fixing rake spec issue. --- manifests/redhat.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/redhat.pp b/manifests/redhat.pp index 951fc2a0..5d4f148b 100644 --- a/manifests/redhat.pp +++ b/manifests/redhat.pp @@ -15,7 +15,7 @@ # class datadog_agent::redhat( $baseurl = "https://yum.datadoghq.com/rpm/${::architecture}/", - $gpgkey = 'https://yum.datadoghq.com/DATADOG_RPM_KEY.public' + $gpgkey = 'https://yum.datadoghq.com/DATADOG_RPM_KEY.public', $manage_repo = true, ) { From f3f846b139743c23c8e3640e84f22cacbd061b0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Cavaill=C3=A9?= Date: Wed, 30 Mar 2016 13:43:55 +0200 Subject: [PATCH 08/49] add option in datadog_agent to extract hostnames Fixes #160. This option is a string regex which can be enabled and used to extract the hostname from puppet hostname strings with a capture group. It is useful for people that have specific puppet hostnames and that would like to sanitize them before reporting those in Datadog. --- lib/puppet/reports/datadog_reports.rb | 14 ++++++++++++++ manifests/init.pp | 7 +++++++ manifests/reports.pp | 3 ++- templates/datadog.yaml.erb | 3 +++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/lib/puppet/reports/datadog_reports.rb b/lib/puppet/reports/datadog_reports.rb index 5e93cce0..c5c7746e 100644 --- a/lib/puppet/reports/datadog_reports.rb +++ b/lib/puppet/reports/datadog_reports.rb @@ -14,6 +14,14 @@ config = YAML.load_file(configfile) API_KEY = config[:datadog_api_key] + # if need be initialize the regex + HOSTNAME_EXTRACTION_REGEX = config[:hostname_extraction_regex] + begin + HOSTNAME_EXTRACTION_REGEX = Regexp.new HOSTNAME_EXTRACTION_REGEX unless HOSTNAME_EXTRACTION_REGEX.nil? + rescue + raise(Puppet::ParseError, "Invalid hostname_extraction_regex #{HOSTNAME_EXTRACTION_REGEX}") + end + desc <<-DESC Send notification of metrics to Datadog DESC @@ -38,6 +46,12 @@ def pluralize(number, noun) def process @summary = self.summary @msg_host = self.host + unless HOSTNAME_EXTRACTION_REGEX.nil? + m = @msg_host.match(HOSTNAME_EXTRACTION_REGEX) + unless m[:hostname].nil? + @msg_host = m[:hostname] + end + end event_title = '' alert_type = '' diff --git a/manifests/init.pp b/manifests/init.pp index beae0ea3..a626cc2e 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -34,6 +34,11 @@ # $log_level # Set value of 'log_level' variable. Default is 'info' as in dd-agent. # Valid values here are: critical, debug, error, fatal, info, warn and warning. +# $hostname_extraction_regex +# Completely optional. +# Instead of reporting the puppet nodename, use this regex to extract the named +# 'hostname' captured group to report the run in Datadog. +# ex.: '^(?.*\.datadoghq\.com)(\.i-\w{8}\..*)?$' # $log_to_syslog # Set value of 'log_to_syslog' variable. Default is true -> yes as in dd-agent. # Valid values here are: true or false. @@ -107,6 +112,7 @@ $service_ensure = 'running', $service_enable = true, $manage_repo = true, + $hostname_extraction_regex = nil, $use_mount = false, $dogstatsd_port = 8125, $statsd_forward_host = '', @@ -212,6 +218,7 @@ class { 'datadog_agent::reports': api_key => $api_key, puppetmaster_user => $puppetmaster_user, + hostname_extraction_regex => $hostname_extraction_regex, } } diff --git a/manifests/reports.pp b/manifests/reports.pp index b6832ae3..af4ca7a6 100644 --- a/manifests/reports.pp +++ b/manifests/reports.pp @@ -15,7 +15,8 @@ # class datadog_agent::reports( $api_key, - $puppetmaster_user + $puppetmaster_user, + $hostname_extraction_regex ) { include datadog_agent::params diff --git a/templates/datadog.yaml.erb b/templates/datadog.yaml.erb index 26317540..b480aca0 100644 --- a/templates/datadog.yaml.erb +++ b/templates/datadog.yaml.erb @@ -3,3 +3,6 @@ # --- :datadog_api_key: '<%= @api_key %>' +<% if @hostname_extraction_regex.nil? -%> +:hostname_extraction_regex: '<%= @hostname_extraction_regex %>' +<% end -%> From e5e9b8a91840c5558a051bd384212836ae95d22a Mon Sep 17 00:00:00 2001 From: Alan Scherger Date: Tue, 5 Apr 2016 10:02:52 -0500 Subject: [PATCH 09/49] fix mesos with new checks add dd user to docker group update to use docker_daemon add consul allow repo to be optionally managed use_mount is now managed in disk.yaml --- manifests/init.pp | 3 - .../{docker.pp => docker_daemon.pp} | 20 ++- .../{mesos.pp => mesos_master.pp} | 12 +- manifests/integrations/mesos_slave.pp | 29 +++++ manifests/redhat.pp | 6 +- templates/agent-conf.d/docker.yaml.erb | 17 --- templates/agent-conf.d/docker_daemon.yaml.erb | 115 ++++++++++++++++++ .../{mesos.yaml.erb => mesos_master.yaml.erb} | 6 +- templates/agent-conf.d/mesos_slave.yaml.erb | 7 ++ templates/datadog.conf.erb | 3 - 10 files changed, 182 insertions(+), 36 deletions(-) rename manifests/integrations/{docker.pp => docker_daemon.pp} (56%) rename manifests/integrations/{mesos.pp => mesos_master.pp} (69%) create mode 100644 manifests/integrations/mesos_slave.pp delete mode 100644 templates/agent-conf.d/docker.yaml.erb create mode 100644 templates/agent-conf.d/docker_daemon.yaml.erb rename templates/agent-conf.d/{mesos.yaml.erb => mesos_master.yaml.erb} (58%) create mode 100644 templates/agent-conf.d/mesos_slave.yaml.erb diff --git a/manifests/init.pp b/manifests/init.pp index a626cc2e..3f51ad75 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -42,9 +42,6 @@ # $log_to_syslog # Set value of 'log_to_syslog' variable. Default is true -> yes as in dd-agent. # Valid values here are: true or false. -# $use_mount -# Allow overriding default of tracking disks by device path instead of mountpoint -# Valid values here are: true or false. # $dogstatsd_port # Set value of the 'dogstatsd_port' variable. Defaultis 8125. # $statsd_forward_host diff --git a/manifests/integrations/docker.pp b/manifests/integrations/docker_daemon.pp similarity index 56% rename from manifests/integrations/docker.pp rename to manifests/integrations/docker_daemon.pp index 57ac2443..7d05812c 100644 --- a/manifests/integrations/docker.pp +++ b/manifests/integrations/docker_daemon.pp @@ -12,6 +12,10 @@ # $tags: # optional array of tags # +# $group: +# optional name of docker group to add dd-agent user too +# +# # Sample Usage: # # class { 'datadog_agent::integrations::docker' : @@ -19,18 +23,30 @@ # url => 'unix://var/run/docker.sock', # } # -class datadog_agent::integrations::docker( +class datadog_agent::integrations::docker_daemon( $new_tag_names = true, $url = 'unix://var/run/docker.sock', $tags = [], + $group = 'docker', ) inherits datadog_agent::params { + exec { 'dd-agent-should-be-in-docker-group': + command => "/usr/sbin/usermod -aG ${group} ${datadog_agent::params::dd_user}", + unless => "/bin/cat /etc/group | grep '^${group}:' | grep -qw ${datadog_agent::params::dd_user}", + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name] + } + file { "${datadog_agent::params::conf_dir}/docker.yaml": + ensure => 'absent' + } + + file { "${datadog_agent::params::conf_dir}/docker_daemon.yaml": ensure => file, owner => $datadog_agent::params::dd_user, group => $datadog_agent::params::dd_group, mode => '0644', - content => template('datadog_agent/agent-conf.d/docker.yaml.erb'), + content => template('datadog_agent/agent-conf.d/docker_daemon.yaml.erb'), require => Package[$datadog_agent::params::package_name], notify => Service[$datadog_agent::params::service_name] } diff --git a/manifests/integrations/mesos.pp b/manifests/integrations/mesos_master.pp similarity index 69% rename from manifests/integrations/mesos.pp rename to manifests/integrations/mesos_master.pp index 7b0ab913..37ac1915 100644 --- a/manifests/integrations/mesos.pp +++ b/manifests/integrations/mesos_master.pp @@ -1,4 +1,4 @@ -# Class: datadog_agent::integrations::mesos +# Class: datadog_agent::integrations::mesos_master # # This class will install the necessary configuration for the mesos integration # @@ -12,17 +12,21 @@ # url => "http://localhost:5050" # } # -class datadog_agent::integrations::mesos( - $mesos_timeout = 5, +class datadog_agent::integrations::mesos_master( + $mesos_timeout = 10, $url = 'http://localhost:5050' ) inherits datadog_agent::params { file { "${datadog_agent::params::conf_dir}/mesos.yaml": + ensure => 'absent' + } + + file { "${datadog_agent::params::conf_dir}/mesos_master.yaml": ensure => file, owner => $datadog_agent::params::dd_user, group => $datadog_agent::params::dd_group, mode => '0644', - content => template('datadog_agent/agent-conf.d/mesos.yaml.erb'), + content => template('datadog_agent/agent-conf.d/mesos_master.yaml.erb'), require => Package[$datadog_agent::params::package_name], notify => Service[$datadog_agent::params::service_name] } diff --git a/manifests/integrations/mesos_slave.pp b/manifests/integrations/mesos_slave.pp new file mode 100644 index 00000000..4b1dffaa --- /dev/null +++ b/manifests/integrations/mesos_slave.pp @@ -0,0 +1,29 @@ +# Class: datadog_agent::integrations::mesos_slave +# +# This class will install the necessary configuration for the mesos slave integration +# +# Parameters: +# $url: +# The URL for Mesos slave +# +# Sample Usage: +# +# class { 'datadog_agent::integrations::mesos' : +# url => "http://localhost:5051" +# } +# +class datadog_agent::integrations::mesos_slave( + $mesos_timeout = 10, + $url = 'http://localhost:5051' +) inherits datadog_agent::params { + + file { "${datadog_agent::params::conf_dir}/mesos_slave.yaml": + ensure => file, + owner => $datadog_agent::params::dd_user, + group => $datadog_agent::params::dd_group, + mode => '0644', + content => template('datadog_agent/agent-conf.d/mesos_slave.yaml.erb'), + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name] + } +} diff --git a/manifests/redhat.pp b/manifests/redhat.pp index 5d4f148b..5b11b8b5 100644 --- a/manifests/redhat.pp +++ b/manifests/redhat.pp @@ -17,13 +17,13 @@ $baseurl = "https://yum.datadoghq.com/rpm/${::architecture}/", $gpgkey = 'https://yum.datadoghq.com/DATADOG_RPM_KEY.public', $manage_repo = true, + $agent_version = 'latest' ) { validate_bool($manage_repo) if $manage_repo { validate_string($baseurl) - yumrepo {'datadog': enabled => 1, gpgcheck => 1, @@ -32,7 +32,7 @@ baseurl => $baseurl, } - Package['datadog-agent'] -> Yumrepo['datadog'] + Package { require => Yumrepo['datadog']} } package { 'datadog-agent-base': @@ -41,7 +41,7 @@ } package { 'datadog-agent': - ensure => latest, + ensure => $agent_version, } service { 'datadog-agent': diff --git a/templates/agent-conf.d/docker.yaml.erb b/templates/agent-conf.d/docker.yaml.erb deleted file mode 100644 index edbf9e92..00000000 --- a/templates/agent-conf.d/docker.yaml.erb +++ /dev/null @@ -1,17 +0,0 @@ -# -# MANAGED BY PUPPET -# - -init_config: - -instances: - - url: <%= @url %> - new_tag_names: <%= @new_tag_names %> -<% if @tags and ! @tags.empty? -%> - tags: - <%- Array(@tags).each do |tag| -%> - <%- if tag != '' -%> - - <%= tag %> - <%- end -%> - <%- end -%> -<% end -%> diff --git a/templates/agent-conf.d/docker_daemon.yaml.erb b/templates/agent-conf.d/docker_daemon.yaml.erb new file mode 100644 index 00000000..aaf50110 --- /dev/null +++ b/templates/agent-conf.d/docker_daemon.yaml.erb @@ -0,0 +1,115 @@ +init_config: + # Change the root directory to look at to get cgroup statistics. Useful when running inside a + # container with host directories mounted on a different folder. Default: /. + # Example for the docker-dd-agent container: + # docker_root: /host + + # Timeout in seconds for the connection to the docker daemon + # Default: 5 seconds + # + # timeout: 10 + + # The version of the API the client will use. Specify 'auto' to use the API version provided by the server. + # api_version: auto + + # Use TLS encryption while communicating with the Docker API + # + # tls: False + # tls_client_cert: /path/to/client-cert.pem + # tls_client_key: /path/to/client-key.pem + # tls_cacert: /path/to/ca.pem + # tls_verify: True + +instances: + - ## Daemon and system configuration + ## + + # URL of the Docker daemon socket to reach the Docker API. HTTP/HTTPS also works. + # Warning: if that's a non-local daemon, we won't be able to collect performance metrics. + # + url: <%= @url %> + + ## Data collection + ## + + # Create events whenever a container status change. + # Defaults to true. + # + # collect_events: false + + # Collect disk usage per container with docker.container.size_rw and + # docker.container.size_rootfs metrics. + # Warning: This might take time for Docker daemon to generate, + # ensure that `docker ps -a -q` run fast before enabling it. + # Defaults to false. + # + # collect_container_size: false + + # Collect images stats + # Number of available active images and intermediate images as gauges. + # Defaults to false. + # + # collect_images_stats: false + + # Collect disk usage per image with docker.image.size and docker.image.virtual_size metrics. + # The check gets this size with the `docker images` command. + # Requires collect_images_stats to be enabled. + # Defaults to false. + # + # collect_image_size: false + + + # Exclude containers based on their tags + # An excluded container will be completely ignored. The rule is a regex on the tags. + # + # How it works: exclude first. + # If a tag matches an exclude rule, it won't be included unless it also matches an include rule. + # Examples: + # exclude all, except ubuntu and debian. + # exclude: [".*"] + # include: ["docker_image:ubuntu", "docker_image:debian"] + # + # include all, except ubuntu and debian. + # exclude: ["docker_image:ubuntu", "docker_image:debian"] + # include: [] + # + # Default: include all containers + + + + ## Tagging + ## + + # You can add extra tags to your Docker metrics with the tags list option. + # Example: ["extra_tag", "env:testing"] + # + # tags: [] + + # If the agent is running in an Amazon ECS task, tags container metrics with the ECS task name and version. + # Default: true + # + # ecs_tags: false + + # Custom metrics tagging + # Define which Docker tags to apply on metrics. + # Since it impacts the aggregation, modify it carefully (only if you really need it). + # + # Tags for performance metrics. + # Available: + # - image_name: Name of the image (example: "nginx") + # - image_tag: Tag of the image (example: "latest") + # - docker_image: LEGACY. The full image name:tag string (example: "nginx:latest") + # - container_name: Name of the container (example: "boring_euclid") + # - container_command: Command ran by the container (example: "echo 1") + # + # performance_tags: ["container_name", image_name", "image_tag", "docker_image"] + + # Tags for containers count metrics. + # Available: ["image_name", "image_tag", "docker_image", "container_command"] + # + # container_tags: ["image_name", "image_tag", "docker_image"] + + # List of container label names that should be collected and sent as tags. + # Default to None + # Example: + # collect_labels_as_tags: ["com.docker.compose.service", "com.docker.compose.project"] \ No newline at end of file diff --git a/templates/agent-conf.d/mesos.yaml.erb b/templates/agent-conf.d/mesos_master.yaml.erb similarity index 58% rename from templates/agent-conf.d/mesos.yaml.erb rename to templates/agent-conf.d/mesos_master.yaml.erb index 1d4ee99d..bb67c598 100644 --- a/templates/agent-conf.d/mesos.yaml.erb +++ b/templates/agent-conf.d/mesos_master.yaml.erb @@ -1,8 +1,6 @@ -# -# MANAGED BY PUPPET -# init_config: default_timeout: <%= @mesos_timeout %> + instances: - - url: <%= @url %> + - url: <%= @url %> \ No newline at end of file diff --git a/templates/agent-conf.d/mesos_slave.yaml.erb b/templates/agent-conf.d/mesos_slave.yaml.erb new file mode 100644 index 00000000..17c2e594 --- /dev/null +++ b/templates/agent-conf.d/mesos_slave.yaml.erb @@ -0,0 +1,7 @@ +init_config: + default_timeout: <%= @mesos_timeout %> + +instances: + - url: <%= @url %> + # tasks: + # - "hello" \ No newline at end of file diff --git a/templates/datadog.conf.erb b/templates/datadog.conf.erb index feb7dd15..779cef13 100644 --- a/templates/datadog.conf.erb +++ b/templates/datadog.conf.erb @@ -79,9 +79,6 @@ collect_instance_metadata: <%= @collect_instance_metadata %> # Defaults to 30 seconds if no value is provided #recent_point_threshold: 30 -# Use mount points instead of volumes to track disk and fs metrics -use_mount: <%= @use_mount %> - # Change port the Agent is listening to # listen_port: 17123 From e05b0b1297f75e2670d8065f09cf869ddcfcfbc0 Mon Sep 17 00:00:00 2001 From: Jaime Fullaondo Date: Thu, 7 Apr 2016 15:00:55 -0400 Subject: [PATCH 10/49] [spec] fixing spec for hostname_extraction_regex in Reports. --- manifests/init.pp | 4 ++-- spec/classes/datadog_agent_reports_spec.rb | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 3f51ad75..9e61a07f 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -213,8 +213,8 @@ if $puppet_run_reports { class { 'datadog_agent::reports': - api_key => $api_key, - puppetmaster_user => $puppetmaster_user, + api_key => $api_key, + puppetmaster_user => $puppetmaster_user, hostname_extraction_regex => $hostname_extraction_regex, } } diff --git a/spec/classes/datadog_agent_reports_spec.rb b/spec/classes/datadog_agent_reports_spec.rb index 318e19c0..4d72a82f 100644 --- a/spec/classes/datadog_agent_reports_spec.rb +++ b/spec/classes/datadog_agent_reports_spec.rb @@ -4,6 +4,7 @@ let(:params) do { api_key: 'notanapikey', + hostname_extraction_regex: nil, puppetmaster_user: 'puppet' } end From 43fe1b4891fb2ce451a719801fc42e00315456b5 Mon Sep 17 00:00:00 2001 From: Jaime Fullaondo Date: Thu, 7 Apr 2016 16:58:58 -0400 Subject: [PATCH 11/49] [http_check] fixing variable reassignment, and template. [http_check] fixing template. [http_check] fixing yaml alignment. --- manifests/integrations/http_check.pp | 4 ++- templates/agent-conf.d/http_check.yaml.erb | 34 +++++++++++----------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/manifests/integrations/http_check.pp b/manifests/integrations/http_check.pp index 0da8e325..5a8750ff 100644 --- a/manifests/integrations/http_check.pp +++ b/manifests/integrations/http_check.pp @@ -90,7 +90,7 @@ ) inherits datadog_agent::params { if $instances == undef { - $instances = [{ + $_instances = [{ 'url' => $url, 'username' => $username, 'password' => $password, @@ -104,6 +104,8 @@ 'tags' => $tags, 'contact' => $contact, }] + } else { + $_instances = $instances } file { "${datadog_agent::params::conf_dir}/http_check.yaml": diff --git a/templates/agent-conf.d/http_check.yaml.erb b/templates/agent-conf.d/http_check.yaml.erb index d63ad134..fb3683f4 100644 --- a/templates/agent-conf.d/http_check.yaml.erb +++ b/templates/agent-conf.d/http_check.yaml.erb @@ -1,52 +1,52 @@ init_config: instances: -<%- (Array(@instances)).each do |instance| -%> - - name: <%= instance['name'] %> - url: <%= instance['url'] %> +<%- (Array(@_instances)).each do |instance| -%> + - name: <%= instance['name'] %> + url: <%= instance['url'] %> <% if instance['timeout'] -%> - timeout: <%= instance['timeout'] %> + timeout: <%= instance['timeout'] %> <% end -%> <% if instance['username'] -%> - username: <%= instance['username'] %> + username: <%= instance['username'] %> <% end -%> <% if instance['password'] -%> - password: <%= instance['password'] %> + password: <%= instance['password'] %> <% end -%> <% if instance['threshold'] -%> - threshold: <%= instance['threshold'] %> + threshold: <%= instance['threshold'] %> <% end -%> <% if instance['window'] -%> - window: <%= instance['window'] %> + window: <%= instance['window'] %> <% end -%> <% if instance['include_content'] -%> - include_content: <%= instance['include_content'] %> + include_content: <%= instance['include_content'] %> <% end -%> <% if instance['collect_response_time'] -%> - collect_response_time: <%= instance['collect_response_time'] %> + collect_response_time: <%= instance['collect_response_time'] %> <% end -%> - disable_ssl_validation: <%= instance['disable_ssl_validation'] %> + disable_ssl_validation: <%= instance['disable_ssl_validation'] %> <% if instance['headers'] and ! instance['headers'].empty? -%> - headers: + headers: <%- Array(instance['headers']).each do |header| -%> <%- if header != '' -%> - <%= header %> + <%= header %> <%- end -%> <%- end -%> <% end -%> <% if instance['tags'] and ! instance['tags'].empty? -%> - tags: + tags: <%- Array(instance['tags']).each do |tag| -%> <%- if tag != '' -%> - - <%= tag %> + - <%= tag %> <%- end -%> <%- end -%> <% end -%> <% if instance['contacts'] and ! instance['contacts'].empty? -%> - notify: + notify: <%- Array(instance['contacts']).each do |contact| -%> <%- if contact != '' -%> - - <%= contact %> + - <%= contact %> <%- end -%> <%- end -%> <% end -%> From ad64a965b0fb6dcf6b50931c12aba8631bf9b2c0 Mon Sep 17 00:00:00 2001 From: obowersa Date: Mon, 30 Mar 2015 15:42:42 +0100 Subject: [PATCH 12/49] Expanded datadog.conf.erb to parametize additional options. Spec tests have been exapnde to cover these options Added documentation to init.pp Added in tests/paramters for syslog host/port Fixed some typos Added coverage for dogstreams Fixed missing check for custom_emitters Fixed up additional new lines in the template file Added checks for new lines in tests --- manifests/init.pp | 136 ++++++++- spec/classes/datadog_agent_spec.rb | 452 +++++++++++++++++++++++++++++ templates/datadog.conf.erb | 94 +++++- 3 files changed, 675 insertions(+), 7 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 9e61a07f..142fe0e5 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -7,7 +7,6 @@ # The host of the Datadog intake server to send agent data to. # Defaults to https://app.datadoghq.com. # $host: -# Your hostname to see in Datadog. Defaults with Datadog hostname detection. # $api_key: # Your DataDog API Key. Please replace with your key value. # $collect_ec2_tags @@ -73,6 +72,90 @@ # Skip SSL validation. # $use_curl_http_client # Uses the curl HTTP client for the forwarder +# $collect_ec2_tas +# Presents custom EC2 tags as agent tags to datadog +# Boolean. Default: False +# $collect_instance_metadata +# Enables the agent to try and gather instance metadata on EC2/GCE +# Boolean. Default: true +# $recent_point_threshold +# Sets the threshold for accepting points. +# String. Default: empty (30 second intervals) +# $listen_port +# Change the port that the agent listens on +# String. Default: empty (port 17123 in dd-agent) +# $additional_checksd +# Additional directory to look for datadog checks in +# String. Default: empty +# $bind_host +# The loopback address the forwarder and Dogstatsd will bind. +# String. Default: empty +# $use_pup +# Enables the local pup dashboard +# Boolean. Default: false +# $pup_port +# Specifies the port to be used by pup. Must have use_pup set +# String. Default: empty +# $pup_interface +# Specifies which interface pup will use. Must have use_pup set +# String. Default: empty +# $pup_url +# Specifies the URL used to access pup. Must have use_pup set +# String. Default: empty +# $use_dogstatsd +# Enables the dogstatsd server +# Boolean. Default: false +# $dogstatsd_port +# Specifies the port to be used by dogstatsd. Must have use_dogstatsd set +# String. Default: empty +# $dogstatsd_target +# Change the target to be used by dogstatsd. Must have use_dogstatsd set +# set +# String. Default: empty +# $dogstatsd_interval +# Change the dogstatsd flush period. Must have use_dogstatsd set +# String. Default: empty ( 10 second interval) +# $dogstatsd_normalize +# Enables 1 second nomralization. Must have use_dogstatsd set +# Boolean. Default: true +# $statsd_forward_host +# Enables forwarding of statsd packetsto host. Must have use_dogstatsd set +# String. Default: empty +# $statsd_forward_port +# Specifis port for $statsd_forward_host. Must have use_dogstatsd set +# String. Default: empty +# $device_blacklist_re +# Specifies pattern for device blacklisting. +# String. Default: empty +# $ganglia_host +# Specifies host where gmetad is running +# String. Default: empty +# $ganglia_port +# Specifies port for $ganglia_host +# String. Default: empty +# $dogstreams +# Specifies port for list of logstreams/modules to be used. +# String. Default: empty +# $custom_emitters +# Specifies a comma seperated list of non standard emitters to be used +# String. Default: empty +# $custom_emitters +# Specifies a comma seperated list of non standard emitters to be used +# String. Default: empty +# $collector_log_file +# Specifies the log file location for the collector system +# String. Default: empty +# $forwarder_log_file +# Specifies the log file location for the forwarder system +# String. Default: empty +# $dogstatsd +# Specifies the log file location for the dogstatsd system +# String. Default: empty +# $pup_log_file +# Specifies the log file location for the pup system +# String. Default: empty +# +# # Actions: # # Requires: @@ -126,6 +209,31 @@ $skip_ssl_validation = false, $skip_apt_key_trusting = false, $use_curl_http_client = false + $collect_ec2_tags = false, + $collect_instance_metadata = true, + $recent_point_threshold = '', + $listen_port = '', + $additional_checksd = '', + $bind_host = '', + $use_pup = false, + $pup_port = '', + $pup_interface = '', + $pup_url = '', + $use_dogstatsd = false, + $dogstatsd_port = '', + $dogstatsd_target = '', + $dogstatsd_interval = '', + $dogstatsd_normalize = true, + $statsd_forward_host = '', + $statsd_forward_port = '', + $device_blacklist_re = '', + $custom_emitters = '', + $collector_log_file = '', + $forwarder_log_file = '', + $dogstatsd_log_file = '', + $pup_log_file = '', + $syslog_host = '', + $syslog_port = '', ) inherits datadog_agent::params { validate_string($dd_url) @@ -138,6 +246,7 @@ validate_bool($puppet_run_reports) validate_string($puppetmaster_user) validate_bool($non_local_traffic) + validate_bool($non_local_traffic) validate_bool($log_to_syslog) validate_bool($manage_repo) validate_string($log_level) @@ -154,6 +263,31 @@ validate_bool($skip_ssl_validation) validate_bool($skip_apt_key_trusting) validate_bool($use_curl_http_client) + validate_bool($collect_ec2_tags) + validate_bool($collect_instance_metadata) + validate_string($recent_point_threshold) + validate_string($listen_port) + validate_string($additional_checksd) + validate_string($bind_host) + validate_bool($use_pup) + validate_string($pup_port) + validate_string($pup_interface) + validate_string($pup_url) + validate_bool($use_dogstatsd) + validate_string($dogstatsd_port) + validate_string($dogstatsd_target) + validate_string($dogstatsd_interval) + validate_bool($dogstatsd_normalize) + validate_string($statsd_forward_host) + validate_string($statsd_forward_port) + validate_string($device_blacklist_re) + validate_string($custom_emitters) + validate_string($collector_log_file) + validate_string($forwarder_log_file) + validate_string($dogstatsd_log_file) + validate_string($pup_log_file) + validate_string($syslog_host) + validate_string($syslog_port) if $hiera_tags { $local_tags = hiera_array('datadog_agent::tags') diff --git a/spec/classes/datadog_agent_spec.rb b/spec/classes/datadog_agent_spec.rb index 507f922b..d3bc01ea 100644 --- a/spec/classes/datadog_agent_spec.rb +++ b/spec/classes/datadog_agent_spec.rb @@ -43,6 +43,458 @@ it { should contain_class('datadog_agent::reports') } + describe 'parameter check' do + context 'with defaults' do + context 'for proxy' do + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^dd_url: https:\/\/app.datadoghq.com\n/, + )} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^# proxy_host:\n/, + )} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^# proxy_port:\n/, + )} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^# proxy_user:\n/, + )} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^# proxy_password:\n/, + )} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^skip_ssl_validation: no\n/, + )} + end + + context 'for general' do + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^api_key: your_API_key\n/, + )} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^# hostname:\n/, + )} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^use_mount: false\n/, + )} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^non_local_traffic: false\n/, + )} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^collect_ec2_tags: no\n/, + )} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^collect_instance_metadata: yes\n/, + )} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /# recent_point_threshold: 30\n/, + )} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^# listen_port: 17123\n/, + )} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^# graphite_listen_port: 17124\n/, + )} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^# additional_checksd: \/etc\/dd-agent\/checks.d\/\n/, + )} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^use_curl_http_client: true\n/, + )} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^# device_blacklist_re: .*\\\/dev\\\/mapper\\\/lxc-box.*\n/, + )} + + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^# dogstreams:\n/, + )} + end + + context 'for pup' do + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^use_pup: no\n/, + )} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^# pup_port: 17125\n/, + )} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^# pup_interface: localhost\n/, + )} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^# pup_url: http:\/\/localhost:17125\n/, + )} + end + + context 'for dogstatsd' do + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^# bind_host: localhost\n/, + )} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^use_dogstatsd: no\n/, + )} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^# dogstatsd_port : 8125\n/, + )} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^# dogstatsd_target : http:\/\/localhost:17123\n/, + )} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^# dogstatsd_interval : 10\n/, + )} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^dogstatsd_normalize: yes\n/, + )} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^# statsd_forward_host: address_of_own_statsd_server\n/, + )} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^# statsd_forward_port: 8125\n/, + )} + end + + context 'for ganglia' do + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^# ganglia_host: localhost\n/, + )} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^# ganglia_port: 8651\n/, + )} + end + + context 'for logging' do + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^log_level: INFO\n/, + )} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^log_to_syslog: yes\n/, + )} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^# collector_log_file: \/var\/log\/datadog\/collector.log\n/, + )} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^# forwarder_log_file: \/var\/log\/datadog\/forwarder.log\n/, + )} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^# dogstatsd_log_file: \/var\/log\/datadog\/dogstatsd.log\n/, + )} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + #'content' => /^# pup_log_file: \/var\/log\/datadog\/pup.log\n/, + )} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^# syslog_host:\n/, + )} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^# syslog_port:\n/, + )} + end + end + + context 'with user provided paramaters' do + context 'with a custom dd_url' do + let(:params) {{:dd_url => 'https://notaurl.datadoghq.com'}} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^dd_url: https:\/\/notaurl.datadoghq.com\n/, + )} + end + + context 'with a custom proxy_host' do + let(:params) {{:proxy_host => 'localhost'}} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^proxy_host: localhost\n/, + )} + end + + context 'with a custom proxy_port' do + let(:params) {{:proxy_port => '1234'}} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^proxy_port: 1234\n/, + )} + end + + context 'with a custom proxy_user' do + let(:params) {{:proxy_user => 'notauser'}} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^proxy_user: notauser\n/, + )} + end + context 'with a custom api_key' do + let(:params) {{:api_key => 'notakey'}} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^api_key: notakey\n/, + )} + end + + context 'with a custom hostname' do + let(:params) {{:host => 'notahost'}} + + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^hostname: notahost\n/, + )} + end + context 'with use_mount set to true' do + let(:params) {{:use_mount => 'true'}} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^use_mount: true\n/, + )} + end + context 'with non_local_traffic set to true' do + let(:params) {{:non_local_traffic => true}} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^non_local_traffic: true\n/, + )} + end + #Should expand testing to cover changes to the case upcase + context 'with log level set to critical' do + let(:params) {{:log_level => 'critical'}} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^log_level: CRITICAL\n/, + )} + end + context 'with a custom hostname' do + let(:params) {{:host => 'notahost'}} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^hostname: notahost\n/, + )} + end + context 'with log_to_syslog set to false' do + let(:params) {{:log_to_syslog => false}} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^log_to_syslog: no\n/, + )} + end + context 'with skip_ssl_validation set to yes' do + let(:params) {{:skip_ssl_validation => true }} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^skip_ssl_validation: yes\n/, + )} + end + context 'with collect_ec2_tags set to yes' do + let(:params) {{:collect_ec2_tags => true }} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^collect_ec2_tags: yes\n/, + )} + end + context 'with collect_instance_metadata set to no' do + let(:params) {{:collect_ec2_tags => true }} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^collect_ec2_tags: yes\n/, + )} + end + context 'with recent_point_threshold set to 60' do + let(:params) {{:recent_point_threshold => 60 }} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^recent_point_threshold: 60\n/, + )} + end + context 'with a custom port set to 17125' do + let(:params) {{:listen_port => 17125 }} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^listen_port: 17125\n/, + )} + end + context 'litstening for graphite data on port 17124' do + let(:params) {{:graphite_listen_port => 17124 }} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^graphite_listen_port: 17124\n/, + )} + end + context 'with configuration for a custom checks.d' do + let(:params) {{:additional_checksd => '/etc/dd-agent/checks_custom.d' }} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^additional_checksd: \/etc\/dd-agent\/checks_custom.d\n/, + )} + end + context 'with configuration for a custom checks.d' do + let(:params) {{:additional_checksd => '/etc/dd-agent/checks_custom.d' }} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^additional_checksd: \/etc\/dd-agent\/checks_custom.d\n/, + )} + end + + context 'with configuration for a custom checks.d' do + let(:params) {{:additional_checksd => '/etc/dd-agent/checks_custom.d' }} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^additional_checksd: \/etc\/dd-agent\/checks_custom.d\n/, + )} + end + context 'with using the Tornado HTTP client' do + let(:params) {{:use_curl_http_client => false }} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^use_curl_http_client: false\n/, + )} + end + context 'with a custom bind_host' do + let(:params) {{:bind_host => 'test' }} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^bind_host: test\n/, + )} + end + context 'with pup enabled' do + let(:params) {{:use_pup => true }} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^use_pup: yes\n/, + )} + end + context 'with a custom pup_port' do + let(:params) {{:pup_port => 17126 }} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^pup_port: 17126\n/, + )} + end + context 'with a custom pup_interface' do + let(:params) {{:pup_interface => 'notalocalhost' }} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^pup_interface: notalocalhost\n/, + )} + end + + context 'with a custom pup_url' do + let(:params) {{:pup_url => 'http://localhost:17126' }} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^pup_url: http:\/\/localhost:17126\n/, + )} + end + + context 'with use_dogstatsd set to yes' do + let(:params) {{:use_dogstatsd => true}} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^use_dogstatsd: yes\n/, + )} + end + context 'with dogstatsd_port set to 8126' do + let(:params) {{:dogstatsd_port => 8126}} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^dogstatsd_port: 8126\n/, + )} + end + context 'with dogstatsd_target set to localhost:17124' do + let(:params) {{:dogstatsd_target => 'http://localhost:17124'}} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^dogstatsd_target: http:\/\/localhost:17124\n/, + )} + end + context 'with dogstatsd_interval set to 5' do + let(:params) {{:dogstatsd_interval => '5' }} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^dogstatsd_interval: 5\n/, + )} + end + context 'with dogstatsd_interval set to 5' do + let(:params) {{:dogstatsd_interval => '5' }} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^dogstatsd_interval: 5\n/, + )} + end + context 'with dogstatsd_normalize set to false' do + let(:params) {{:dogstatsd_normalize => false }} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^dogstatsd_normalize: no\n/, + )} + end + context 'with statsd_forward_host set to localhost:3958' do + let(:params) {{:statsd_forward_host => 'localhost:3958' }} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^statsd_forward_host: localhost:3958\n/, + )} + end + context 'with statsd_forward_port set to 8126' do + let(:params) {{:statsd_forward_port => '8126' }} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^statsd_forward_port: 8126\n/, + )} + end + context 'with statsd_forward_port set to 8126' do + let(:params) {{:statsd_forward_port => '8126' }} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^statsd_forward_port: 8126\n/, + )} + end + context 'with device_blacklist_re set to test' do + let(:params) {{:device_blacklist_re => 'test' }} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^device_blacklist_re: test\n/, + )} + end + context 'with device_blacklist_re set to test' do + let(:params) {{:device_blacklist_re => 'test' }} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^device_blacklist_re: test\n/, + )} + end + context 'with ganglia_host set to testhost' do + let(:params) {{:ganglia_host => 'testhost' }} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^ganglia_host: testhost\n/, + )} + end + context 'with ganglia_port set to 12345' do + let(:params) {{:ganglia_port => '12345' }} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^ganglia_port: 12345\n/, + )} + end + context 'with dogstreams set to /path/to/log1:/path/to/parser' do + let(:params) {{:dogstreams => '/path/to/log1:/path/to/parser' }} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^dogstreams: \/path\/to\/log1:\/path\/to\/parser\n/, + )} + end + context 'with custom_emitters set to /test/emitter' do + let(:params) {{:custom_emitters => '/test/emitter/' }} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^custom_emitters: \/test\/emitter\/\n/, + )} + end + context 'with custom_emitters set to /test/emitter' do + let(:params) {{:custom_emitters => '/test/emitter/' }} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^custom_emitters: \/test\/emitter\/\n/, + )} + end + context 'with collector_log_file set to /test/log' do + let(:params) {{:collector_log_file => '/test/log' }} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^collector_log_file: \/test\/log\n/, + )} + end + context 'with forwarder_log_file set to /test/log' do + let(:params) {{:forwarder_log_file => '/test/log' }} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^forwarder_log_file: \/test\/log\n/, + )} + end + context 'with forwarder_log_file set to /test/log' do + let(:params) {{:forwarder_log_file => '/test/log' }} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^forwarder_log_file: \/test\/log\n/, + )} + end + context 'with dogstatsd_log_file set to /test/log' do + let(:params) {{:dogstatsd_log_file => '/test/log' }} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^dogstatsd_log_file: \/test\/log\n/, + )} + end + context 'with pup_log_file set to /test/log' do + let(:params) {{:pup_log_file => '/test/log' }} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^pup_log_file: \/test\/log\n/, + )} + end + context 'with syslog location set to localhost' do + let(:params) {{:syslog_host => 'localhost' }} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^syslog_host: localhost\n/, + )} + end + context 'with syslog port set to 8080' do + let(:params) {{:syslog_port => '8080' }} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^syslog_port: 8080\n/, + )} + end + end + end + if DEBIAN_OS.include?(operatingsystem) it { should contain_class('datadog_agent::ubuntu') } elsif REDHAT_OS.include?(operatingsystem) diff --git a/templates/datadog.conf.erb b/templates/datadog.conf.erb index 779cef13..0e425828 100644 --- a/templates/datadog.conf.erb +++ b/templates/datadog.conf.erb @@ -77,10 +77,19 @@ collect_instance_metadata: <%= @collect_instance_metadata %> # Set the threshold for accepting points to allow anything # with recent_point_threshold seconds # Defaults to 30 seconds if no value is provided -#recent_point_threshold: 30 + +<% if @recent_point_threshold.empty? -%> +# recent_point_threshold: 30 +<% else -%> +recent_point_threshold: <%= @recent_point_threshold %> +<% end -%> # Change port the Agent is listening to +<% if @listen_port.empty? -%> # listen_port: 17123 +<% else -%> +listen_port: <%= @listen_port %> +<% end -%> # Start a graphite listener on this port <% if @graphite_listen_port.empty? -%> @@ -90,7 +99,11 @@ graphite_listen_port: <%= @graphite_listen_port %> <% end -%> # Additional directory to look for Datadog checks +<% if @additional_checksd.empty? -%> # additional_checksd: /etc/dd-agent/checks.d/ +<% else -%> +additional_checksd: <%= @additional_checksd %> +<% end -%> # Allow non-local traffic to this Agent # This is required when using this Agent as a proxy for other Agents @@ -105,7 +118,11 @@ 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 +<% if @bind_host.empty? -%> # bind_host: localhost +<% else -%> +bind_host: <%= @bind_host %> +<% end -%> # ========================================================================== # # Pup configuration @@ -115,18 +132,33 @@ use_curl_http_client: <%= @use_curl_http_client %> # Think of it as a fancy status page or a toe dip into the world of # datadog. It can be connected to on the port below. -# use_pup: no +use_pup: <%= @use_pup ? "yes" : "no" %> + +<% if @pup_port.empty? -%> # pup_port: 17125 +<% else -%> +pup_port: <%= @pup_port %> +<% end -%> + +<% if @pup_interface.empty? -%> # pup_interface: localhost +<% else -%> +pup_interface: <%= @pup_interface %> +<% end -%> + +<% if @pup_url.empty? -%> # pup_url: http://localhost:17125 +<% else -%> +pup_url: <%= @pup_url %> +<% end -%> # ========================================================================== # # DogStatsd configuration # # ========================================================================== # # If you don't want to enable the DogStatsd server, set this option to no -# use_dogstatsd: yes +use_dogstatsd: <%= @use_dogstatsd ? "yes" : "no" %> # DogStatsd is a small server that aggregates your custom app metrics. For # usage information, check out http://api.datadoghq.com @@ -140,14 +172,22 @@ dogstatsd_port : <%= @dogstatsd_port %> # By default dogstatsd will post aggregate metrics to the Agent (which handles # errors/timeouts/retries/etc). To send directly to the datadog api, set this # to https://app.datadoghq.com. +<% if @dogstatsd_target.empty? -%> # dogstatsd_target : http://localhost:17123 +<% else -%> +dogstatsd_target: <%= @dogstatsd_target %> +<% end -%> ## The dogstatsd flush period. +<% if @dogstatsd_interval.empty? -%> # dogstatsd_interval : 10 +<% else -%> +dogstatsd_interval: <%= dogstatsd_interval -%> +<% end -%> ## If 'yes', counters and rates will be normalized to 1 second (that is divided ## by the dogstatsd_interval) before being sent to the server. Defaults to 'yes' -# dogstatsd_normalize : yes +dogstatsd_normalize: <%= @dogstatsd_normalize ? "yes" : "no" %> histogram_percentiles: <%= @statsd_histogram_percentiles %> @@ -178,7 +218,12 @@ statsd_forward_port: <%= @statsd_forward_port %> # running constantly churning linux containers) whose metrics aren't # interesting for datadog. To filter out a particular pattern of devices # from collection, configure a regex here: + +<% if @device_blacklist_re.empty? -%> # device_blacklist_re: .*\/dev\/mapper\/lxc-box.* +<% else -%> +device_blacklist_re: <%= @device_blacklist_re %> +<% end -%> # -------------------------------------------------------------------------- # # Ganglia # @@ -186,7 +231,11 @@ statsd_forward_port: <%= @statsd_forward_port %> <% if @ganglia_host.empty? -%> # Ganglia host where gmetad is running -#ganglia_host: localhost +<% if @ganglia_host.empty? -%> +# ganglia_host: localhost +<% else -%> +ganglia_host: <%= @ganglia_host %> +<% end -%> # Ganglia port where gmetad is running #ganglia_port: 8651 @@ -199,7 +248,6 @@ ganglia_port: <%= @ganglia_port %> <% end -%> - # -------------------------------------------------------------------------- # # Dogstream (log file parser) # -------------------------------------------------------------------------- # @@ -246,7 +294,11 @@ dogstreams: <%= dogstreams.join(', ') %> # Expected to be passed as a comma-separated list of colon-delimited # name/object pairs. # +<% if @custom_emitters.empty? -%> # custom_emitters: /usr/local/my-code/emitters/rabbitmq.py:RabbitMQEmitter +<% else -%> +custom_emitters: <%= @custom_emitters %> +<% end -%> # # If the name of the emitter function is not specified, 'emitter' is assumed. @@ -257,17 +309,47 @@ dogstreams: <%= dogstreams.join(', ') %> log_level: <%= @_loglevel %> +<% if @collector_log_file.empty? -%> # collector_log_file: /var/log/datadog/collector.log +<% else -%> +collector_log_file: <%= @collector_log_file %> +<% end -%> + +<% if @forwarder_log_file.empty? -%> # forwarder_log_file: /var/log/datadog/forwarder.log +<% else -%> +forwarder_log_file: <%= @forwarder_log_file %> +<% end -%> + +<% if @dogstatsd_log_file.empty? -%> # dogstatsd_log_file: /var/log/datadog/dogstatsd.log +<% else -%> +dogstatsd_log_file: <%= @dogstatsd_log_file %> +<% end -%> + +<% if @pup_log_file.empty? -%> # pup_log_file: /var/log/datadog/pup.log +<% else -%> +pup_log_file: <%= @pup_log_file %> +<% end -%> + # if syslog is enabled but a host and port are not set, a local domain socket # connection will be attempted # log_to_syslog: <%= @log_to_syslog ? "yes" : "no" %> +<% if @syslog_host.empty? -%> # syslog_host: +<% else -%> +syslog_host: <%= @syslog_host %> +<% end -%> + +<% if @syslog_port.empty? -%> # syslog_port: +<% else -%> +syslog_port: <%= @syslog_port %> +<% end -%> + <% if not @extra_template.empty? -%> # ========================================================================== # # Custom Templates from Puppet # From 5dc07bede002a6e3b86e28cfbf4703c57874ad79 Mon Sep 17 00:00:00 2001 From: Jaime Fullaondo Date: Fri, 8 Apr 2016 01:14:24 -0400 Subject: [PATCH 13/49] [spec] fixing spec issues, inconsistencies. --- manifests/init.pp | 13 ++----- spec/classes/datadog_agent_spec.rb | 62 +++++++++++------------------- templates/datadog.conf.erb | 22 +++++------ 3 files changed, 35 insertions(+), 62 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 142fe0e5..ce97fc53 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -196,7 +196,7 @@ $use_mount = false, $dogstatsd_port = 8125, $statsd_forward_host = '', - $statsd_forward_port = 8125, + $statsd_forward_port = '', $statsd_histogram_percentiles = '0.95', $proxy_host = '', $proxy_port = '', @@ -208,9 +208,7 @@ $ganglia_port = 8651, $skip_ssl_validation = false, $skip_apt_key_trusting = false, - $use_curl_http_client = false - $collect_ec2_tags = false, - $collect_instance_metadata = true, + $use_curl_http_client = false, $recent_point_threshold = '', $listen_port = '', $additional_checksd = '', @@ -220,12 +218,9 @@ $pup_interface = '', $pup_url = '', $use_dogstatsd = false, - $dogstatsd_port = '', $dogstatsd_target = '', $dogstatsd_interval = '', $dogstatsd_normalize = true, - $statsd_forward_host = '', - $statsd_forward_port = '', $device_blacklist_re = '', $custom_emitters = '', $collector_log_file = '', @@ -246,12 +241,12 @@ validate_bool($puppet_run_reports) validate_string($puppetmaster_user) validate_bool($non_local_traffic) - validate_bool($non_local_traffic) validate_bool($log_to_syslog) validate_bool($manage_repo) validate_string($log_level) validate_integer($dogstatsd_port) validate_string($statsd_histogram_percentiles) + validate_string($statsd_forward_port) validate_string($proxy_host) validate_string($proxy_port) validate_string($proxy_user) @@ -274,12 +269,10 @@ validate_string($pup_interface) validate_string($pup_url) validate_bool($use_dogstatsd) - validate_string($dogstatsd_port) validate_string($dogstatsd_target) validate_string($dogstatsd_interval) validate_bool($dogstatsd_normalize) validate_string($statsd_forward_host) - validate_string($statsd_forward_port) validate_string($device_blacklist_re) validate_string($custom_emitters) validate_string($collector_log_file) diff --git a/spec/classes/datadog_agent_spec.rb b/spec/classes/datadog_agent_spec.rb index d3bc01ea..b0bfce3e 100644 --- a/spec/classes/datadog_agent_spec.rb +++ b/spec/classes/datadog_agent_spec.rb @@ -62,7 +62,7 @@ 'content' => /^# proxy_password:\n/, )} it { should contain_file('/etc/dd-agent/datadog.conf').with( - 'content' => /^skip_ssl_validation: no\n/, + 'content' => /^# skip_ssl_validation: no\n/, )} end @@ -74,16 +74,13 @@ 'content' => /^# hostname:\n/, )} it { should contain_file('/etc/dd-agent/datadog.conf').with( - 'content' => /^use_mount: false\n/, - )} - it { should contain_file('/etc/dd-agent/datadog.conf').with( 'content' => /^non_local_traffic: false\n/, )} it { should contain_file('/etc/dd-agent/datadog.conf').with( - 'content' => /^collect_ec2_tags: no\n/, + 'content' => /^collect_ec2_tags: false\n/, )} it { should contain_file('/etc/dd-agent/datadog.conf').with( - 'content' => /^collect_instance_metadata: yes\n/, + 'content' => /^collect_instance_metadata: true\n/, )} it { should contain_file('/etc/dd-agent/datadog.conf').with( 'content' => /# recent_point_threshold: 30\n/, @@ -98,15 +95,11 @@ 'content' => /^# additional_checksd: \/etc\/dd-agent\/checks.d\/\n/, )} it { should contain_file('/etc/dd-agent/datadog.conf').with( - 'content' => /^use_curl_http_client: true\n/, + 'content' => /^use_curl_http_client: false\n/, )} it { should contain_file('/etc/dd-agent/datadog.conf').with( 'content' => /^# device_blacklist_re: .*\\\/dev\\\/mapper\\\/lxc-box.*\n/, )} - - it { should contain_file('/etc/dd-agent/datadog.conf').with( - 'content' => /^# dogstreams:\n/, - )} end context 'for pup' do @@ -132,13 +125,13 @@ 'content' => /^use_dogstatsd: no\n/, )} it { should contain_file('/etc/dd-agent/datadog.conf').with( - 'content' => /^# dogstatsd_port : 8125\n/, + 'content' => /^dogstatsd_port: 8125\n/, )} it { should contain_file('/etc/dd-agent/datadog.conf').with( - 'content' => /^# dogstatsd_target : http:\/\/localhost:17123\n/, + 'content' => /^# dogstatsd_target: http:\/\/localhost:17123\n/, )} it { should contain_file('/etc/dd-agent/datadog.conf').with( - 'content' => /^# dogstatsd_interval : 10\n/, + 'content' => /^# dogstatsd_interval: 10\n/, )} it { should contain_file('/etc/dd-agent/datadog.conf').with( 'content' => /^dogstatsd_normalize: yes\n/, @@ -230,12 +223,6 @@ 'content' => /^hostname: notahost\n/, )} end - context 'with use_mount set to true' do - let(:params) {{:use_mount => 'true'}} - it { should contain_file('/etc/dd-agent/datadog.conf').with( - 'content' => /^use_mount: true\n/, - )} - end context 'with non_local_traffic set to true' do let(:params) {{:non_local_traffic => true}} it { should contain_file('/etc/dd-agent/datadog.conf').with( @@ -261,38 +248,38 @@ 'content' => /^log_to_syslog: no\n/, )} end - context 'with skip_ssl_validation set to yes' do + context 'with skip_ssl_validation set to true' do let(:params) {{:skip_ssl_validation => true }} it { should contain_file('/etc/dd-agent/datadog.conf').with( - 'content' => /^skip_ssl_validation: yes\n/, + 'content' => /^skip_ssl_validation: true\n/, )} end context 'with collect_ec2_tags set to yes' do let(:params) {{:collect_ec2_tags => true }} it { should contain_file('/etc/dd-agent/datadog.conf').with( - 'content' => /^collect_ec2_tags: yes\n/, + 'content' => /^collect_ec2_tags: true\n/, )} end context 'with collect_instance_metadata set to no' do - let(:params) {{:collect_ec2_tags => true }} + let(:params) {{:collect_instance_metadata => false }} it { should contain_file('/etc/dd-agent/datadog.conf').with( - 'content' => /^collect_ec2_tags: yes\n/, + 'content' => /^collect_instance_metadata: false\n/, )} end context 'with recent_point_threshold set to 60' do - let(:params) {{:recent_point_threshold => 60 }} + let(:params) {{:recent_point_threshold => '60' }} it { should contain_file('/etc/dd-agent/datadog.conf').with( 'content' => /^recent_point_threshold: 60\n/, )} end context 'with a custom port set to 17125' do - let(:params) {{:listen_port => 17125 }} + let(:params) {{:listen_port => '17125' }} it { should contain_file('/etc/dd-agent/datadog.conf').with( 'content' => /^listen_port: 17125\n/, )} end context 'litstening for graphite data on port 17124' do - let(:params) {{:graphite_listen_port => 17124 }} + let(:params) {{:graphite_listen_port => '17124' }} it { should contain_file('/etc/dd-agent/datadog.conf').with( 'content' => /^graphite_listen_port: 17124\n/, )} @@ -317,9 +304,9 @@ )} end context 'with using the Tornado HTTP client' do - let(:params) {{:use_curl_http_client => false }} + let(:params) {{:use_curl_http_client => true }} it { should contain_file('/etc/dd-agent/datadog.conf').with( - 'content' => /^use_curl_http_client: false\n/, + 'content' => /^use_curl_http_client: true\n/, )} end context 'with a custom bind_host' do @@ -335,7 +322,7 @@ )} end context 'with a custom pup_port' do - let(:params) {{:pup_port => 17126 }} + let(:params) {{:pup_port => '17126' }} it { should contain_file('/etc/dd-agent/datadog.conf').with( 'content' => /^pup_port: 17126\n/, )} @@ -420,20 +407,17 @@ 'content' => /^device_blacklist_re: test\n/, )} end - context 'with ganglia_host set to testhost' do - let(:params) {{:ganglia_host => 'testhost' }} + context 'with ganglia_host set to localhost and ganglia_port set to 12345' do + let(:params) {{:ganglia_host => 'testhost', :ganglia_port => '12345' }} it { should contain_file('/etc/dd-agent/datadog.conf').with( - 'content' => /^ganglia_host: testhost\n/, + 'content' => /^ganglia_port: 12345\n/, )} - end - context 'with ganglia_port set to 12345' do - let(:params) {{:ganglia_port => '12345' }} it { should contain_file('/etc/dd-agent/datadog.conf').with( - 'content' => /^ganglia_port: 12345\n/, + 'content' => /^ganglia_host: testhost\n/, )} end context 'with dogstreams set to /path/to/log1:/path/to/parser' do - let(:params) {{:dogstreams => '/path/to/log1:/path/to/parser' }} + let(:params) {{:dogstreams => ['/path/to/log1:/path/to/parser'] }} it { should contain_file('/etc/dd-agent/datadog.conf').with( 'content' => /^dogstreams: \/path\/to\/log1:\/path\/to\/parser\n/, )} diff --git a/templates/datadog.conf.erb b/templates/datadog.conf.erb index 0e425828..1470d8a3 100644 --- a/templates/datadog.conf.erb +++ b/templates/datadog.conf.erb @@ -164,25 +164,25 @@ use_dogstatsd: <%= @use_dogstatsd ? "yes" : "no" %> # Make sure your client is sending to the same port. <% if @dogstatsd_port.nil? -%> -# dogstatsd_port : @dogstatsd_port +# dogstatsd_port: 8125 <% else -%> -dogstatsd_port : <%= @dogstatsd_port %> +dogstatsd_port: <%= @dogstatsd_port %> <% end -%> # By default dogstatsd will post aggregate metrics to the Agent (which handles # errors/timeouts/retries/etc). To send directly to the datadog api, set this # to https://app.datadoghq.com. <% if @dogstatsd_target.empty? -%> -# dogstatsd_target : http://localhost:17123 +# dogstatsd_target: http://localhost:17123 <% else -%> dogstatsd_target: <%= @dogstatsd_target %> <% end -%> ## The dogstatsd flush period. <% if @dogstatsd_interval.empty? -%> -# dogstatsd_interval : 10 +# dogstatsd_interval: 10 <% else -%> -dogstatsd_interval: <%= dogstatsd_interval -%> +dogstatsd_interval: <%= @dogstatsd_interval -%> <% end -%> ## If 'yes', counters and rates will be normalized to 1 second (that is divided @@ -200,7 +200,7 @@ histogram_percentiles: <%= @statsd_histogram_percentiles %> <% else -%> statsd_forward_host: <%= @statsd_forward_host %> <% end -%> -<% if @statsd_forward_port.nil? -%> +<% if @statsd_forward_port.empty? -%> # statsd_forward_port: 8125 <% else -%> statsd_forward_port: <%= @statsd_forward_port %> @@ -231,14 +231,10 @@ device_blacklist_re: <%= @device_blacklist_re %> <% if @ganglia_host.empty? -%> # Ganglia host where gmetad is running -<% if @ganglia_host.empty? -%> # ganglia_host: localhost -<% else -%> -ganglia_host: <%= @ganglia_host %> -<% end -%> - +# # Ganglia port where gmetad is running -#ganglia_port: 8651 +# ganglia_port: 8651 <% else -%> # Ganglia host where gmetad is running ganglia_host: <%= @ganglia_host %> @@ -282,7 +278,7 @@ ganglia_port: <%= @ganglia_port %> <% if not @dogstreams.empty? -%> -dogstreams: <%= dogstreams.join(', ') %> +dogstreams: <%= @dogstreams.join(', ') %> <% end -%> # ========================================================================== # From 7bc1cc2be4d03c99c701fc75dcaa8388eb5eec6b Mon Sep 17 00:00:00 2001 From: Frank Zwart Date: Thu, 18 Feb 2016 13:53:54 +0100 Subject: [PATCH 14/49] support multiple ports for a single host --- manifests/integrations/redis.pp | 8 ++++---- templates/agent-conf.d/redisdb.yaml.erb | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/manifests/integrations/redis.pp b/manifests/integrations/redis.pp index a79016df..81d573dc 100644 --- a/manifests/integrations/redis.pp +++ b/manifests/integrations/redis.pp @@ -7,8 +7,8 @@ # The host redis is running on # $password # The redis password (optional) -# $port -# The redis port +# $ports +# Array of redis ports # $slowlog_max_len # The max length of the slow-query log (optional) # $tags @@ -26,14 +26,14 @@ class datadog_agent::integrations::redis( $host = 'localhost', $password = '', - $port = 6379, + $ports = [ 6379 ], $slowlog_max_len = '', $tags = [], $keys = [], $warn_on_missing_keys = true, ) inherits datadog_agent::params { - validate_re($port, '^\d+$') + validate_array($ports) validate_array($tags) validate_array($keys) validate_bool($warn_on_missing_keys) diff --git a/templates/agent-conf.d/redisdb.yaml.erb b/templates/agent-conf.d/redisdb.yaml.erb index a8543414..59ce7418 100644 --- a/templates/agent-conf.d/redisdb.yaml.erb +++ b/templates/agent-conf.d/redisdb.yaml.erb @@ -5,8 +5,9 @@ init_config: instances: +<% @ports.each do |port| -%> - host: <%= @host %> - port: <%= @port %> + port: <%= port %> warn_on_missing_keys: <%= @warn_on_missing_keys %> <% if @password.empty? %># <%end %>password: <%= @password %> # unix_socket_path: /var/run/redis/redis.sock # optional, can be used in lieu of host/port @@ -23,3 +24,4 @@ instances: - <%= key %> <% end -%> <% end -%> +<% end -%> From 3f3f15b13f5ea28744c990eec3b08c5e475e8d2b Mon Sep 17 00:00:00 2001 From: Jaime Fullaondo Date: Fri, 8 Apr 2016 13:29:55 -0400 Subject: [PATCH 15/49] [redis] making backward compatible by keeping port parameter. --- manifests/integrations/redis.pp | 16 +++++++++++++--- templates/agent-conf.d/redisdb.yaml.erb | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/manifests/integrations/redis.pp b/manifests/integrations/redis.pp index 81d573dc..54630cf3 100644 --- a/manifests/integrations/redis.pp +++ b/manifests/integrations/redis.pp @@ -7,8 +7,10 @@ # The host redis is running on # $password # The redis password (optional) +# $port +# The main redis port. # $ports -# Array of redis ports +# Array of redis ports: overrides port (optional) # $slowlog_max_len # The max length of the slow-query log (optional) # $tags @@ -26,18 +28,26 @@ class datadog_agent::integrations::redis( $host = 'localhost', $password = '', - $ports = [ 6379 ], + $port = 6379, + $ports = undef, $slowlog_max_len = '', $tags = [], $keys = [], $warn_on_missing_keys = true, ) inherits datadog_agent::params { - validate_array($ports) validate_array($tags) validate_array($keys) validate_bool($warn_on_missing_keys) + if $ports == undef { + $_ports = [ $port ] + } else { + $_ports = $ports + } + + validate_array($_ports) + file { "${datadog_agent::params::conf_dir}/redisdb.yaml": ensure => file, owner => $datadog_agent::params::dd_user, diff --git a/templates/agent-conf.d/redisdb.yaml.erb b/templates/agent-conf.d/redisdb.yaml.erb index 59ce7418..99c61e61 100644 --- a/templates/agent-conf.d/redisdb.yaml.erb +++ b/templates/agent-conf.d/redisdb.yaml.erb @@ -5,7 +5,7 @@ init_config: instances: -<% @ports.each do |port| -%> +<% @_ports.each do |port| -%> - host: <%= @host %> port: <%= port %> warn_on_missing_keys: <%= @warn_on_missing_keys %> From 0ea5310b04300524e721ee4690879de7acd5225c Mon Sep 17 00:00:00 2001 From: Jaime Fullaondo Date: Fri, 8 Apr 2016 15:28:03 -0400 Subject: [PATCH 16/49] [datadog.conf] use_mount is deprecated, removing. --- manifests/init.pp | 1 - 1 file changed, 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index ce97fc53..989cb0c6 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -193,7 +193,6 @@ $service_enable = true, $manage_repo = true, $hostname_extraction_regex = nil, - $use_mount = false, $dogstatsd_port = 8125, $statsd_forward_host = '', $statsd_forward_port = '', From 3aa17e70b18b68cf2d717e28403007843d80530b Mon Sep 17 00:00:00 2001 From: Matt Casper Date: Fri, 8 Apr 2016 10:14:48 -0700 Subject: [PATCH 17/49] Add manifest for the pgbouncer integration --- manifests/integrations/pgbouncer.pp | 46 +++++++++++++++++++++++ templates/agent-conf.d/pgbouncer.yaml.erb | 23 ++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 manifests/integrations/pgbouncer.pp create mode 100644 templates/agent-conf.d/pgbouncer.yaml.erb diff --git a/manifests/integrations/pgbouncer.pp b/manifests/integrations/pgbouncer.pp new file mode 100644 index 00000000..75e95153 --- /dev/null +++ b/manifests/integrations/pgbouncer.pp @@ -0,0 +1,46 @@ +# Class: datadog_agent::integrations::pgbouncer +# +# This class will install the necessary configuration for the pgbouncer integration +# +# Parameters: +# $host: +# The host pgbouncer is listening on +# $port +# The pgbouncer port number +# $username +# The username for the datadog user +# $password +# The password for the datadog user +# $tags +# Optional array of tags +# +# Sample Usage: +# +# class { 'datadog_agent::integrations::pgbouncer' : +# host => 'localhost', +# username => 'datadog', +# port => '6432', +# password => 'some_pass', +# } +# +# +class datadog_agent::integrations::pgbouncer( + $host = 'localhost', + $port = '6432', + $username = 'datadog', + $password, + $tags = [], +) inherits datadog_agent::params { + + validate_array($tags) + + file { "${datadog_agent::params::conf_dir}/pgbouncer.yaml": + ensure => file, + owner => $datadog_agent::params::dd_user, + group => $datadog_agent::params::dd_group, + mode => '0600', + content => template('datadog_agent/agent-conf.d/pgbouncer.yaml.erb'), + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], + } +} diff --git a/templates/agent-conf.d/pgbouncer.yaml.erb b/templates/agent-conf.d/pgbouncer.yaml.erb new file mode 100644 index 00000000..d676099b --- /dev/null +++ b/templates/agent-conf.d/pgbouncer.yaml.erb @@ -0,0 +1,23 @@ +init_config: + +instances: +# - host: localhost +# port: 6432 +# username: my_username +# password: my_password +# tags: +# - optional_tag1 +# - optional_tag2 +# + - host: <%= @host %> + port: <%= @port %> + username: <%= @username %> + password: <%= @password %> +<% if @tags and ! @tags.empty? -%> + tags: + <%- Array(@tags).each do |tag| -%> + <%- if tag != '' -%> + - <%= tag %> + <%- end -%> + <%- end -%> +<% end -%> From a2ae8425c17bd171f1054ab45eb52c2271c0bcaa Mon Sep 17 00:00:00 2001 From: Jaime Fullaondo Date: Tue, 12 Apr 2016 13:38:34 -0400 Subject: [PATCH 18/49] [release] updating CHANGELOG.md [release] pimping changelog. --- CHANGELOG.md | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc3eb70e..e32471a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,29 @@ Changes ======= +# 1.7.0 / 2016-04-12 + +### Notes + +* [FEATURE] Added manifest for PGBouncer. See [#175][]. (Thanks [@mcasper][]). +* [FEATURE] Added manifest for Consul. See [#174][]. (Thanks [@flyinprogrammer][]). +* [FEATURE] Added mesos master and slave manifests for individual management. See [#174][]. (Thanks [@flyinprogrammer][] and [@jangie][]). +* [FEATURE] Added option to extract the hostname from puppet hostname strings with a regex capture group. See [#173][]. (Thanks [@LeoCavaille][]). +* [FEATURE] Added support on multiple ports per host on Redis integration. See [#169][]. (Thanks [@fzwart][]). +* [FEATURE] Added support for disable_ssl_validation on Apache integration. See[#171. (Thanks [@BIAndrews][]). +* [FEATURE] Added support for SSL, additional metrics and database connection in Mongo integration. See [#164][]. (Thanks [@bflad][]). +* [FEATURE] Added support for multiple instance in HTTP check. See [#155][]. (Thanks [@bfla][]d]. +* [FEATURE] Added support for multiple new datadog.conf directives. See [#79][]. (Thanks [@obowersa][]). +* [FEATURE] Decouple yum repo from agent package. See [#168][]. (Thanks [@b2jrock][]). + +* [IMPROVEMENT] Moved GPG key to its own parameter. See [#158][]. (Thanks [@davidgibbons][]). + +* [BUFIX] Updated docker to use more current docker_daemon. See [#174][]. (Thanks [@flyinprogrammer][] and [@jangie][]). + +* [DEPRECATE] Deprecated old docker manifest. See [#174][]. (Thanks [@flyinprogrammer][]). +* [DEPRECATE] Deprecated use_mount option in base manifest. See [#174][]. Thanks [@flyinprogrammer][]). + +* [CI] Improved spec and docs. See [#79][]. (Thanks [@obowersa][]). # 1.6.0 / 2016-01-20 @@ -107,14 +130,34 @@ Changes # 1.0.1 +[#79]: https://github.com/DataDog/puppet-datadog-agent/issues/79 [#139]: https://github.com/DataDog/puppet-datadog-agent/issues/139 [#149]: https://github.com/DataDog/puppet-datadog-agent/issues/149 [#150]: https://github.com/DataDog/puppet-datadog-agent/issues/150 [#154]: https://github.com/DataDog/puppet-datadog-agent/issues/154 +[#155]: https://github.com/DataDog/puppet-datadog-agent/issues/155 [#156]: https://github.com/DataDog/puppet-datadog-agent/issues/156 +[#158]: https://github.com/DataDog/puppet-datadog-agent/issues/158 [#161]: https://github.com/DataDog/puppet-datadog-agent/issues/161 +[#164]: https://github.com/DataDog/puppet-datadog-agent/issues/164 +[#168]: https://github.com/DataDog/puppet-datadog-agent/issues/168 +[#169]: https://github.com/DataDog/puppet-datadog-agent/issues/169 +[#171]: https://github.com/DataDog/puppet-datadog-agent/issues/171 +[#173]: https://github.com/DataDog/puppet-datadog-agent/issues/173 +[#174]: https://github.com/DataDog/puppet-datadog-agent/issues/174 +[#175]: https://github.com/DataDog/puppet-datadog-agent/issues/175 +[@BIAndrews]: https://github.com/BIAndrews +[@LeoCavaille]: https://github.com/LeoCavaille [@MartinDelta]: https://github.com/MartinDelta +[@b2jrock]: https://github.com/b2jrock +[@bflad]: https://github.com/bflad +[@davidgibbons]: https://github.com/davidgibbons +[@flyinprogrammer]: https://github.com/flyinprogrammer +[@fzwart]: https://github.com/fzwart [@grubernaut]: https://github.com/grubernaut +[@jangie]: https://github.com/jangie +[@mcasper]: https://github.com/mcasper [@mrunkel-ut]: https://github.com/mrunkel-ut +[@obowersa]: https://github.com/obowersa [@rtyler]: https://github.com/rtyler [@tuxinaut]: https://github.com/tuxinaut \ No newline at end of file From 117d27af6c897be746df0e23ca7ca6884ec13ad0 Mon Sep 17 00:00:00 2001 From: Jaime Fullaondo Date: Tue, 12 Apr 2016 13:53:51 -0400 Subject: [PATCH 19/49] [release] bumping version metadata. --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 14d28194..d45d5b1b 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "datadog-datadog_agent", - "version": "1.6.0", + "version": "1.7.0", "author": "James Turnbull () and Rob Terhaar () for Datadog Inc.", "summary": "Install the Datadog monitoring agent and report Puppet runs to Datadog", "license": "Apache License, Version 2.0", From 23eb8b2b40585752c02ca66e86105a3d73c4bab7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Cavaill=C3=A9?= Date: Wed, 30 Mar 2016 13:43:55 +0200 Subject: [PATCH 20/49] add option in datadog_agent to extract hostnames (fixes) Fixes #160. This option is a string regex which can be enabled and used to extract the hostname from puppet hostname strings with a capture group. It is useful for people that have specific puppet hostnames and that would like to sanitize them before reporting those in Datadog. --- manifests/init.pp | 1 - manifests/reports.pp | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 989cb0c6..b7271d37 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -344,5 +344,4 @@ hostname_extraction_regex => $hostname_extraction_regex, } } - } diff --git a/manifests/reports.pp b/manifests/reports.pp index af4ca7a6..0d5e157a 100644 --- a/manifests/reports.pp +++ b/manifests/reports.pp @@ -16,7 +16,7 @@ class datadog_agent::reports( $api_key, $puppetmaster_user, - $hostname_extraction_regex + $hostname_extraction_regex = nil ) { include datadog_agent::params From 948b2471f604938da194b2bf57f8642784270a30 Mon Sep 17 00:00:00 2001 From: Jeremy Kitchen Date: Mon, 16 Nov 2015 12:18:47 -0800 Subject: [PATCH 21/49] adds tests for apache integration --- manifests/integrations/apache.pp | 1 + .../datadog_agent_integrations_apache_spec.rb | 88 +++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 spec/classes/datadog_agent_integrations_apache_spec.rb diff --git a/manifests/integrations/apache.pp b/manifests/integrations/apache.pp index cb7bce6f..6f25cd69 100644 --- a/manifests/integrations/apache.pp +++ b/manifests/integrations/apache.pp @@ -33,6 +33,7 @@ $tags = [], $disable_ssl_validation = false ) inherits datadog_agent::params { + include datadog_agent validate_string($url) validate_array($tags) diff --git a/spec/classes/datadog_agent_integrations_apache_spec.rb b/spec/classes/datadog_agent_integrations_apache_spec.rb new file mode 100644 index 00000000..bc11140d --- /dev/null +++ b/spec/classes/datadog_agent_integrations_apache_spec.rb @@ -0,0 +1,88 @@ +require 'spec_helper' + +describe 'datadog_agent::integrations::apache' do + let(:facts) {{ + operatingsystem: 'Ubuntu', + }} + let(:conf_dir) { '/etc/dd-agent/conf.d' } + let(:dd_user) { 'dd-agent' } + let(:dd_group) { 'root' } + let(:dd_package) { 'datadog-agent' } + let(:dd_service) { 'datadog-agent' } + let(:conf_file) { "#{conf_dir}/apache.yaml" } + + it { should compile.with_all_deps } + it { should contain_file(conf_file).with( + owner: dd_user, + group: dd_group, + mode: '0600', + )} + it { should contain_file(conf_file).that_requires("Package[#{dd_package}]") } + it { should contain_file(conf_file).that_notifies("Service[#{dd_service}]") } + + context 'with default parameters' do + it { should contain_file(conf_file).with_content(%r{apache_status_url: http://localhost/server-status\?auto}) } + it { should contain_file(conf_file).without_content(/tags:/) } + it { should contain_file(conf_file).without_content(/apache_user:/) } + it { should contain_file(conf_file).without_content(/apache_password:/) } + end + + context 'with parameters set' do + let(:params) {{ + url: 'http://foobar', + username: 'userfoo', + password: 'passfoo', + tags: %w{foo bar baz}, + }} + it { should contain_file(conf_file).with_content(%r{apache_status_url: http://foobar}) } + it { should contain_file(conf_file).with_content(/apache_user: userfoo/) } + it { should contain_file(conf_file).with_content(/apache_password: passfoo/) } + end + + context 'with tags parameter single value' do + let(:params) {{ + tags: 'foo', + }} + it { should_not compile } + + skip "this is currently unimplemented behavior" do + it { should contain_file(conf_file).with_content(/tags:\s+- foo\s*?[^-]/m) } + end + end + + context 'with tags parameter array' do + let(:params) {{ + tags: %w{ foo bar baz }, + }} + it { should contain_file(conf_file).with_content(/tags:\s+- foo\s+- bar\s+- baz\s*?[^-]/m) } + end + + context 'with tags parameter with an empty tag' do + end + + context 'with tags parameter empty values' do + context 'mixed in with other tags' do + let(:params) {{ + tags: [ 'foo', '', 'baz' ] + }} + + it { should contain_file(conf_file).with_content(/tags:\s+- foo\s+- baz\s*?[^-]/m) } + end + + context 'single element array of an empty string' do + let(:params) {{ + tags: [''], + }} + + skip("undefined behavior") + end + + context 'single value empty string' do + let(:params) {{ + tags: '', + }} + + skip("doubly undefined behavior") + end + end +end From 18e012bb242e77c94eec9d91db849c5088a86bc5 Mon Sep 17 00:00:00 2001 From: Jeremy Kitchen Date: Mon, 16 Nov 2015 15:13:17 -0800 Subject: [PATCH 22/49] removed empty context --- spec/classes/datadog_agent_integrations_apache_spec.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/spec/classes/datadog_agent_integrations_apache_spec.rb b/spec/classes/datadog_agent_integrations_apache_spec.rb index bc11140d..c68839da 100644 --- a/spec/classes/datadog_agent_integrations_apache_spec.rb +++ b/spec/classes/datadog_agent_integrations_apache_spec.rb @@ -57,9 +57,6 @@ it { should contain_file(conf_file).with_content(/tags:\s+- foo\s+- bar\s+- baz\s*?[^-]/m) } end - context 'with tags parameter with an empty tag' do - end - context 'with tags parameter empty values' do context 'mixed in with other tags' do let(:params) {{ From ceff1adaa52459dc2956efe3d7ab4bb031533768 Mon Sep 17 00:00:00 2001 From: Jeremy Kitchen Date: Mon, 16 Nov 2015 15:16:18 -0800 Subject: [PATCH 23/49] adds test for docker integration --- manifests/integrations/docker_daemon.pp | 1 + .../datadog_agent_integrations_docker_spec.rb | 74 +++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 spec/classes/datadog_agent_integrations_docker_spec.rb diff --git a/manifests/integrations/docker_daemon.pp b/manifests/integrations/docker_daemon.pp index 7d05812c..3764f6e1 100644 --- a/manifests/integrations/docker_daemon.pp +++ b/manifests/integrations/docker_daemon.pp @@ -29,6 +29,7 @@ $tags = [], $group = 'docker', ) inherits datadog_agent::params { + include datadog_agent exec { 'dd-agent-should-be-in-docker-group': command => "/usr/sbin/usermod -aG ${group} ${datadog_agent::params::dd_user}", diff --git a/spec/classes/datadog_agent_integrations_docker_spec.rb b/spec/classes/datadog_agent_integrations_docker_spec.rb new file mode 100644 index 00000000..b701a181 --- /dev/null +++ b/spec/classes/datadog_agent_integrations_docker_spec.rb @@ -0,0 +1,74 @@ +require 'spec_helper' + +describe 'datadog_agent::integrations::docker' do + let(:facts) {{ + operatingsystem: 'Ubuntu', + }} + let(:conf_dir) { '/etc/dd-agent/conf.d' } + let(:dd_user) { 'dd-agent' } + let(:dd_group) { 'root' } + let(:dd_package) { 'datadog-agent' } + let(:dd_service) { 'datadog-agent' } + let(:conf_file) { "#{conf_dir}/docker.yaml" } + + it { should compile.with_all_deps } + it { should contain_file(conf_file).with( + owner: dd_user, + group: dd_group, + mode: '0644', + )} + it { should contain_file(conf_file).that_requires("Package[#{dd_package}]") } + it { should contain_file(conf_file).that_notifies("Service[#{dd_service}]") } + + context 'with default parameters' do + it { should contain_file(conf_file).with_content(%r{url: unix://var/run/docker.sock}) } + it { should contain_file(conf_file).with_content(/new_tag_names: true/) } + it { should contain_file(conf_file).without_content(/tags: /) } + end + + context 'with parameters set' do + let(:params) {{ + url: 'unix://foo/bar/baz.sock', + new_tag_names: false, + }} + it { should contain_file(conf_file).with_content(%r{url: unix://foo/bar/baz.sock}) } + it { should contain_file(conf_file).with_content(/new_tag_names: false/) } + end + + context 'with tags parameter array' do + let(:params) {{ + tags: %w{ foo bar baz }, + }} + it { should contain_file(conf_file).with_content(/tags:\s+- foo\s+- bar\s+- baz\s*?[^-]/m) } + end + + context 'with tags parameter with an empty tag' do + end + + context 'with tags parameter empty values' do + context 'mixed in with other tags' do + let(:params) {{ + tags: [ 'foo', '', 'baz' ] + }} + + it { should contain_file(conf_file).with_content(/tags:\s+- foo\s+- baz\s*?[^-]/m) } + end + + context 'single element array of an empty string' do + let(:params) {{ + tags: [''], + }} + + skip("undefined behavior") + end + + context 'single value empty string' do + let(:params) {{ + tags: '', + }} + + skip("doubly undefined behavior") + end + end + +end From 02e28edd8576dfaae02df960c077cb9dc23824ef Mon Sep 17 00:00:00 2001 From: Jeremy Kitchen Date: Mon, 16 Nov 2015 15:26:43 -0800 Subject: [PATCH 24/49] adds tests for elasticsearch integration --- manifests/integrations/elasticsearch.pp | 1 + ...g_agent_integrations_elasticsearch_spec.rb | 35 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 spec/classes/datadog_agent_integrations_elasticsearch_spec.rb diff --git a/manifests/integrations/elasticsearch.pp b/manifests/integrations/elasticsearch.pp index 8e9f2d43..c2ac6d54 100644 --- a/manifests/integrations/elasticsearch.pp +++ b/manifests/integrations/elasticsearch.pp @@ -15,6 +15,7 @@ class datadog_agent::integrations::elasticsearch( $url = 'http://localhost:9200' ) inherits datadog_agent::params { + include datadog_agent file { "${datadog_agent::params::conf_dir}/elastic.yaml": ensure => file, diff --git a/spec/classes/datadog_agent_integrations_elasticsearch_spec.rb b/spec/classes/datadog_agent_integrations_elasticsearch_spec.rb new file mode 100644 index 00000000..7853b748 --- /dev/null +++ b/spec/classes/datadog_agent_integrations_elasticsearch_spec.rb @@ -0,0 +1,35 @@ +require 'spec_helper' + +describe 'datadog_agent::integrations::elasticsearch' do + let(:facts) {{ + operatingsystem: 'Ubuntu', + }} + let(:conf_dir) { '/etc/dd-agent/conf.d' } + let(:dd_user) { 'dd-agent' } + let(:dd_group) { 'root' } + let(:dd_package) { 'datadog-agent' } + let(:dd_service) { 'datadog-agent' } + let(:conf_file) { "#{conf_dir}/elastic.yaml" } + + it { should compile.with_all_deps } + it { should contain_file(conf_file).with( + owner: dd_user, + group: dd_group, + mode: '0644', + )} + + it { should contain_file(conf_file).that_requires("Package[#{dd_package}]") } + it { should contain_file(conf_file).that_notifies("Service[#{dd_service}]") } + + context 'with default parameters' do + it { should contain_file(conf_file).with_content(%r{url: http://localhost:9200}) } + end + + context 'with parameters set' do + let(:params) {{ + url: 'http://foo:4242', + }} + it { should contain_file(conf_file).with_content(%r{http://foo:4242}) } + end + +end From aa2ee89bd773dfa2286eaf5249435920ffd8fda0 Mon Sep 17 00:00:00 2001 From: Jeremy Kitchen Date: Mon, 16 Nov 2015 15:37:13 -0800 Subject: [PATCH 25/49] adds tests for haproxy integration --- manifests/integrations/haproxy.pp | 1 + ...datadog_agent_integrations_haproxy_spec.rb | 57 +++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 spec/classes/datadog_agent_integrations_haproxy_spec.rb diff --git a/manifests/integrations/haproxy.pp b/manifests/integrations/haproxy.pp index 551564c7..ce8d4ac5 100644 --- a/manifests/integrations/haproxy.pp +++ b/manifests/integrations/haproxy.pp @@ -19,6 +19,7 @@ $creds = {}, $url = "http://${::ipaddress}:8080", ) inherits datadog_agent::params { + include datadog_agent file { "${datadog_agent::params::conf_dir}/haproxy.yaml": diff --git a/spec/classes/datadog_agent_integrations_haproxy_spec.rb b/spec/classes/datadog_agent_integrations_haproxy_spec.rb new file mode 100644 index 00000000..1fc6f20f --- /dev/null +++ b/spec/classes/datadog_agent_integrations_haproxy_spec.rb @@ -0,0 +1,57 @@ +require 'spec_helper' + +describe 'datadog_agent::integrations::haproxy' do + let(:facts) {{ + operatingsystem: 'Ubuntu', + ipaddress: '1.2.3.4', + }} + let(:conf_dir) { '/etc/dd-agent/conf.d' } + let(:dd_user) { 'dd-agent' } + let(:dd_group) { 'root' } + let(:dd_package) { 'datadog-agent' } + let(:dd_service) { 'datadog-agent' } + let(:conf_file) { "#{conf_dir}/haproxy.yaml" } + + it { should compile.with_all_deps } + it { should contain_file(conf_file).with( + owner: dd_user, + group: dd_group, + mode: '0644', + )} + it { should contain_file(conf_file).that_requires("Package[#{dd_package}]") } + it { should contain_file(conf_file).that_notifies("Service[#{dd_service}]") } + + context 'with default parameters' do + it { should contain_file(conf_file).with_content(%r{url: http://1.2.3.4:8080}) } + it { should contain_file(conf_file).without_content(%r{username: }) } + it { should contain_file(conf_file).without_content(%r{password: }) } + end + + context 'with url set' do + let(:params) {{ + url: 'http://foo.bar:8421', + }} + it { should contain_file(conf_file).with_content(%r{url: http://foo.bar:8421}) } + end + + context 'with creds set correctly' do + let(:params) {{ + creds: { + 'username' => 'foo', + 'password' => 'bar', + }, + }} + it { should contain_file(conf_file).with_content(%r{username: foo}) } + it { should contain_file(conf_file).with_content(%r{password: bar}) } + end + + context 'with creds set incorrectly' do + let(:params) {{ + 'invalid' => 'is this real life', + }} + + skip 'functionality not yet implemented' do + it { should contain_file(conf_file).without_content(/invalid: is this real life/) } + end + end +end From 8eb8a34aeb5ff82f2857c9d692847213478d16d6 Mon Sep 17 00:00:00 2001 From: Jeremy Kitchen Date: Mon, 16 Nov 2015 16:06:40 -0800 Subject: [PATCH 26/49] adds tests for http check integration --- manifests/integrations/http_check.pp | 1 + ...adog_agent_integrations_http_check_spec.rb | 128 ++++++++++++++++++ 2 files changed, 129 insertions(+) create mode 100644 spec/classes/datadog_agent_integrations_http_check_spec.rb diff --git a/manifests/integrations/http_check.pp b/manifests/integrations/http_check.pp index 5a8750ff..f2f6c6fe 100644 --- a/manifests/integrations/http_check.pp +++ b/manifests/integrations/http_check.pp @@ -88,6 +88,7 @@ $contact = [], $instances = undef, ) inherits datadog_agent::params { + include datadog_agent if $instances == undef { $_instances = [{ diff --git a/spec/classes/datadog_agent_integrations_http_check_spec.rb b/spec/classes/datadog_agent_integrations_http_check_spec.rb new file mode 100644 index 00000000..543acfc9 --- /dev/null +++ b/spec/classes/datadog_agent_integrations_http_check_spec.rb @@ -0,0 +1,128 @@ +require 'spec_helper' + +describe 'datadog_agent::integrations::http_check' do + let(:facts) {{ + operatingsystem: 'Ubuntu', + }} + let(:conf_dir) { '/etc/dd-agent/conf.d' } + let(:dd_user) { 'dd-agent' } + let(:dd_group) { 'root' } + let(:dd_package) { 'datadog-agent' } + let(:dd_service) { 'datadog-agent' } + let(:conf_file) { "#{conf_dir}/http_check.yaml" } + + it { should compile.with_all_deps } + it { should contain_file(conf_file).with( + owner: dd_user, + group: dd_group, + mode: '0600', + )} + it { should contain_file(conf_file).that_requires("Package[#{dd_package}]") } + it { should contain_file(conf_file).that_notifies("Service[#{dd_service}]") } + it { should contain_file(conf_file).with_content(%r{name: datadog_agent::integrations::http_check}) } + + context 'with default parameters' do + it { should contain_file(conf_file).with_content(%r{url: }) } + it { should contain_file(conf_file).without_content(%r{username: }) } + it { should contain_file(conf_file).without_content(%r{password: }) } + it { should contain_file(conf_file).with_content(%r{timeout: 1}) } + it { should contain_file(conf_file).without_content(%{threshold: }) } + it { should contain_file(conf_file).without_content(%r{window: }) } + it { should contain_file(conf_file).without_content(%r{include_content: true}) } + it { should contain_file(conf_file).with_content(%r{collect_response_time: true}) } + it { should contain_file(conf_file).with_content(%r{disable_ssl_validation: false}) } + it { should contain_file(conf_file).without_content(%r{headers: }) } + it { should contain_file(conf_file).without_content(%r{tags: }) } + end + + context 'with parameters set' do + let(:params) {{ + url: 'http://foo.bar.baz:4096', + username: 'foouser', + password: 'barpassword', + timeout: 123, + threshold: 456, + window: 789, + include_content: true, + collect_response_time: false, + disable_ssl_validation: true, + }} + + it { should contain_file(conf_file).with_content(%r{url: http://foo.bar.baz:4096}) } + it { should contain_file(conf_file).with_content(%r{username: foouser}) } + it { should contain_file(conf_file).with_content(%r{password: barpassword}) } + it { should contain_file(conf_file).with_content(%r{timeout: 123}) } + it { should contain_file(conf_file).with_content(%r{threshold: 456}) } + it { should contain_file(conf_file).with_content(%r{window: 789}) } + it { should contain_file(conf_file).with_content(%r{include_content: true}) } + it { should contain_file(conf_file).without_content(%r{collect_response_time: true}) } + it { should contain_file(conf_file).with_content(%r{disable_ssl_validation: true}) } + end + + context 'with headers parameter array' do + let(:params) {{ + headers: %w{ foo bar baz }, + }} + it { should contain_file(conf_file).with_content(/headers:\s+foo\s+bar\s+baz\s*?[^-]/m) } + end + + context 'with headers parameter empty values' do + context 'mixed in with other headers' do + let(:params) {{ + headers: [ 'foo', '', 'baz' ] + }} + + it { should contain_file(conf_file).with_content(/headers:\s+foo\s+baz\s*?[^-]/m) } + end + + context 'single element array of an empty string' do + let(:params) {{ + headers: [''], + }} + + skip("undefined behavior") + end + + context 'single value empty string' do + let(:params) {{ + headers: '', + }} + + skip("doubly undefined behavior") + end + end + + + context 'with tags parameter array' do + let(:params) {{ + tags: %w{ foo bar baz }, + }} + it { should contain_file(conf_file).with_content(/tags:\s+- foo\s+- bar\s+- baz\s*?[^-]/m) } + end + + context 'with tags parameter empty values' do + context 'mixed in with other tags' do + let(:params) {{ + tags: [ 'foo', '', 'baz' ] + }} + + it { should contain_file(conf_file).with_content(/tags:\s+- foo\s+- baz\s*?[^-]/m) } + end + + context 'single element array of an empty string' do + let(:params) {{ + tags: [''], + }} + + skip("undefined behavior") + end + + context 'single value empty string' do + let(:params) {{ + tags: '', + }} + + skip("doubly undefined behavior") + end + end +end From 76107097e24ac9fac99f8f3edf2af87f3bbafb6b Mon Sep 17 00:00:00 2001 From: Jeremy Kitchen Date: Mon, 16 Nov 2015 16:11:41 -0800 Subject: [PATCH 27/49] adds tests for jenkins integration --- manifests/integrations/jenkins.pp | 1 + ...datadog_agent_integrations_jenkins_spec.rb | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 spec/classes/datadog_agent_integrations_jenkins_spec.rb diff --git a/manifests/integrations/jenkins.pp b/manifests/integrations/jenkins.pp index db590cd7..ea206aca 100644 --- a/manifests/integrations/jenkins.pp +++ b/manifests/integrations/jenkins.pp @@ -16,6 +16,7 @@ class datadog_agent::integrations::jenkins( $path = '/var/lib/jenkins' ) inherits datadog_agent::params { + include datadog_agent file { "${datadog_agent::params::conf_dir}/jenkins.yaml": ensure => file, diff --git a/spec/classes/datadog_agent_integrations_jenkins_spec.rb b/spec/classes/datadog_agent_integrations_jenkins_spec.rb new file mode 100644 index 00000000..2d504368 --- /dev/null +++ b/spec/classes/datadog_agent_integrations_jenkins_spec.rb @@ -0,0 +1,34 @@ +require 'spec_helper' + +describe 'datadog_agent::integrations::jenkins' do + let(:facts) {{ + operatingsystem: 'Ubuntu', + }} + let(:conf_dir) { '/etc/dd-agent/conf.d' } + let(:dd_user) { 'dd-agent' } + let(:dd_group) { 'root' } + let(:dd_package) { 'datadog-agent' } + let(:dd_service) { 'datadog-agent' } + let(:conf_file) { "#{conf_dir}/jenkins.yaml" } + + it { should compile.with_all_deps } + it { should contain_file(conf_file).with( + owner: dd_user, + group: dd_group, + mode: '0600', + )} + it { should contain_file(conf_file).that_requires("Package[#{dd_package}]") } + it { should contain_file(conf_file).that_notifies("Service[#{dd_service}]") } + + context 'with default parameters' do + it { should contain_file(conf_file).with_content(%r{jenkins_home: /var/lib/jenkins}) } + end + + context 'with parameters set' do + let(:params) {{ + path: '/foo/bar/baz', + }} + it { should contain_file(conf_file).with_content(%r{jenkins_home: /foo/bar/baz}) } + end + +end From f02af0b47055363704fb8a83c27ab8e7ba343dbf Mon Sep 17 00:00:00 2001 From: Jeremy Kitchen Date: Mon, 16 Nov 2015 16:18:53 -0800 Subject: [PATCH 28/49] adds tests for marathon integration --- manifests/integrations/marathon.pp | 1 + ...atadog_agent_integrations_marathon_spec.rb | 37 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 spec/classes/datadog_agent_integrations_marathon_spec.rb diff --git a/manifests/integrations/marathon.pp b/manifests/integrations/marathon.pp index f45a3440..206e3f84 100644 --- a/manifests/integrations/marathon.pp +++ b/manifests/integrations/marathon.pp @@ -16,6 +16,7 @@ $marathon_timeout = 5, $url = 'http://localhost:8080' ) inherits datadog_agent::params { + include datadog_agent file { "${datadog_agent::params::conf_dir}/marathon.yaml": ensure => file, diff --git a/spec/classes/datadog_agent_integrations_marathon_spec.rb b/spec/classes/datadog_agent_integrations_marathon_spec.rb new file mode 100644 index 00000000..045d3b50 --- /dev/null +++ b/spec/classes/datadog_agent_integrations_marathon_spec.rb @@ -0,0 +1,37 @@ +require 'spec_helper' + +describe 'datadog_agent::integrations::marathon' do + let(:facts) {{ + operatingsystem: 'Ubuntu', + }} + let(:conf_dir) { '/etc/dd-agent/conf.d' } + let(:dd_user) { 'dd-agent' } + let(:dd_group) { 'root' } + let(:dd_package) { 'datadog-agent' } + let(:dd_service) { 'datadog-agent' } + let(:conf_file) { "#{conf_dir}/marathon.yaml" } + + it { should compile.with_all_deps } + it { should contain_file(conf_file).with( + owner: dd_user, + group: dd_group, + mode: '0644', + )} + it { should contain_file(conf_file).that_requires("Package[#{dd_package}]") } + it { should contain_file(conf_file).that_notifies("Service[#{dd_service}]") } + + context 'with default parameters' do + it { should contain_file(conf_file).with_content(%r{default_timeout: 5}) } + it { should contain_file(conf_file).with_content(%r{url: http://localhost:8080}) } + end + + context 'with params set' do + let(:params) {{ + marathon_timeout: 867, + url: 'http://foo.bar.baz:5309', + }} + + it { should contain_file(conf_file).with_content(%r{default_timeout: 867}) } + it { should contain_file(conf_file).with_content(%r{url: http://foo.bar.baz:5309}) } + end +end From 54a5bf2dab0ae25568a56632548dfcb666d2d8ba Mon Sep 17 00:00:00 2001 From: Jeremy Kitchen Date: Mon, 16 Nov 2015 16:24:38 -0800 Subject: [PATCH 29/49] adds test for mesos integration --- manifests/integrations/mesos_master.pp | 1 + .../datadog_agent_integrations_mesos_spec.rb | 36 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 spec/classes/datadog_agent_integrations_mesos_spec.rb diff --git a/manifests/integrations/mesos_master.pp b/manifests/integrations/mesos_master.pp index 37ac1915..1aaec699 100644 --- a/manifests/integrations/mesos_master.pp +++ b/manifests/integrations/mesos_master.pp @@ -16,6 +16,7 @@ $mesos_timeout = 10, $url = 'http://localhost:5050' ) inherits datadog_agent::params { + include datadog_agent file { "${datadog_agent::params::conf_dir}/mesos.yaml": ensure => 'absent' diff --git a/spec/classes/datadog_agent_integrations_mesos_spec.rb b/spec/classes/datadog_agent_integrations_mesos_spec.rb new file mode 100644 index 00000000..836b263f --- /dev/null +++ b/spec/classes/datadog_agent_integrations_mesos_spec.rb @@ -0,0 +1,36 @@ +require 'spec_helper' + +describe 'datadog_agent::integrations::mesos' do + let(:facts) {{ + operatingsystem: 'Ubuntu', + }} + let(:conf_dir) { '/etc/dd-agent/conf.d' } + let(:dd_user) { 'dd-agent' } + let(:dd_group) { 'root' } + let(:dd_package) { 'datadog-agent' } + let(:dd_service) { 'datadog-agent' } + let(:conf_file) { "#{conf_dir}/mesos.yaml" } + + it { should compile.with_all_deps } + it { should contain_file(conf_file).with( + owner: dd_user, + group: dd_group, + mode: '0644', + )} + it { should contain_file(conf_file).that_requires("Package[#{dd_package}]") } + it { should contain_file(conf_file).that_notifies("Service[#{dd_service}]") } + + context 'with default parameters' do + it { should contain_file(conf_file).with_content(%r{default_timeout: 5}) } + it { should contain_file(conf_file).with_content(%r{url: http://localhost:5050}) } + end + + context 'with parameters set' do + let(:params) {{ + mesos_timeout: 867, + url: 'http://foo.bar.baz:5309', + }} + it { should contain_file(conf_file).with_content(%r{default_timeout: 867}) } + it { should contain_file(conf_file).with_content(%r{url: http://foo.bar.baz:5309}) } + end +end From 3552834ab0b0661031e1f99e5353a5f74c6ff5b4 Mon Sep 17 00:00:00 2001 From: Jeremy Kitchen Date: Mon, 16 Nov 2015 16:41:29 -0800 Subject: [PATCH 30/49] adds tests for mongo integration --- manifests/integrations/mongo.pp | 1 + .../datadog_agent_integrations_mongo_spec.rb | 86 +++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 spec/classes/datadog_agent_integrations_mongo_spec.rb diff --git a/manifests/integrations/mongo.pp b/manifests/integrations/mongo.pp index 5cf5895a..20c03143 100644 --- a/manifests/integrations/mongo.pp +++ b/manifests/integrations/mongo.pp @@ -57,6 +57,7 @@ class datadog_agent::integrations::mongo( $servers = [{'host' => 'localhost', 'port' => '27017'}] ) inherits datadog_agent::params { + include datadog_agent validate_array($servers) diff --git a/spec/classes/datadog_agent_integrations_mongo_spec.rb b/spec/classes/datadog_agent_integrations_mongo_spec.rb new file mode 100644 index 00000000..9f88f8fa --- /dev/null +++ b/spec/classes/datadog_agent_integrations_mongo_spec.rb @@ -0,0 +1,86 @@ +require 'spec_helper' + +describe 'datadog_agent::integrations::mongo' do + let(:facts) {{ + operatingsystem: 'Ubuntu', + }} + let(:conf_dir) { '/etc/dd-agent/conf.d' } + let(:dd_user) { 'dd-agent' } + let(:dd_group) { 'root' } + let(:dd_package) { 'datadog-agent' } + let(:dd_service) { 'datadog-agent' } + let(:conf_file) { "#{conf_dir}/mongo.yaml" } + + it { should compile.with_all_deps } + it { should contain_file(conf_file).with( + owner: dd_user, + group: dd_group, + mode: '0600', + )} + it { should contain_file(conf_file).that_requires("Package[#{dd_package}]") } + it { should contain_file(conf_file).that_notifies("Service[#{dd_service}]") } + + context 'with default parameters' do + it { should contain_file(conf_file).with_content(%r{- server: mongodb://localhost:27017}) } + it { should contain_file(conf_file).without_content(%r{tags:}) } + end + + context 'with one mongo' do + let(:params) {{ + servers: [ + { + 'host' => '127.0.0.1', + 'port' => '12345', + 'tags' => %w{ foo bar baz }, + } + ] + }} + + it { should contain_file(conf_file).with_content(%r{server: mongodb://127.0.0.1:12345\s+tags:\s+- foo\s+- bar\s+- baz}) } + end + + context 'with multiple mongos' do + let(:params) {{ + servers: [ + { + 'host' => '127.0.0.1', + 'port' => '34567', + 'tags' => %w{foo bar}, + }, + { + 'host' => '127.0.0.2', + 'port' => '45678', + 'tags' => %w{baz bat}, + } + ] + }} + it { should contain_file(conf_file).with_content(%r{server: mongodb://127.0.0.1:34567\s+tags:\s+- foo\s+- bar}) } + it { should contain_file(conf_file).with_content(%r{server: mongodb://127.0.0.2:45678\s+tags:\s+- baz\s+- bat}) } + it { should contain_file(conf_file).with_content(%r{server:.*127.0.0.1.*server:.*127.0.0.2}m) } + end + + context 'without tags' do + let(:params) {{ + servers: [ + { + 'host' => '127.0.0.1', + 'port' => '12345', + } + ] + }} + + end + + context 'weird tags' do + let(:params) {{ + servers: [ + { + 'host' => '127.0.0.1', + 'port' => '56789', + 'tags' => 'word' + } + ] + }} + it { should_not compile } + end +end From ee7b98ed6c5fb89a74d3417375effd8ad4530582 Mon Sep 17 00:00:00 2001 From: Jeremy Kitchen Date: Mon, 16 Nov 2015 17:01:32 -0800 Subject: [PATCH 31/49] adds tests for mysql integration --- manifests/integrations/mysql.pp | 1 + .../datadog_agent_integrations_mysql_spec.rb | 78 +++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 spec/classes/datadog_agent_integrations_mysql_spec.rb diff --git a/manifests/integrations/mysql.pp b/manifests/integrations/mysql.pp index c0f823a5..aafab8d3 100644 --- a/manifests/integrations/mysql.pp +++ b/manifests/integrations/mysql.pp @@ -36,6 +36,7 @@ $replication = '0', $galera_cluster = '0' ) inherits datadog_agent::params { + include datadog_agent validate_array($tags) diff --git a/spec/classes/datadog_agent_integrations_mysql_spec.rb b/spec/classes/datadog_agent_integrations_mysql_spec.rb new file mode 100644 index 00000000..ece7ded5 --- /dev/null +++ b/spec/classes/datadog_agent_integrations_mysql_spec.rb @@ -0,0 +1,78 @@ +require 'spec_helper' + +describe 'datadog_agent::integrations::mysql' do + let(:facts) {{ + operatingsystem: 'Ubuntu', + }} + let(:conf_dir) { '/etc/dd-agent/conf.d' } + let(:dd_user) { 'dd-agent' } + let(:dd_group) { 'root' } + let(:dd_package) { 'datadog-agent' } + let(:dd_service) { 'datadog-agent' } + let(:conf_file) { "#{conf_dir}/mysql.yaml" } + + context 'with default parameters' do + it { should_not compile } + end + + context 'with password set' do + let(:params) {{ + password: 'foobar', + }} + + it { should compile.with_all_deps } + it { should contain_file(conf_file).with( + owner: dd_user, + group: dd_group, + mode: '0600', + )} + it { should contain_file(conf_file).that_requires("Package[#{dd_package}]") } + it { should contain_file(conf_file).that_notifies("Service[#{dd_service}]") } + + it { should contain_file(conf_file).with_content(%r{pass: foobar}) } + it { should contain_file(conf_file).without_content(%r{tags: }) } + + context 'with defaults' do + it { should contain_file(conf_file).with_content(%r{server: localhost}) } + it { should contain_file(conf_file).with_content(%r{user: datadog}) } + it { should contain_file(conf_file).without_content(%r{sock: }) } + it { should contain_file(conf_file).with_content(%r{replication: 0}) } + it { should contain_file(conf_file).with_content(%r{galera_cluster: 0}) } + end + + context 'with parameters set' do + let(:params) {{ + password: 'foobar', + host: 'mysql1', + user: 'baz', + sock: '/tmp/mysql.foo.sock', + replication: '1', + galera_cluster: '1', + }} + + it { should contain_file(conf_file).with_content(%r{pass: foobar}) } + it { should contain_file(conf_file).with_content(%r{server: mysql1}) } + it { should contain_file(conf_file).with_content(%r{user: baz}) } + it { should contain_file(conf_file).with_content(%r{sock: /tmp/mysql.foo.sock}) } + it { should contain_file(conf_file).with_content(%r{replication: 1}) } + it { should contain_file(conf_file).with_content(%r{galera_cluster: 1}) } + end + + context 'with tags parameter array' do + let(:params) {{ + password: 'foobar', + tags: %w{ foo bar baz }, + }} + it { should contain_file(conf_file).with_content(/tags:[^-]+- foo\s+- bar\s+- baz\s*?[^-]/m) } + end + + context 'tags not array' do + let(:params) {{ + password: 'foobar', + tags: 'aoeu', + }} + + it { should_not compile } + end + end +end From f3e4a0638411b72eda5502c4e6006cc9b8542969 Mon Sep 17 00:00:00 2001 From: Jeremy Kitchen Date: Tue, 17 Nov 2015 10:26:44 -0800 Subject: [PATCH 32/49] adds tests for nginx integration --- manifests/integrations/nginx.pp | 1 + .../datadog_agent_integrations_nginx_spec.rb | 40 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 spec/classes/datadog_agent_integrations_nginx_spec.rb diff --git a/manifests/integrations/nginx.pp b/manifests/integrations/nginx.pp index 14f5e44c..9066da12 100644 --- a/manifests/integrations/nginx.pp +++ b/manifests/integrations/nginx.pp @@ -25,6 +25,7 @@ class datadog_agent::integrations::nginx( $instances = [], ) inherits datadog_agent::params { + include datadog_agent validate_array($instances) diff --git a/spec/classes/datadog_agent_integrations_nginx_spec.rb b/spec/classes/datadog_agent_integrations_nginx_spec.rb new file mode 100644 index 00000000..99cdd1f4 --- /dev/null +++ b/spec/classes/datadog_agent_integrations_nginx_spec.rb @@ -0,0 +1,40 @@ +require 'spec_helper' + +describe 'datadog_agent::integrations::nginx' do + let(:facts) {{ + operatingsystem: 'Ubuntu', + }} + let(:conf_dir) { '/etc/dd-agent/conf.d' } + let(:dd_user) { 'dd-agent' } + let(:dd_group) { 'root' } + let(:dd_package) { 'datadog-agent' } + let(:dd_service) { 'datadog-agent' } + let(:conf_file) { "#{conf_dir}/nginx.yaml" } + + it { should compile.with_all_deps } + it { should contain_file(conf_file).with( + owner: dd_user, + group: dd_group, + mode: '0600', + )} + it { should contain_file(conf_file).that_requires("Package[#{dd_package}]") } + it { should contain_file(conf_file).that_notifies("Service[#{dd_service}]") } + + context 'default parameters' do + it { should contain_file(conf_file).without_content(/^[^#]*nginx_status_url/) } + end + + context 'parameters set' do + let(:params) {{ + instances: [ + { + 'nginx_status_url' => 'http://foo.bar:1941/check', + 'tags' => %w{foo bar baz} + } + ] + }} + + it { should contain_file(conf_file).with_content(%r{nginx_status_url:.*http://foo.bar:1941/check}m) } + it { should contain_file(conf_file).with_content(%r{tags:.*foo.*bar.*baz}m) } + end +end From a19bfe3843e6003fb1a6b158a87cb530ea291f0c Mon Sep 17 00:00:00 2001 From: Jeremy Kitchen Date: Tue, 17 Nov 2015 10:36:57 -0800 Subject: [PATCH 33/49] adds tests for ntp integration --- manifests/integrations/ntp.pp | 1 + .../datadog_agent_integrations_ntp_spec.rb | 35 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 spec/classes/datadog_agent_integrations_ntp_spec.rb diff --git a/manifests/integrations/ntp.pp b/manifests/integrations/ntp.pp index bf8bcfd0..ce4fa9cf 100644 --- a/manifests/integrations/ntp.pp +++ b/manifests/integrations/ntp.pp @@ -30,6 +30,7 @@ $version = undef, $timeout = undef, ) inherits datadog_agent::params { + include datadog_agent file { "${datadog_agent::params::conf_dir}/ntp.yaml": ensure => file, diff --git a/spec/classes/datadog_agent_integrations_ntp_spec.rb b/spec/classes/datadog_agent_integrations_ntp_spec.rb new file mode 100644 index 00000000..f6cfa537 --- /dev/null +++ b/spec/classes/datadog_agent_integrations_ntp_spec.rb @@ -0,0 +1,35 @@ +require 'spec_helper' + +describe 'datadog_agent::integrations::ntp' do + let(:facts) {{ + operatingsystem: 'Ubuntu', + }} + let(:conf_dir) { '/etc/dd-agent/conf.d' } + let(:dd_user) { 'dd-agent' } + let(:dd_group) { 'root' } + let(:dd_package) { 'datadog-agent' } + let(:dd_service) { 'datadog-agent' } + let(:conf_file) { "#{conf_dir}/ntp.yaml" } + + it { should compile.with_all_deps } + it { should contain_file(conf_file).with( + owner: dd_user, + group: dd_group, + mode: '0600', + )} + it { should contain_file(conf_file).that_requires("Package[#{dd_package}]") } + it { should contain_file(conf_file).that_notifies("Service[#{dd_service}]") } + + context 'with default parameters' do + it { should contain_file(conf_file).with_content(/offset_threshold: 60/) } + end + + context 'with parameters set' do + let(:params) {{ + offset_threshold: 42, + }} + it { should contain_file(conf_file).with_content(/offset_threshold: 42/) } + end + + +end From f9251218303af81c7d3656c498a82f6909efc58e Mon Sep 17 00:00:00 2001 From: Jeremy Kitchen Date: Tue, 17 Nov 2015 11:08:08 -0800 Subject: [PATCH 34/49] adds a skipped test for missing functionality in http_check --- .../datadog_agent_integrations_http_check_spec.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/spec/classes/datadog_agent_integrations_http_check_spec.rb b/spec/classes/datadog_agent_integrations_http_check_spec.rb index 543acfc9..60cad4bb 100644 --- a/spec/classes/datadog_agent_integrations_http_check_spec.rb +++ b/spec/classes/datadog_agent_integrations_http_check_spec.rb @@ -125,4 +125,15 @@ skip("doubly undefined behavior") end end + + context 'with contact set' do + let(:params) {{ + contact: %r{alice bob carlo} + }} + + # the parameter is '$contact' and the template uses '@contacts', so neither is used + skip "this functionality appears to not be functional" do + it { should contain_file(conf_file).with_content(%r{notify:\s+- alice\s+bob\s+carlo}) } + end + end end From 88e96203b8595aa856a97a426e939ce3bb1899c4 Mon Sep 17 00:00:00 2001 From: Jeremy Kitchen Date: Tue, 17 Nov 2015 11:13:44 -0800 Subject: [PATCH 35/49] adds tests for postgres integration --- manifests/integrations/postgres.pp | 1 + ...atadog_agent_integrations_postgres_spec.rb | 61 +++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 spec/classes/datadog_agent_integrations_postgres_spec.rb diff --git a/manifests/integrations/postgres.pp b/manifests/integrations/postgres.pp index 40375e43..ae0b9583 100644 --- a/manifests/integrations/postgres.pp +++ b/manifests/integrations/postgres.pp @@ -39,6 +39,7 @@ $tags = [], $tables = [] ) inherits datadog_agent::params { + include datadog_agent validate_array($tags) validate_array($tables) diff --git a/spec/classes/datadog_agent_integrations_postgres_spec.rb b/spec/classes/datadog_agent_integrations_postgres_spec.rb new file mode 100644 index 00000000..f7e514c9 --- /dev/null +++ b/spec/classes/datadog_agent_integrations_postgres_spec.rb @@ -0,0 +1,61 @@ +require 'spec_helper' + +describe 'datadog_agent::integrations::postgres' do + let(:facts) {{ + operatingsystem: 'Ubuntu', + }} + let(:conf_dir) { '/etc/dd-agent/conf.d' } + let(:dd_user) { 'dd-agent' } + let(:dd_group) { 'root' } + let(:dd_package) { 'datadog-agent' } + let(:dd_service) { 'datadog-agent' } + let(:conf_file) { "#{conf_dir}/postgres.yaml" } + + context 'with default parameters' do + it { should_not compile } + end + + context 'with password set' do + let(:params) {{ + password: 'abc123', + }} + + it { should compile.with_all_deps } + it { should contain_file(conf_file).with( + owner: dd_user, + group: dd_group, + mode: '0600', + )} + it { should contain_file(conf_file).that_requires("Package[#{dd_package}]") } + it { should contain_file(conf_file).that_notifies("Service[#{dd_service}]") } + it { should contain_file(conf_file).with_content(/password: abc123/) } + + context 'with default parameters' do + it { should contain_file(conf_file).with_content(%r{host: localhost}) } + it { should contain_file(conf_file).with_content(%r{dbname: postgres}) } + it { should contain_file(conf_file).with_content(%r{port: 5432}) } + it { should contain_file(conf_file).with_content(%r{username: datadog}) } + it { should contain_file(conf_file).without_content(%r{tags: })} + it { should contain_file(conf_file).without_content(%r{^[^#]*relations: }) } + end + + context 'with parameters set' do + let(:params) {{ + host: 'postgres1', + dbname: 'cats', + port: 4142, + username: 'monitoring', + password: 'abc123', + tags: %w{foo bar baz}, + tables: %w{furry fuzzy funky} + }} + it { should contain_file(conf_file).with_content(%r{host: postgres1}) } + it { should contain_file(conf_file).with_content(%r{dbname: cats}) } + it { should contain_file(conf_file).with_content(%r{port: 4142}) } + it { should contain_file(conf_file).with_content(%r{username: monitoring}) } + it { should contain_file(conf_file).with_content(%r{^[^#]*tags:\s+- foo\s+- bar\s+- baz}) } + it { should contain_file(conf_file).with_content(%r{^[^#]*relations:\s+- furry\s+- fuzzy\s+- funky}) } + end + end + +end From ba92ad17919f1881828d066ed38c9fc31d0bed5c Mon Sep 17 00:00:00 2001 From: Jeremy Kitchen Date: Tue, 17 Nov 2015 13:15:15 -0800 Subject: [PATCH 36/49] adds tests for process integration --- manifests/integrations/process.pp | 1 + ...datadog_agent_integrations_process_spec.rb | 41 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 spec/classes/datadog_agent_integrations_process_spec.rb diff --git a/manifests/integrations/process.pp b/manifests/integrations/process.pp index bbe39830..4cc9b1ca 100644 --- a/manifests/integrations/process.pp +++ b/manifests/integrations/process.pp @@ -41,6 +41,7 @@ class datadog_agent::integrations::process( $processes = [], ) inherits datadog_agent::params { + include datadog_agent validate_array( $processes ) diff --git a/spec/classes/datadog_agent_integrations_process_spec.rb b/spec/classes/datadog_agent_integrations_process_spec.rb new file mode 100644 index 00000000..89412c42 --- /dev/null +++ b/spec/classes/datadog_agent_integrations_process_spec.rb @@ -0,0 +1,41 @@ +require 'spec_helper' + +describe 'datadog_agent::integrations::process' do + let(:facts) {{ + operatingsystem: 'Ubuntu', + }} + let(:conf_dir) { '/etc/dd-agent/conf.d' } + let(:dd_user) { 'dd-agent' } + let(:dd_group) { 'root' } + let(:dd_package) { 'datadog-agent' } + let(:dd_service) { 'datadog-agent' } + let(:conf_file) { "#{conf_dir}/process.yaml" } + + it { should compile.with_all_deps } + it { should contain_file(conf_file).with( + owner: dd_user, + group: dd_group, + mode: '0600', + )} + it { should contain_file(conf_file).that_requires("Package[#{dd_package}]") } + it { should contain_file(conf_file).that_notifies("Service[#{dd_service}]") } + + context 'with default parameters' do + it { should contain_file(conf_file).without_content(%r{^[^#]*name:}) } + end + + context 'with parameters set' do + let(:params) {{ + processes: [ + { + 'name' => 'foo', + 'search_string' => 'bar', + 'exact_match' => true + } + ] + }} + it { should contain_file(conf_file).with_content(%r{name: foo}) } + it { should contain_file(conf_file).with_content(%r{search_string: bar}) } + it { should contain_file(conf_file).with_content(%r{exact_match: true}) } + end +end From 1ae02d437453336a1b6c0329f8d74c6f51b9b6ad Mon Sep 17 00:00:00 2001 From: Jeremy Kitchen Date: Tue, 17 Nov 2015 13:32:41 -0800 Subject: [PATCH 37/49] adds tests for rabbitmq integration --- manifests/integrations/rabbitmq.pp | 1 + ...atadog_agent_integrations_rabbitmq_spec.rb | 45 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 spec/classes/datadog_agent_integrations_rabbitmq_spec.rb diff --git a/manifests/integrations/rabbitmq.pp b/manifests/integrations/rabbitmq.pp index 53363d26..70c0fa6e 100644 --- a/manifests/integrations/rabbitmq.pp +++ b/manifests/integrations/rabbitmq.pp @@ -28,6 +28,7 @@ $queues = undef, $vhosts = undef, ) inherits datadog_agent::params { + include datadog_agent file { "${datadog_agent::params::conf_dir}/rabbitmq.yaml": ensure => file, diff --git a/spec/classes/datadog_agent_integrations_rabbitmq_spec.rb b/spec/classes/datadog_agent_integrations_rabbitmq_spec.rb new file mode 100644 index 00000000..0c0b4531 --- /dev/null +++ b/spec/classes/datadog_agent_integrations_rabbitmq_spec.rb @@ -0,0 +1,45 @@ +require 'spec_helper' + +describe 'datadog_agent::integrations::rabbitmq' do + let(:facts) {{ + operatingsystem: 'Ubuntu', + }} + let(:conf_dir) { '/etc/dd-agent/conf.d' } + let(:dd_user) { 'dd-agent' } + let(:dd_group) { 'root' } + let(:dd_package) { 'datadog-agent' } + let(:dd_service) { 'datadog-agent' } + let(:conf_file) { "#{conf_dir}/rabbitmq.yaml" } + + it { should compile.with_all_deps } + it { should contain_file(conf_file).with( + owner: dd_user, + group: dd_group, + mode: '0600', + )} + it { should contain_file(conf_file).that_requires("Package[#{dd_package}]") } + it { should contain_file(conf_file).that_notifies("Service[#{dd_service}]") } + + context 'with default parameters' do + it { should contain_file(conf_file).with_content(%r{rabbitmq_api_url: }) } + it { should contain_file(conf_file).without_content(%r{rabbitmq_user: }) } + it { should contain_file(conf_file).without_content(%r{rabbitmq_pass: }) } + it { should contain_file(conf_file).without_content(%r{queues: }) } + it { should contain_file(conf_file).without_content(%r{vhosts: }) } + end + + context 'with parameters set' do + let(:params) {{ + url: 'http://rabbit1:15672/', + username: 'foo', + password: 'bar', + queues: %w{ queue1 queue2 queue3 }, + vhosts: %w{ vhost1 vhost2 vhost3 }, + }} + it { should contain_file(conf_file).with_content(%r{rabbitmq_api_url: http://rabbit1:15672/}) } + it { should contain_file(conf_file).with_content(%r{rabbitmq_user: foo}) } + it { should contain_file(conf_file).with_content(%r{rabbitmq_pass: bar}) } + it { should contain_file(conf_file).with_content(%r{queues:\s+- queue1\s+- queue2\s+- queue3}) } + it { should contain_file(conf_file).with_content(%r{vhosts:\s+- vhost1\s+- vhost2\s+- vhost3}) } + end +end From 92a2963b0345ddba763845240951d527c3909e46 Mon Sep 17 00:00:00 2001 From: Jeremy Kitchen Date: Wed, 18 Nov 2015 10:27:05 -0800 Subject: [PATCH 38/49] adds tests for redis integration --- manifests/integrations/redis.pp | 1 + .../datadog_agent_integrations_redis_spec.rb | 52 +++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 spec/classes/datadog_agent_integrations_redis_spec.rb diff --git a/manifests/integrations/redis.pp b/manifests/integrations/redis.pp index 54630cf3..ec755aab 100644 --- a/manifests/integrations/redis.pp +++ b/manifests/integrations/redis.pp @@ -35,6 +35,7 @@ $keys = [], $warn_on_missing_keys = true, ) inherits datadog_agent::params { + include datadog_agent validate_array($tags) validate_array($keys) diff --git a/spec/classes/datadog_agent_integrations_redis_spec.rb b/spec/classes/datadog_agent_integrations_redis_spec.rb new file mode 100644 index 00000000..16c30562 --- /dev/null +++ b/spec/classes/datadog_agent_integrations_redis_spec.rb @@ -0,0 +1,52 @@ +require 'spec_helper' + +describe 'datadog_agent::integrations::redis' do + let(:facts) {{ + operatingsystem: 'Ubuntu', + }} + let(:conf_dir) { '/etc/dd-agent/conf.d' } + let(:dd_user) { 'dd-agent' } + let(:dd_group) { 'root' } + let(:dd_package) { 'datadog-agent' } + let(:dd_service) { 'datadog-agent' } + let(:conf_file) { "#{conf_dir}/redisdb.yaml" } + + it { should compile.with_all_deps } + it { should contain_file(conf_file).with( + owner: dd_user, + group: dd_group, + mode: '0600', + )} + it { should contain_file(conf_file).that_requires("Package[#{dd_package}]") } + it { should contain_file(conf_file).that_notifies("Service[#{dd_service}]") } + + context 'with default parameters' do + it { should contain_file(conf_file).with_content(%r{host: localhost}) } + it { should contain_file(conf_file).without_content(%r{^[^#]*password: }) } + it { should contain_file(conf_file).with_content(%r{port: 6379}) } + it { should contain_file(conf_file).without_content(%r{^[^#]*slowlog-max-len: }) } + it { should contain_file(conf_file).without_content(%r{tags:}) } + it { should contain_file(conf_file).without_content(%r{\bkeys:}) } + it { should contain_file(conf_file).with_content(%r{warn_on_missing_keys: true}) } + end + + context 'with parameters set' do + let(:params) {{ + host: 'redis1', + password: 'hunter2', + port: 867, + slowlog_max_len: 5309, + tags: %w{foo bar}, + keys: %w{baz bat}, + warn_on_missing_keys: false, + }} + it { should contain_file(conf_file).with_content(%r{host: redis1}) } + it { should contain_file(conf_file).with_content(%r{^[^#]*password: hunter2}) } + it { should contain_file(conf_file).with_content(%r{port: 867}) } + it { should contain_file(conf_file).with_content(%r{^[^#]*slowlog-max-len: 5309}) } + it { should contain_file(conf_file).with_content(%r{tags:.*\s+- foo\s+- bar}) } + it { should contain_file(conf_file).with_content(%r{keys:.*\s+- baz\s+- bat}) } + it { should contain_file(conf_file).with_content(%r{warn_on_missing_keys: false}) } + end + +end From 5e248c913f09a7ccd0537cf34e2fd7dec3e394d4 Mon Sep 17 00:00:00 2001 From: Jeremy Kitchen Date: Wed, 18 Nov 2015 10:43:16 -0800 Subject: [PATCH 39/49] adds tests for solr integration --- manifests/integrations/solr.pp | 4 +- .../datadog_agent_integrations_solr_spec.rb | 56 +++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 spec/classes/datadog_agent_integrations_solr_spec.rb diff --git a/manifests/integrations/solr.pp b/manifests/integrations/solr.pp index 5ed65e0f..542b5d33 100644 --- a/manifests/integrations/solr.pp +++ b/manifests/integrations/solr.pp @@ -34,7 +34,9 @@ $java_bin_path = undef, $trust_store_path = undef, $trust_store_password = undef, - $tags = {})inherits datadog_agent::params { + $tags = {}, +) inherits datadog_agent::params { + include datadog_agent file { "${datadog_agent::params::conf_dir}/solr.yaml": ensure => file, diff --git a/spec/classes/datadog_agent_integrations_solr_spec.rb b/spec/classes/datadog_agent_integrations_solr_spec.rb new file mode 100644 index 00000000..0aea0cf5 --- /dev/null +++ b/spec/classes/datadog_agent_integrations_solr_spec.rb @@ -0,0 +1,56 @@ +require 'spec_helper' + +describe 'datadog_agent::integrations::solr' do + let(:facts) {{ + operatingsystem: 'Ubuntu', + }} + let(:conf_dir) { '/etc/dd-agent/conf.d' } + let(:dd_user) { 'dd-agent' } + let(:dd_group) { 'root' } + let(:dd_package) { 'datadog-agent' } + let(:dd_service) { 'datadog-agent' } + let(:conf_file) { "#{conf_dir}/solr.yaml" } + + it { should compile.with_all_deps } + it { should contain_file(conf_file).with( + owner: dd_user, + group: dd_group, + mode: '0600', + )} + it { should contain_file(conf_file).that_requires("Package[#{dd_package}]") } + it { should contain_file(conf_file).that_notifies("Service[#{dd_service}]") } + + context 'with default parameters' do + it { should contain_file(conf_file).with_content(%r{host: localhost}) } + it { should contain_file(conf_file).with_content(%r{port: 7199}) } + it { should contain_file(conf_file).without_content(%r{user:}) } + it { should contain_file(conf_file).without_content(%r{password:}) } + it { should contain_file(conf_file).without_content(%r{java_bin_path:}) } + it { should contain_file(conf_file).without_content(%r{trust_store_path:}) } + it { should contain_file(conf_file).without_content(%r{trust_store_password:}) } + end + + context 'with parameters set' do + let(:params) {{ + hostname: 'solr1', + port: 867, + username: 'userfoo', + password: 'passbar', + java_bin_path: '/opt/java/bin', + trust_store_path: '/var/lib/solr/trust_store', + trust_store_password: 'hunter2', + tags: { + 'foo' => 'bar', + 'baz' => 'bat', + } + }} + it { should contain_file(conf_file).with_content(%r{host: solr1}) } + it { should contain_file(conf_file).with_content(%r{port: 867}) } + it { should contain_file(conf_file).with_content(%r{user: userfoo}) } + it { should contain_file(conf_file).with_content(%r{password: passbar}) } + it { should contain_file(conf_file).with_content(%r{java_bin_path: /opt/java/bin}) } + it { should contain_file(conf_file).with_content(%r{trust_store_path: /var/lib/solr/trust_store}) } + it { should contain_file(conf_file).with_content(%r{trust_store_password: hunter2}) } + it { should contain_file(conf_file).with_content(%r{tags:\s+foo: bar\s+baz: bat}) } + end +end From c04da906f571cfaed1f80b39841cfffbb4c10771 Mon Sep 17 00:00:00 2001 From: Jeremy Kitchen Date: Wed, 18 Nov 2015 10:54:55 -0800 Subject: [PATCH 40/49] adds tests for tomcat integration --- manifests/integrations/tomcat.pp | 5 +- .../datadog_agent_integrations_tomcat_spec.rb | 57 +++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 spec/classes/datadog_agent_integrations_tomcat_spec.rb diff --git a/manifests/integrations/tomcat.pp b/manifests/integrations/tomcat.pp index 57f9482d..fb386873 100644 --- a/manifests/integrations/tomcat.pp +++ b/manifests/integrations/tomcat.pp @@ -34,7 +34,10 @@ $java_bin_path = undef, $trust_store_path = undef, $trust_store_password = undef, - $tags = {}) inherits datadog_agent::params { + $tags = {}, +) inherits datadog_agent::params { + include datadog_agent + file { "${datadog_agent::params::conf_dir}/tomcat.yaml": ensure => file, diff --git a/spec/classes/datadog_agent_integrations_tomcat_spec.rb b/spec/classes/datadog_agent_integrations_tomcat_spec.rb new file mode 100644 index 00000000..a463df89 --- /dev/null +++ b/spec/classes/datadog_agent_integrations_tomcat_spec.rb @@ -0,0 +1,57 @@ +require 'spec_helper' + +describe 'datadog_agent::integrations::tomcat' do + let(:facts) {{ + operatingsystem: 'Ubuntu', + }} + let(:conf_dir) { '/etc/dd-agent/conf.d' } + let(:dd_user) { 'dd-agent' } + let(:dd_group) { 'root' } + let(:dd_package) { 'datadog-agent' } + let(:dd_service) { 'datadog-agent' } + let(:conf_file) { "#{conf_dir}/tomcat.yaml" } + + it { should compile.with_all_deps } + it { should contain_file(conf_file).with( + owner: dd_user, + group: dd_group, + mode: '0600', + )} + it { should contain_file(conf_file).that_requires("Package[#{dd_package}]") } + it { should contain_file(conf_file).that_notifies("Service[#{dd_service}]") } + + context 'with default parameters' do + it { should contain_file(conf_file).with_content(%r{host: localhost}) } + it { should contain_file(conf_file).with_content(%r{port: 7199}) } + it { should contain_file(conf_file).without_content(%r{user: }) } + it { should contain_file(conf_file).without_content(%r{password: }) } + it { should contain_file(conf_file).without_content(%r{java_bin_path:}) } + it { should contain_file(conf_file).without_content(%r{trust_store_path:}) } + it { should contain_file(conf_file).without_content(%r{trust_store_password}) } + it { should contain_file(conf_file).without_content(%r{tags:}) } + end + + context 'with parameters set' do + let(:params) {{ + hostname: 'tomcat1', + port: 867, + username: 'userfoo', + password: 'passbar', + java_bin_path: '/opt/bin/java', + trust_store_path: '/var/lib/tomcat/trust_store_path', + trust_store_password: 'hunter2', + tags: { + 'foo' => 'bar', + 'baz' => 'bat', + } + }} + it { should contain_file(conf_file).with_content(%r{host: tomcat1}) } + it { should contain_file(conf_file).with_content(%r{port: 867}) } + it { should contain_file(conf_file).with_content(%r{user: userfoo}) } + it { should contain_file(conf_file).with_content(%r{password: passbar}) } + it { should contain_file(conf_file).with_content(%r{java_bin_path: /opt/bin/java}) } + it { should contain_file(conf_file).with_content(%r{trust_store_path: /var/lib/tomcat/trust_store_path}) } + it { should contain_file(conf_file).with_content(%r{trust_store_password: hunter2}) } + it { should contain_file(conf_file).with_content(%r{tags:\s+foo: bar\s+baz: bat}) } + end +end From c46f6e2dfe4d14aba3ac3e0af2a2967347aae072 Mon Sep 17 00:00:00 2001 From: Jeremy Kitchen Date: Wed, 18 Nov 2015 11:21:50 -0800 Subject: [PATCH 41/49] adds tests for varnish integration --- manifests/integrations/varnish.pp | 1 + ...datadog_agent_integrations_varnish_spec.rb | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 spec/classes/datadog_agent_integrations_varnish_spec.rb diff --git a/manifests/integrations/varnish.pp b/manifests/integrations/varnish.pp index 4fb43e2c..870c47c3 100644 --- a/manifests/integrations/varnish.pp +++ b/manifests/integrations/varnish.pp @@ -22,6 +22,7 @@ $varnishstat = '/usr/bin/varnishstat', $tags = [], ) inherits datadog_agent::params { + include datadog_agent file { "${datadog_agent::params::conf_dir}/varnish.yaml": ensure => file, diff --git a/spec/classes/datadog_agent_integrations_varnish_spec.rb b/spec/classes/datadog_agent_integrations_varnish_spec.rb new file mode 100644 index 00000000..557d7296 --- /dev/null +++ b/spec/classes/datadog_agent_integrations_varnish_spec.rb @@ -0,0 +1,38 @@ +require 'spec_helper' + +describe 'datadog_agent::integrations::varnish' do + let(:facts) {{ + operatingsystem: 'Ubuntu', + }} + let(:conf_dir) { '/etc/dd-agent/conf.d' } + let(:dd_user) { 'dd-agent' } + let(:dd_group) { 'root' } + let(:dd_package) { 'datadog-agent' } + let(:dd_service) { 'datadog-agent' } + let(:conf_file) { "#{conf_dir}/varnish.yaml" } + + it { should compile.with_all_deps } + it { should contain_file(conf_file).with( + owner: dd_user, + group: dd_group, + mode: '0600', + )} + it { should contain_file(conf_file).that_requires("Package[#{dd_package}]") } + it { should contain_file(conf_file).that_notifies("Service[#{dd_service}]") } + + + context 'with default parameters' do + it { should contain_file(conf_file).with_content(%r{varnishstat: /usr/bin/varnishstat}) } + it { should contain_file(conf_file).without_content(%r{tags: }) } + end + + context 'with parameters set' do + let(:params){{ + varnishstat: '/opt/bin/varnishstat', + tags: %w{ foo bar baz }, + }} + + it { should contain_file(conf_file).with_content(%r{varnishstat: /opt/bin/varnishstat}) } + it { should contain_file(conf_file).with_content(%r{tags:\s+- foo\s+- bar\s+- baz}) } + end +end From c17687ad16511c208ce7b9bb25855e6eaee60325 Mon Sep 17 00:00:00 2001 From: Jeremy Kitchen Date: Wed, 18 Nov 2015 11:34:40 -0800 Subject: [PATCH 42/49] adds tests for zookeeper integration --- manifests/integrations/zk.pp | 1 + .../datadog_agent_integrations_zk_spec.rb | 53 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 spec/classes/datadog_agent_integrations_zk_spec.rb diff --git a/manifests/integrations/zk.pp b/manifests/integrations/zk.pp index 154e9114..b85549b7 100644 --- a/manifests/integrations/zk.pp +++ b/manifests/integrations/zk.pp @@ -30,6 +30,7 @@ class datadog_agent::integrations::zk ( $servers = [{'host' => 'localhost', 'port' => '2181'}] ) inherits datadog_agent::params { + include datadog_agent validate_array($servers) diff --git a/spec/classes/datadog_agent_integrations_zk_spec.rb b/spec/classes/datadog_agent_integrations_zk_spec.rb new file mode 100644 index 00000000..4a971222 --- /dev/null +++ b/spec/classes/datadog_agent_integrations_zk_spec.rb @@ -0,0 +1,53 @@ +require 'spec_helper' + +describe 'datadog_agent::integrations::zk' do + let(:facts) {{ + operatingsystem: 'Ubuntu', + }} + let(:conf_dir) { '/etc/dd-agent/conf.d' } + let(:dd_user) { 'dd-agent' } + let(:dd_group) { 'root' } + let(:dd_package) { 'datadog-agent' } + let(:dd_service) { 'datadog-agent' } + let(:conf_file) { "#{conf_dir}/zk.yaml" } + + it { should compile.with_all_deps } + it { should contain_file(conf_file).with( + owner: dd_user, + group: dd_group, + mode: '0600', + )} + it { should contain_file(conf_file).that_requires("Package[#{dd_package}]") } + it { should contain_file(conf_file).that_notifies("Service[#{dd_service}]") } + + context 'with default parameters' do + it { should contain_file(conf_file).with_content(%r{host: localhost}) } + it { should contain_file(conf_file).with_content(%r{port: 2181}) } + it { should contain_file(conf_file).with_content(%r{timeout: 3}) } + it { should contain_file(conf_file).without_content(%r{tags:}) } + end + + context 'with parameters set' do + let(:params) {{ + servers: [ + { + 'host' => 'zookeeper1', + 'port' => '1234', + 'tags' => %w{foo bar}, + }, + { + 'host' => 'zookeeper2', + 'port' => '4567', + 'tags' => %w{baz bat}, + } + ] + }} + it { should contain_file(conf_file).with_content(%r{host: zookeeper1}) } + it { should contain_file(conf_file).with_content(%r{port: 1234}) } + it { should contain_file(conf_file).with_content(%r{tags:\s+- foo\s+- bar}) } + it { should contain_file(conf_file).with_content(%r{host: zookeeper2}) } + it { should contain_file(conf_file).with_content(%r{port: 4567}) } + it { should contain_file(conf_file).with_content(%r{tags:\s+- baz\s+- bat}) } + it { should contain_file(conf_file).with_content(%r{host: zookeeper1.+host: zookeeper2}m) } + end +end From 9680294bce26932090e4bd62e30628af76e997b1 Mon Sep 17 00:00:00 2001 From: Jaime Fullaondo Date: Tue, 12 Apr 2016 18:18:52 -0400 Subject: [PATCH 43/49] [docker_daemon] removing bad parameter new_tag_names. --- manifests/integrations/docker_daemon.pp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/manifests/integrations/docker_daemon.pp b/manifests/integrations/docker_daemon.pp index 3764f6e1..741b1249 100644 --- a/manifests/integrations/docker_daemon.pp +++ b/manifests/integrations/docker_daemon.pp @@ -3,9 +3,6 @@ # This class will install the necessary configuration for the docker integration # # Parameters: -# $new_tag_names: -# Update docker new tags -# # $url: # The URL for docker API # @@ -19,12 +16,10 @@ # Sample Usage: # # class { 'datadog_agent::integrations::docker' : -# new_tag_names => true, # url => 'unix://var/run/docker.sock', # } # class datadog_agent::integrations::docker_daemon( - $new_tag_names = true, $url = 'unix://var/run/docker.sock', $tags = [], $group = 'docker', From fb63bf5ee108d553f4f522c6a6f7a10348f0b6d2 Mon Sep 17 00:00:00 2001 From: Jaime Fullaondo Date: Tue, 12 Apr 2016 18:19:18 -0400 Subject: [PATCH 44/49] [docker_daemon] removing bad parameter new_tag_names. --- templates/agent-conf.d/docker_daemon.yaml.erb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/templates/agent-conf.d/docker_daemon.yaml.erb b/templates/agent-conf.d/docker_daemon.yaml.erb index aaf50110..65eb9825 100644 --- a/templates/agent-conf.d/docker_daemon.yaml.erb +++ b/templates/agent-conf.d/docker_daemon.yaml.erb @@ -79,6 +79,14 @@ instances: ## Tagging ## +<% if @tags and ! @tags.empty? -%> + tags: + <%- Array(@tags).each do |tag| -%> + <%- if tag != '' -%> + - <%= tag %> + <%- end -%> + <%- end -%> +<% end -%> # You can add extra tags to your Docker metrics with the tags list option. # Example: ["extra_tag", "env:testing"] @@ -112,4 +120,4 @@ instances: # List of container label names that should be collected and sent as tags. # Default to None # Example: - # collect_labels_as_tags: ["com.docker.compose.service", "com.docker.compose.project"] \ No newline at end of file + # collect_labels_as_tags: ["com.docker.compose.service", "com.docker.compose.project"] From 2474085b3b7c3a43bb8f1509bb2e5c0f8865b6a5 Mon Sep 17 00:00:00 2001 From: Jaime Fullaondo Date: Tue, 12 Apr 2016 18:24:00 -0400 Subject: [PATCH 45/49] [docker_daemon] renaming spec to docker_daemon, fixing test. --- ...g_agent_integrations_docker_daemon_spec.rb | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 spec/classes/datadog_agent_integrations_docker_daemon_spec.rb diff --git a/spec/classes/datadog_agent_integrations_docker_daemon_spec.rb b/spec/classes/datadog_agent_integrations_docker_daemon_spec.rb new file mode 100644 index 00000000..4d713e1b --- /dev/null +++ b/spec/classes/datadog_agent_integrations_docker_daemon_spec.rb @@ -0,0 +1,70 @@ +require 'spec_helper' + +describe 'datadog_agent::integrations::docker_daemon' do + let(:facts) {{ + operatingsystem: 'Ubuntu', + }} + let(:conf_dir) { '/etc/dd-agent/conf.d' } + let(:dd_user) { 'dd-agent' } + let(:dd_group) { 'root' } + let(:dd_package) { 'datadog-agent' } + let(:dd_service) { 'datadog-agent' } + let(:conf_file) { "#{conf_dir}/docker_daemon.yaml" } + + it { should compile.with_all_deps } + it { should contain_file(conf_file).with( + owner: dd_user, + group: dd_group, + mode: '0644', + )} + it { should contain_file(conf_file).that_requires("Package[#{dd_package}]") } + it { should contain_file(conf_file).that_notifies("Service[#{dd_service}]") } + + context 'with default parameters' do + it { should contain_file(conf_file).with_content(%r{url: unix://var/run/docker.sock}) } + end + + context 'with parameters set' do + let(:params) {{ + url: 'unix://foo/bar/baz.sock', + }} + it { should contain_file(conf_file).with_content(%r{url: unix://foo/bar/baz.sock}) } + end + + context 'with tags parameter array' do + let(:params) {{ + tags: %w{ foo bar baz }, + }} + it { should contain_file(conf_file).with_content(/tags:\s+- foo\s+- bar\s+- baz\s*?[^-]/m) } + end + + context 'with tags parameter with an empty tag' do + end + + context 'with tags parameter empty values' do + context 'mixed in with other tags' do + let(:params) {{ + tags: [ 'foo', '', 'baz' ] + }} + + it { should contain_file(conf_file).with_content(/tags:\s+- foo\s+- baz\s*?[^-]/m) } + end + + context 'single element array of an empty string' do + let(:params) {{ + tags: [''], + }} + + skip("undefined behavior") + end + + context 'single value empty string' do + let(:params) {{ + tags: '', + }} + + skip("doubly undefined behavior") + end + end + +end From 9a77fefdb2c4816007f618edf3306c08861d2e94 Mon Sep 17 00:00:00 2001 From: Jaime Fullaondo Date: Tue, 12 Apr 2016 18:25:46 -0400 Subject: [PATCH 46/49] [mesos] renaming mesos to mesos_master. --- ...og_agent_integrations_mesos_master_spec.rb | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 spec/classes/datadog_agent_integrations_mesos_master_spec.rb diff --git a/spec/classes/datadog_agent_integrations_mesos_master_spec.rb b/spec/classes/datadog_agent_integrations_mesos_master_spec.rb new file mode 100644 index 00000000..8578137a --- /dev/null +++ b/spec/classes/datadog_agent_integrations_mesos_master_spec.rb @@ -0,0 +1,36 @@ +require 'spec_helper' + +describe 'datadog_agent::integrations::mesos_master' do + let(:facts) {{ + operatingsystem: 'Ubuntu', + }} + let(:conf_dir) { '/etc/dd-agent/conf.d' } + let(:dd_user) { 'dd-agent' } + let(:dd_group) { 'root' } + let(:dd_package) { 'datadog-agent' } + let(:dd_service) { 'datadog-agent' } + let(:conf_file) { "#{conf_dir}/mesos_master.yaml" } + + it { should compile.with_all_deps } + it { should contain_file(conf_file).with( + owner: dd_user, + group: dd_group, + mode: '0644', + )} + it { should contain_file(conf_file).that_requires("Package[#{dd_package}]") } + it { should contain_file(conf_file).that_notifies("Service[#{dd_service}]") } + + context 'with default parameters' do + it { should contain_file(conf_file).with_content(%r{default_timeout: 10}) } + it { should contain_file(conf_file).with_content(%r{url: http://localhost:5050}) } + end + + context 'with parameters set' do + let(:params) {{ + mesos_timeout: 867, + url: 'http://foo.bar.baz:5309', + }} + it { should contain_file(conf_file).with_content(%r{default_timeout: 867}) } + it { should contain_file(conf_file).with_content(%r{url: http://foo.bar.baz:5309}) } + end +end From c34121d11662adb9a5da64a9141f0d7c01308cfd Mon Sep 17 00:00:00 2001 From: Jaime Fullaondo Date: Tue, 12 Apr 2016 18:26:16 -0400 Subject: [PATCH 47/49] [spec] fixing tests --- .../datadog_agent_integrations_docker_spec.rb | 74 ------------------- ...adog_agent_integrations_http_check_spec.rb | 1 - .../datadog_agent_integrations_mesos_spec.rb | 36 --------- .../datadog_agent_integrations_mongo_spec.rb | 6 +- .../datadog_agent_integrations_redis_spec.rb | 2 +- templates/agent-conf.d/haproxy.yaml.erb | 2 +- 6 files changed, 5 insertions(+), 116 deletions(-) delete mode 100644 spec/classes/datadog_agent_integrations_docker_spec.rb delete mode 100644 spec/classes/datadog_agent_integrations_mesos_spec.rb diff --git a/spec/classes/datadog_agent_integrations_docker_spec.rb b/spec/classes/datadog_agent_integrations_docker_spec.rb deleted file mode 100644 index b701a181..00000000 --- a/spec/classes/datadog_agent_integrations_docker_spec.rb +++ /dev/null @@ -1,74 +0,0 @@ -require 'spec_helper' - -describe 'datadog_agent::integrations::docker' do - let(:facts) {{ - operatingsystem: 'Ubuntu', - }} - let(:conf_dir) { '/etc/dd-agent/conf.d' } - let(:dd_user) { 'dd-agent' } - let(:dd_group) { 'root' } - let(:dd_package) { 'datadog-agent' } - let(:dd_service) { 'datadog-agent' } - let(:conf_file) { "#{conf_dir}/docker.yaml" } - - it { should compile.with_all_deps } - it { should contain_file(conf_file).with( - owner: dd_user, - group: dd_group, - mode: '0644', - )} - it { should contain_file(conf_file).that_requires("Package[#{dd_package}]") } - it { should contain_file(conf_file).that_notifies("Service[#{dd_service}]") } - - context 'with default parameters' do - it { should contain_file(conf_file).with_content(%r{url: unix://var/run/docker.sock}) } - it { should contain_file(conf_file).with_content(/new_tag_names: true/) } - it { should contain_file(conf_file).without_content(/tags: /) } - end - - context 'with parameters set' do - let(:params) {{ - url: 'unix://foo/bar/baz.sock', - new_tag_names: false, - }} - it { should contain_file(conf_file).with_content(%r{url: unix://foo/bar/baz.sock}) } - it { should contain_file(conf_file).with_content(/new_tag_names: false/) } - end - - context 'with tags parameter array' do - let(:params) {{ - tags: %w{ foo bar baz }, - }} - it { should contain_file(conf_file).with_content(/tags:\s+- foo\s+- bar\s+- baz\s*?[^-]/m) } - end - - context 'with tags parameter with an empty tag' do - end - - context 'with tags parameter empty values' do - context 'mixed in with other tags' do - let(:params) {{ - tags: [ 'foo', '', 'baz' ] - }} - - it { should contain_file(conf_file).with_content(/tags:\s+- foo\s+- baz\s*?[^-]/m) } - end - - context 'single element array of an empty string' do - let(:params) {{ - tags: [''], - }} - - skip("undefined behavior") - end - - context 'single value empty string' do - let(:params) {{ - tags: '', - }} - - skip("doubly undefined behavior") - end - end - -end diff --git a/spec/classes/datadog_agent_integrations_http_check_spec.rb b/spec/classes/datadog_agent_integrations_http_check_spec.rb index 60cad4bb..21057311 100644 --- a/spec/classes/datadog_agent_integrations_http_check_spec.rb +++ b/spec/classes/datadog_agent_integrations_http_check_spec.rb @@ -19,7 +19,6 @@ )} it { should contain_file(conf_file).that_requires("Package[#{dd_package}]") } it { should contain_file(conf_file).that_notifies("Service[#{dd_service}]") } - it { should contain_file(conf_file).with_content(%r{name: datadog_agent::integrations::http_check}) } context 'with default parameters' do it { should contain_file(conf_file).with_content(%r{url: }) } diff --git a/spec/classes/datadog_agent_integrations_mesos_spec.rb b/spec/classes/datadog_agent_integrations_mesos_spec.rb deleted file mode 100644 index 836b263f..00000000 --- a/spec/classes/datadog_agent_integrations_mesos_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'spec_helper' - -describe 'datadog_agent::integrations::mesos' do - let(:facts) {{ - operatingsystem: 'Ubuntu', - }} - let(:conf_dir) { '/etc/dd-agent/conf.d' } - let(:dd_user) { 'dd-agent' } - let(:dd_group) { 'root' } - let(:dd_package) { 'datadog-agent' } - let(:dd_service) { 'datadog-agent' } - let(:conf_file) { "#{conf_dir}/mesos.yaml" } - - it { should compile.with_all_deps } - it { should contain_file(conf_file).with( - owner: dd_user, - group: dd_group, - mode: '0644', - )} - it { should contain_file(conf_file).that_requires("Package[#{dd_package}]") } - it { should contain_file(conf_file).that_notifies("Service[#{dd_service}]") } - - context 'with default parameters' do - it { should contain_file(conf_file).with_content(%r{default_timeout: 5}) } - it { should contain_file(conf_file).with_content(%r{url: http://localhost:5050}) } - end - - context 'with parameters set' do - let(:params) {{ - mesos_timeout: 867, - url: 'http://foo.bar.baz:5309', - }} - it { should contain_file(conf_file).with_content(%r{default_timeout: 867}) } - it { should contain_file(conf_file).with_content(%r{url: http://foo.bar.baz:5309}) } - end -end diff --git a/spec/classes/datadog_agent_integrations_mongo_spec.rb b/spec/classes/datadog_agent_integrations_mongo_spec.rb index 9f88f8fa..c2ba55c0 100644 --- a/spec/classes/datadog_agent_integrations_mongo_spec.rb +++ b/spec/classes/datadog_agent_integrations_mongo_spec.rb @@ -36,7 +36,7 @@ ] }} - it { should contain_file(conf_file).with_content(%r{server: mongodb://127.0.0.1:12345\s+tags:\s+- foo\s+- bar\s+- baz}) } + it { should contain_file(conf_file).with_content(%r{server: mongodb://127.0.0.1:12345/\s+tags:\s+- foo\s+- bar\s+- baz}) } end context 'with multiple mongos' do @@ -54,8 +54,8 @@ } ] }} - it { should contain_file(conf_file).with_content(%r{server: mongodb://127.0.0.1:34567\s+tags:\s+- foo\s+- bar}) } - it { should contain_file(conf_file).with_content(%r{server: mongodb://127.0.0.2:45678\s+tags:\s+- baz\s+- bat}) } + it { should contain_file(conf_file).with_content(%r{server: mongodb://127.0.0.1:34567/\s+tags:\s+- foo\s+- bar}) } + it { should contain_file(conf_file).with_content(%r{server: mongodb://127.0.0.2:45678/\s+tags:\s+- baz\s+- bat}) } it { should contain_file(conf_file).with_content(%r{server:.*127.0.0.1.*server:.*127.0.0.2}m) } end diff --git a/spec/classes/datadog_agent_integrations_redis_spec.rb b/spec/classes/datadog_agent_integrations_redis_spec.rb index 16c30562..cc10fbe8 100644 --- a/spec/classes/datadog_agent_integrations_redis_spec.rb +++ b/spec/classes/datadog_agent_integrations_redis_spec.rb @@ -35,7 +35,7 @@ host: 'redis1', password: 'hunter2', port: 867, - slowlog_max_len: 5309, + slowlog_max_len: '5309', tags: %w{foo bar}, keys: %w{baz bat}, warn_on_missing_keys: false, diff --git a/templates/agent-conf.d/haproxy.yaml.erb b/templates/agent-conf.d/haproxy.yaml.erb index 0eb1fac0..1d6bef71 100644 --- a/templates/agent-conf.d/haproxy.yaml.erb +++ b/templates/agent-conf.d/haproxy.yaml.erb @@ -6,6 +6,6 @@ init_config: instances: - url: <%= @url %> - <% creds.each do |k,v| %> + <% @creds.each do |k,v| %> <%= k %>: <%= v %> <% end -%> From 5f19f8fc623dff7242dbb5b4fb81bc7633fec148 Mon Sep 17 00:00:00 2001 From: Jaime Fullaondo Date: Tue, 12 Apr 2016 19:28:20 -0400 Subject: [PATCH 48/49] [http_check] fixing spec test for older puppets. --- manifests/integrations/http_check.pp | 4 +++- .../datadog_agent_integrations_http_check_spec.rb | 12 ++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/manifests/integrations/http_check.pp b/manifests/integrations/http_check.pp index f2f6c6fe..38f59adc 100644 --- a/manifests/integrations/http_check.pp +++ b/manifests/integrations/http_check.pp @@ -90,7 +90,7 @@ ) inherits datadog_agent::params { include datadog_agent - if $instances == undef { + if !$instances and $url { $_instances = [{ 'url' => $url, 'username' => $username, @@ -105,6 +105,8 @@ 'tags' => $tags, 'contact' => $contact, }] + } elsif !$instances{ + $_instances = [] } else { $_instances = $instances } diff --git a/spec/classes/datadog_agent_integrations_http_check_spec.rb b/spec/classes/datadog_agent_integrations_http_check_spec.rb index 21057311..cdd43cd4 100644 --- a/spec/classes/datadog_agent_integrations_http_check_spec.rb +++ b/spec/classes/datadog_agent_integrations_http_check_spec.rb @@ -21,15 +21,15 @@ it { should contain_file(conf_file).that_notifies("Service[#{dd_service}]") } context 'with default parameters' do - it { should contain_file(conf_file).with_content(%r{url: }) } + it { should contain_file(conf_file).without_content(%r{url: }) } it { should contain_file(conf_file).without_content(%r{username: }) } it { should contain_file(conf_file).without_content(%r{password: }) } - it { should contain_file(conf_file).with_content(%r{timeout: 1}) } + it { should contain_file(conf_file).without_content(%r{timeout: 1}) } it { should contain_file(conf_file).without_content(%{threshold: }) } it { should contain_file(conf_file).without_content(%r{window: }) } it { should contain_file(conf_file).without_content(%r{include_content: true}) } - it { should contain_file(conf_file).with_content(%r{collect_response_time: true}) } - it { should contain_file(conf_file).with_content(%r{disable_ssl_validation: false}) } + it { should contain_file(conf_file).without_content(%r{collect_response_time: true}) } + it { should contain_file(conf_file).without_content(%r{disable_ssl_validation: false}) } it { should contain_file(conf_file).without_content(%r{headers: }) } it { should contain_file(conf_file).without_content(%r{tags: }) } end @@ -60,6 +60,7 @@ context 'with headers parameter array' do let(:params) {{ + url: 'http://foo.bar.baz:4096', headers: %w{ foo bar baz }, }} it { should contain_file(conf_file).with_content(/headers:\s+foo\s+bar\s+baz\s*?[^-]/m) } @@ -68,6 +69,7 @@ context 'with headers parameter empty values' do context 'mixed in with other headers' do let(:params) {{ + url: 'http://foo.bar.baz:4096', headers: [ 'foo', '', 'baz' ] }} @@ -94,6 +96,7 @@ context 'with tags parameter array' do let(:params) {{ + url: 'http://foo.bar.baz:4096', tags: %w{ foo bar baz }, }} it { should contain_file(conf_file).with_content(/tags:\s+- foo\s+- bar\s+- baz\s*?[^-]/m) } @@ -102,6 +105,7 @@ context 'with tags parameter empty values' do context 'mixed in with other tags' do let(:params) {{ + url: 'http://foo.bar.baz:4096', tags: [ 'foo', '', 'baz' ] }} From f5464fe13aa3d8fc22983b1432837df7fbc779d3 Mon Sep 17 00:00:00 2001 From: Jaime Fullaondo Date: Tue, 12 Apr 2016 21:11:27 -0400 Subject: [PATCH 49/49] [changelog] updating. --- CHANGELOG.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e32471a5..a85e2cdc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ Changes * [FEATURE] Added mesos master and slave manifests for individual management. See [#174][]. (Thanks [@flyinprogrammer][] and [@jangie][]). * [FEATURE] Added option to extract the hostname from puppet hostname strings with a regex capture group. See [#173][]. (Thanks [@LeoCavaille][]). * [FEATURE] Added support on multiple ports per host on Redis integration. See [#169][]. (Thanks [@fzwart][]). -* [FEATURE] Added support for disable_ssl_validation on Apache integration. See[#171. (Thanks [@BIAndrews][]). +* [FEATURE] Added support for `disable_ssl_validation` on Apache integration. See[#171. (Thanks [@BIAndrews][]). * [FEATURE] Added support for SSL, additional metrics and database connection in Mongo integration. See [#164][]. (Thanks [@bflad][]). * [FEATURE] Added support for multiple instance in HTTP check. See [#155][]. (Thanks [@bfla][]d]. * [FEATURE] Added support for multiple new datadog.conf directives. See [#79][]. (Thanks [@obowersa][]). @@ -18,12 +18,14 @@ Changes * [IMPROVEMENT] Moved GPG key to its own parameter. See [#158][]. (Thanks [@davidgibbons][]). -* [BUFIX] Updated docker to use more current docker_daemon. See [#174][]. (Thanks [@flyinprogrammer][] and [@jangie][]). +* [BUFIX] Updated docker to use more current `docker_daemon`. See [#174][]. (Thanks [@flyinprogrammer][] and [@jangie][]). * [DEPRECATE] Deprecated old docker manifest. See [#174][]. (Thanks [@flyinprogrammer][]). -* [DEPRECATE] Deprecated use_mount option in base manifest. See [#174][]. Thanks [@flyinprogrammer][]). +* [DEPRECATE] Deprecated `new_tag_names` in `docker_daemon` manifest. See [#174][]. (Thanks [@flyinprogrammer][]). +* [DEPRECATE] Deprecated `use_mount` option in base manifest. See [#174][]. (Thanks [@flyinprogrammer][]). * [CI] Improved spec and docs. See [#79][]. (Thanks [@obowersa][]). +* [CI] Added multiple tests for integration classes. See [#145][]. (Thanks [@kitchen][]). # 1.6.0 / 2016-01-20 @@ -132,6 +134,7 @@ Changes [#79]: https://github.com/DataDog/puppet-datadog-agent/issues/79 [#139]: https://github.com/DataDog/puppet-datadog-agent/issues/139 +[#145]: https://github.com/DataDog/puppet-datadog-agent/issues/145 [#149]: https://github.com/DataDog/puppet-datadog-agent/issues/149 [#150]: https://github.com/DataDog/puppet-datadog-agent/issues/150 [#154]: https://github.com/DataDog/puppet-datadog-agent/issues/154 @@ -150,12 +153,14 @@ Changes [@LeoCavaille]: https://github.com/LeoCavaille [@MartinDelta]: https://github.com/MartinDelta [@b2jrock]: https://github.com/b2jrock +[@bfla]: https://github.com/bfla [@bflad]: https://github.com/bflad [@davidgibbons]: https://github.com/davidgibbons [@flyinprogrammer]: https://github.com/flyinprogrammer [@fzwart]: https://github.com/fzwart [@grubernaut]: https://github.com/grubernaut [@jangie]: https://github.com/jangie +[@kitchen]: https://github.com/kitchen [@mcasper]: https://github.com/mcasper [@mrunkel-ut]: https://github.com/mrunkel-ut [@obowersa]: https://github.com/obowersa