diff --git a/.fixtures.yml b/.fixtures.yml index 5d7a8ec0..1b2dcbac 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -2,12 +2,17 @@ fixtures: repositories: stdlib: repo: "git://github.com/puppetlabs/puppetlabs-stdlib.git" - ref: "4.12.0" + ref: "4.24.0" concat: repo: "git://github.com/puppetlabs/puppetlabs-concat.git" - ref: "2.2.0" + ref: "4.1.1" + apt: + repo: "git://github.com/puppetlabs/puppetlabs-apt.git" + ref: "4.5.0" + puppetserver_gem: + repo: "git://github.com/puppetlabs/puppetlabs-puppetserver_gem.git" + ref: "1.0.0" ruby: "git://github.com/puppetlabs/puppetlabs-ruby.git" - remote_file: "git://github.com/lwf/puppet-remote_file.git" symlinks: custom_datadog: "#{source_dir}/spec/custom_fixtures/custom_datadog" datadog_agent: "#{source_dir}" diff --git a/.gitignore b/.gitignore index c9712915..6a70a383 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,6 @@ spec/fixtures .bundle vendor Gemfile.lock + +.rbenv-gemsets +.ruby-version diff --git a/.travis.yml b/.travis.yml index 64c6adad..c665db82 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,26 +4,13 @@ sudo: false bundler_args: --full-index cache: bundler rvm: - - 2.0.0 - - 2.1.1 + - 2.1.9 - 2.2.3 + - 2.3.6 + - 2.4.3 script: - bundle exec rake test env: - - PUPPET_VERSION="~> 2.7.0" - - PUPPET_VERSION="~> 3.2.0" - - PUPPET_VERSION="~> 3.3.0" - - PUPPET_VERSION="~> 3.4.0" - - PUPPET_VERSION="~> 3.5.0" STRICT_VARIABLES=yes - - PUPPET_VERSION="~> 3.6.0" STRICT_VARIABLES=yes - - PUPPET_VERSION="~> 3.7.0" STRICT_VARIABLES=yes - - PUPPET_VERSION="~> 3.7.5" STRICT_VARIABLES=yes - - PUPPET_VERSION="~> 3.8.1" STRICT_VARIABLES=yes - - PUPPET_VERSION="~> 4.0.0" STRICT_VARIABLES=yes - - PUPPET_VERSION="~> 4.1.0" STRICT_VARIABLES=yes - - PUPPET_VERSION="~> 4.2.0" STRICT_VARIABLES=yes - - PUPPET_VERSION="~> 4.2.1" STRICT_VARIABLES=yes - - PUPPET_VERSION="~> 4.5.3" STRICT_VARIABLES=yes - PUPPET_VERSION="~> 4.6.2" STRICT_VARIABLES=yes - PUPPET_VERSION="~> 4.7.1" STRICT_VARIABLES=yes - PUPPET_VERSION="~> 4.8.2" STRICT_VARIABLES=yes @@ -33,80 +20,3 @@ env: - PUPPET_VERSION="~> 5.1.0" STRICT_VARIABLES=yes - PUPPET_VERSION="~> 5.2.0" STRICT_VARIABLES=yes - PUPPET_VERSION="~> 5.3.3" STRICT_VARIABLES=yes -matrix: - exclude: - # Ruby 2.0.0 - - rvm: 2.0.0 - env: PUPPET_VERSION="~> 2.7.0" - - rvm: 2.0.0 - env: PUPPET_VERSION="~> 4.1.0" - - rvm: 2.0.0 - env: PUPPET_VERSION="~> 4.2.0" - - rvm: 2.0.0 - env: PUPPET_VERSION="~> 4.2.1" - - rvm: 2.0.0 - env: PUPPET_VERSION="~> 4.5.3" STRICT_VARIABLES=yes - - rvm: 2.0.0 - env: PUPPET_VERSION="~> 4.6.2" STRICT_VARIABLES=yes - - rvm: 2.0.0 - env: PUPPET_VERSION="~> 4.7.1" STRICT_VARIABLES=yes - - rvm: 2.0.0 - env: PUPPET_VERSION="~> 4.8.2" STRICT_VARIABLES=yes - - rvm: 2.0.0 - env: PUPPET_VERSION="~> 4.9.4" STRICT_VARIABLES=yes - - rvm: 2.0.0 - env: PUPPET_VERSION="~> 4.10.9" STRICT_VARIABLES=yes - - rvm: 2.0.0 - env: PUPPET_VERSION="~> 5.0.1" STRICT_VARIABLES=yes - - rvm: 2.0.0 - env: PUPPET_VERSION="~> 5.1.0" STRICT_VARIABLES=yes - - rvm: 2.0.0 - env: PUPPET_VERSION="~> 5.2.0" STRICT_VARIABLES=yes - - rvm: 2.0.0 - env: PUPPET_VERSION="~> 5.3.3" STRICT_VARIABLES=yes - - # Ruby 2.1.1 - - rvm: 2.1.1 - env: PUPPET_VERSION="~> 2.7.0" - - rvm: 2.1.1 - env: PUPPET_VERSION="~> 3.2.0" - - rvm: 2.1.1 - env: PUPPET_VERSION="~> 3.3.0" - - rvm: 2.1.1 - env: PUPPET_VERSION="~> 3.4.0" - - rvm: 2.1.1 - env: PUPPET_VERSION="~> 4.1.0" - - rvm: 2.1.1 - env: PUPPET_VERSION="~> 4.2.0" - - rvm: 2.1.1 - env: PUPPET_VERSION="~> 4.2.1" - - rvm: 2.1.1 - env: PUPPET_VERSION="~> 4.5.3" STRICT_VARIABLES=yes - - rvm: 2.1.1 - env: PUPPET_VERSION="~> 4.6.2" STRICT_VARIABLES=yes - - rvm: 2.1.1 - env: PUPPET_VERSION="~> 4.7.1" STRICT_VARIABLES=yes - - rvm: 2.1.1 - env: PUPPET_VERSION="~> 4.8.2" STRICT_VARIABLES=yes - - rvm: 2.1.1 - env: PUPPET_VERSION="~> 4.9.4" STRICT_VARIABLES=yes - - rvm: 2.1.1 - env: PUPPET_VERSION="~> 4.10.9" STRICT_VARIABLES=yes - - rvm: 2.1.1 - env: PUPPET_VERSION="~> 5.0.1" STRICT_VARIABLES=yes - - rvm: 2.1.1 - env: PUPPET_VERSION="~> 5.1.0" STRICT_VARIABLES=yes - - rvm: 2.1.1 - env: PUPPET_VERSION="~> 5.2.0" STRICT_VARIABLES=yes - - rvm: 2.1.1 - env: PUPPET_VERSION="~> 5.3.3" STRICT_VARIABLES=yes - - # Ruby 2.2.3 - - rvm: 2.2.3 - env: PUPPET_VERSION="~> 2.7.0" - - rvm: 2.2.3 - env: PUPPET_VERSION="~> 3.2.0" - - rvm: 2.2.3 - env: PUPPET_VERSION="~> 3.3.0" - - rvm: 2.2.3 - env: PUPPET_VERSION="~> 3.4.0" diff --git a/Gemfile b/Gemfile index 6f88ebb7..20674fbe 100644 --- a/Gemfile +++ b/Gemfile @@ -1,10 +1,7 @@ source "https://rubygems.org" group :test do - gem "syck" - gem "public_suffix", "~> 2.0.5" - gem "safe_yaml", "~> 1.0.4" - gem "hiera-eyaml", "~> 2.1.0" + gem "public_suffix", "~> 3.0.0" gem "listen", "~> 3.0.0" gem "puppet", ENV['PUPPET_VERSION'] || '~> 4.2.0' gem "puppet-lint" @@ -12,14 +9,15 @@ group :test do gem "puppetlabs_spec_helper" gem "jwt", "~> 1.5.6" gem "rake" - gem "rspec-puppet", '2.3.2' + gem "rspec-puppet", '2.6.9' + gem 'rspec-puppet-facts', '~> 1.7', :require => false end group :development do gem "beaker-rspec" - gem "beaker", '2.51.0' + gem "beaker", '3.31.0' gem "guard-rake" - gem "nokogiri", "~> 1.6.0" + gem "nokogiri", "~> 1.8.2" gem "puppet-blacksmith" gem "xmlrpc" if RUBY_VERSION >= '2.3' end diff --git a/README.md b/README.md index 5d3e032f..dbce586f 100644 --- a/README.md +++ b/README.md @@ -11,18 +11,57 @@ A module to: 1. install the [DataDog](http://www.datadoghq.com) agent 2. to send reports of puppet runs to the Datadog service [Datadog](http://www.datadoghq.com/). -Requirements ------------- +Releases +-------- -Puppet >=2.7.x and <=4.2.x (we may work with newer versions, but untested). For detailed informations on compatibility, check the [module page](https://forge.puppetlabs.com/datadog/datadog_agent) on the Puppet forge. +There are currently two actively maintained versions for the puppet module. To users on puppet >= 4.6.x, and possibly some older 4.x puppets, we recommend you use version 2.0+ of the module. + +For users running on older versions of puppet the legacy module, series 1.x, should support most use-cases. + +Hopefully a majority of users will be able to use the newer module as many of the puppet versions supported in the 1.x series of the module have been EOL'd for a while now. + +Some features might be back-ported if there's enough demand for it, but in general only maintenance will be performed on the 1.x series of the module. Future feature development will be performed on the newer puppet module. + + +Version 2.x +----------- -Installation ------------- +## Requirements + +Puppet >=4.6.x and <=5.3.x (we may work with newer versions, but untested). For detailed informations on compatibility, check the [module page](https://forge.puppetlabs.com/datadog/datadog_agent) on the Puppet forge. + +## Installation Install `datadog_agent` as a module in your Puppet master's module path. puppet module install datadog-datadog_agent +### Upgrade from the previous module version 1.x + +Most of the manifests should be backward compatible. However, there are important changes to the main manifest: + +- By default datadog agent 6.x will now be installed. + - You may still setup agent 5.x in your nodes by seting the `agent5_enable` boolean parameter to `True` +- Enhanced support for our APM tracing agent +- Enhanced support for our Process agent +- Enhanced support for additional agent6 options +- Increased granularity for apt/yum repo configuration +- New location for datadog puppet reporting configuration + + +Version 1.x +----------- + +## Requirements + +Puppet >=2.7.x and <=4.2.x (we may work with newer versions, but untested). For detailed informations on compatibility, check the [module page](https://forge.puppetlabs.com/datadog/datadog_agent) on the Puppet forge. + +## Installation + +Install `datadog_agent` as a module in your Puppet master's module path. + + puppet module install datadog-datadog_agent --version 1.12.1 + ### Upgrade from previous git manual install 0.x (unreleased) You can keep using the `datadog` module but it becomes legacy with the release of `datadog_agent` 1.0.0. Upgrade to get new features, and use the puppet forge system which is way easier for maintenance. @@ -31,37 +70,48 @@ You can keep using the `datadog` module but it becomes legacy with the release o * Install the new module from the puppet forge `puppet module install datadog-datadog_agent` * Update your manifests with the new module class, basically replace `datadog` by `datadog_agent` -#### For instance to deploy the elasticsearch integration - include 'datadog_agent::integrations::elasticsearch' Usage ----- -Once the `datadog_agent` module is installed on your master, there's a tiny bit of configuration +The following instructions should hold true for both puppet module versions (1.x, 2.x). + +Note: remember 2.x will install agent6 by default, whereas 1.x defaults to agent6. + +Once the `datadog_agent` module is installed on your `puppetserver`/`puppetmaster`, there's a tiny bit of configuration that needs to be done. 1. Update the default class parameters with your [API key](https://app.datadoghq.com/account/settings#api) 2. Specify the module on any nodes you wish to install the DataDog Agent. - + ``` include datadog_agent + ``` Or assign this module using the Puppet style Parameterized class: + ``` class { 'datadog_agent': api_key => "yourkey", } + ``` - On your Puppet master, enable reporting: + On your `puppetserver`, enable reporting: + ``` class { 'datadog_agent': api_key => "yourkey", puppet_run_reports => true, } + ``` __To support reporting, your Puppet master needs to have the [dogapi](https://github.com/DataDog/dogapi-rb) gem installed, to do that either run the puppet agent on your master with this configuration or install it manually with `gem`.__ - _Please note if on Puppet Enterprise or POSS (ie. >=3.7.0) there is a soft dependency for reporting on the `puppetserver_gem` module. Install with `puppet module install puppetlabs-puppetserver_gem` - installing manually with `gem` will *not* work._ - _Also note that we have made the gem provider configurable, so you can set it to `puppetserver_gem` (already set by default) if on PE/POSS (>=3.7.0) or `gem` if on older versions of puppet_ + __Please note, you may have two restart your `puppetserver` service for the freshly installed gem to be picked up.__ + _Please note, on version 2.x of the module `puppetserver_gem` is defined as a module dependency, it should be installed automatically when the module is installed._ + _Please note, on version 1.x and if on Puppet Enterprise or POSS (ie. >=3.7.0) there is a soft dependency for reporting on the `puppetserver_gem` module. Install with `puppet module install puppetlabs-puppetserver_gem` - installing manually with `gem` will *not* work._ + _Please note, on version 1.x and older puppets you may install `dogapi-rb` with `gem` as the system-level ruby is used_ + _Also note, on version 1.x of the puppet module, the gem provider is configurable, so you can set it to `puppetserver_gem` (already set by default) if on PE/POSS (>=3.7.0) or `gem` if on older versions of puppet_ + 3. Include any other integrations you want the agent to use, e.g. @@ -69,6 +119,9 @@ that needs to be done. Reporting --------- +Other than ensuring that dogapi-rb is available on your system as we +explained earlier, a few additional steps should be conducted. + To enable reporting of changes to the Datadog timeline, enable the report processor on your Puppet master, and enable reporting for your clients. The clients will send a run report after each check-in back to the master. @@ -84,7 +137,11 @@ class { "datadog-agent": } ``` -In your Puppet master `/etc/puppet/puppet.conf`, add these configuration options: +On puppet >=4.x the location for your configuration file will be: +`/etc/puppetlabs/puppet/puppet.conf` +On older puppets the location should be: `/etc/puppet/puppet.conf` + +Add these configuration options in the pertinent location: ```ini [main] @@ -104,7 +161,8 @@ pluginsync=true report=true ``` -And on all of your Puppet client nodes add: +And on all of your Puppet client nodes add the following in the +same location:: ```ini [agent] @@ -122,14 +180,15 @@ Class Datadog_reports is already defined in Puppet::Reports Make sure `reports=datadog_reports` is defined in **[master]**, not **[main]**. + Step-by-step ============ -This is the minimal set of modifications to get started. These files assume puppet 2.7.x or higher. +This is the minimal set of modifications to get started. These files assume puppet 4.5.x or higher. -/etc/puppet/puppet.conf +/etc/puppetlabs/puppet/puppet.conf ----------------------- - +```ini [master] report = true reports = datadog_reports @@ -138,10 +197,14 @@ This is the minimal set of modifications to get started. These files assume pupp [agent] report = true pluginsync = true +``` + +_Note: This may be file `/etc/puppet/puppet/puppet.conf` on older puppets_ -/etc/puppet/manifests/nodes.pp +/etc/puppetlabs/code/environments/production/manifests/10_nodes.pp ------------------------------ +``` node "default" { class { "datadog_agent": api_key => "INSERT YOU API KEY HERE", @@ -153,16 +216,15 @@ This is the minimal set of modifications to get started. These files assume pupp puppet_run_reports => true } } +``` -/etc/puppet/manifests/site.pp ------------------------------ +_Note: This may be file `/etc/puppet/manifests/nodes.pp` on older puppets_ - import "nodes.pp" Run Puppet Agent ---------------- - sudo /etc/init.d/puppetmaster restart + sudo systemctl /etc/init.d/puppetmaster restart sudo puppet agent --onetime --no-daemonize --no-splay --verbose You should see something like: @@ -196,7 +258,8 @@ Search for "Puppet" in the Stream and you should see something like this: Masterless puppet ================= -This is a specific setup, you can use https://gist.github.com/LeoCavaille/cd412c7a9ff5caec462f to set it up. +This is a specific setup, you can use https://gist.github.com/LeoCavaille/cd412c7a9ff5caec462f to set it up. This applies to older puppets and is +untested on >=4.x puppet versions. Client Settings =============== @@ -211,6 +274,27 @@ The datadog agent configuration file will be recreated from the template every p Here are some of the other variables that be set in the datadog_agent class to control settings in the agent: + +#### 2.x + +| variable name | description | +| ------------- | ----------- | +| collect_ec2_tags | Set this to yes to have an instance's custom EC2 tags used as agent tags | +| collect_instance_metadata | Set this to yes to have an instance's EC2 metadata used as agent tags | +| dd_url | datadog intake server URL. You are unlikely to need to change this | +| host | overrides the node's hostname | +| local_tags | an array of key:value strings that will be set as tags for the node | +| non_local_traffic | set this to allow other nodes to relay their traffic through this one | +| agent5_enable | boolean to install agent5 and override agent6 default | +| apm_enabled | boolean to enable the APM agent; defaults to true | +| process_enabled | boolean to enable the process agent; defaults to true | +| agent6_extra_options | hash to provide additional configuration options to agent6. | + +_NOTE: `agent6_extra_options` may be used to provide a fine grain control of additional agent6 config options. A deep merge is performed that may override options provided in the `datadog_agent` class parameters_ + + +#### 1.x + | variable name | description | | ------------- | ----------- | | collect_ec2_tags | Set this to yes to have an instance's custom EC2 tags used as agent tags | @@ -219,6 +303,7 @@ Here are some of the other variables that be set in the datadog_agent class to c | host | overrides the node's hostname | | local_tags | an array of key:value strings that will be set as tags for the node | | non_local_traffic | set this to allow other nodes to relay their traffic through this one | +| agent6_enable | boolean to install agent6 and override agent5 default | ### Proxy Settings diff --git a/functions/tag6.pp b/functions/tag6.pp new file mode 100644 index 00000000..8efb0272 --- /dev/null +++ b/functions/tag6.pp @@ -0,0 +1,24 @@ +# For compatibility with puppet 4.6 return type is left +# out of the function signature, but `tag6` should return +# an Array + +function datadog_agent::tag6( + Variant[Array, String] $tag_names, + Variant[String, Boolean] $lookup_fact = false, +) { + if is_array($tag_names) { + $tags = $tag_names.reduce([]) |$_tags , $tag| { + concat($_tags, datadog_agent::tag6($tag, lookup_fact)) + } + } elsif str2bool($lookup_fact) { + $value = getvar($tag_names) + + if is_array($value){ + $tags = prefix($value, "${tag_name}:") + } + } else { + $tags = [$tag_name] + } + + $tags +} diff --git a/lib/facter/agent_repo.rb b/lib/facter/agent_repo.rb new file mode 100644 index 00000000..32a07450 --- /dev/null +++ b/lib/facter/agent_repo.rb @@ -0,0 +1,31 @@ +Facter.add('apt_agent6_beta_repo') do + setcode do + File.exist? '/etc/apt/sources.list.d/datadog-beta.list' + end +end + +Facter.add('apt_agent6_repo') do + setcode do + File.exist? '/etc/apt/sources.list.d/datadog6.list' + end +end + +Facter.add('apt_agent5_legacy_repo') do + setcode do + File.exist? '/etc/apt/sources.list.d/datadog-beta.list' + end +end + +Facter.add('yum_agent6_repo') do + setcode do + yumpath = '/etc/yum.repos.d/datadog6.repo' + File.exist? yumpath or !File.zero? yumpath + end +end + +Facter.add('yum_datadog_legacy_repo') do + setcode do + yumpath = '/etc/yum.repos.d/datadog.repo' + File.exist? yumpath or !File.zero? yumpath + end +end diff --git a/lib/facter/beta_repo.rb b/lib/facter/beta_repo.rb deleted file mode 100644 index 44b3bf6a..00000000 --- a/lib/facter/beta_repo.rb +++ /dev/null @@ -1,5 +0,0 @@ -Facter.add('apt_agent6_beta_repo') do - setcode do - File.exist? '/etc/apt/sources.list.d/datadog-beta.list' - end -end diff --git a/manifests/init.pp b/manifests/init.pp index 9219da02..ab568f16 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -159,13 +159,13 @@ # String. Default: empty # $apm_enabled # Boolean to enable or disable the trace agent -# Boolean. Default: false +# Boolean. Default: true # $apm_env # String defining the environment for the APM traces # String. Default: empty -# $process_agent_enabled -# Boolean to enable the process/container agent -# Boolean. Default: false +# $process_enabled +# String to enable the process/container agent +# Boolean. Default: true # # Actions: # @@ -197,7 +197,6 @@ $hiera_tags = false, $facts_to_tags = [], $puppet_run_reports = false, - $puppet_gem_provider = 'puppetserver_gem', $puppetmaster_user = $settings::user, $non_local_traffic = false, $dogstreams = [], @@ -251,7 +250,7 @@ $sd_template_dir = '', $sd_jmx_enable = false, $consul_token = '', - $agent6_enable = $datadog_agent::params::agent6_enable, + $agent5_enable = $datadog_agent::params::agent5_enable, $conf_dir = $datadog_agent::params::conf_dir, $conf6_dir = $datadog_agent::params::conf6_dir, $conf_dir_purge = $datadog_agent::params::conf_dir_purge, @@ -260,9 +259,13 @@ $dd_user = $datadog_agent::params::dd_user, $dd_group = $datadog_agent::params::dd_group, $dd_groups = $datadog_agent::params::dd_groups, - $apm_enabled = false, + $apm_enabled = $datadog_agent::params::apm_default_enabled, $apm_env = '', - $process_agent_enabled = false, + $process_enabled = $datadog_agent::params::process_default_enabled, + Hash[String, Data] $agent6_extra_options = {}, + $agent5_repo_uri = $datadog_agent::params::agent5_default_repo, + $agent6_repo_uri = $datadog_agent::params::agent6_default_repo, + $apt_release = $datadog_agent::params::apt_default_release, ) inherits datadog_agent::params { # Allow ports to be passed as integers or strings. @@ -284,7 +287,6 @@ validate_array($dogstreams) validate_array($facts_to_tags) validate_bool($puppet_run_reports) - validate_string($puppet_gem_provider) validate_string($puppetmaster_user) validate_bool($non_local_traffic) validate_bool($log_to_syslog) @@ -336,9 +338,12 @@ validate_bool($sd_jmx_enable) validate_string($consul_token) validate_bool($apm_enabled) - validate_bool($agent6_enable) + validate_bool($agent5_enable) validate_string($apm_env) - validate_bool($process_agent_enabled) + validate_bool($process_enabled) + validate_string($agent5_repo_uri) + validate_string($agent6_repo_uri) + validate_string($apt_release) if $hiera_tags { $local_tags = hiera_array('datadog_agent::tags', []) @@ -352,11 +357,6 @@ $local_integrations = $integrations } - datadog_agent::tag{$local_tags: } - datadog_agent::tag{$facts_to_tags: - lookup_fact => true, - } - include datadog_agent::params case upcase($log_level) { 'CRITICAL': { $_loglevel = 'CRITICAL' } @@ -371,20 +371,38 @@ case $::operatingsystem { 'Ubuntu','Debian' : { - if !$agent6_enable { - include datadog_agent::ubuntu + if $agent5_enable { + class { 'datadog_agent::ubuntu::agent5': + service_ensure => $service_ensure, + service_enable => $service_enable, + location => $agent5_repo_uri, + release => $apt_release, + skip_apt_key_trusting => $skip_apt_key_trusting, + } } else { - include datadog_agent::ubuntu::agent6 + class { 'datadog_agent::ubuntu::agent6': + service_ensure => $service_ensure, + service_enable => $service_enable, + location => $agent6_repo_uri, + release => $apt_release, + skip_apt_key_trusting => $skip_apt_key_trusting, + } } } 'RedHat','CentOS','Fedora','Amazon','Scientific' : { - if !$agent6_enable { - class { 'datadog_agent::redhat': - manage_repo => $manage_repo, + if $agent5_enable { + class { 'datadog_agent::redhat::agent5': + baseurl => $agent5_repo_uri, + manage_repo => $manage_repo, + service_ensure => $service_ensure, + service_enable => $service_enable, } } else { class { 'datadog_agent::redhat::agent6': - manage_repo => $manage_repo, + baseurl => $agent6_repo_uri, + manage_repo => $manage_repo, + service_ensure => $service_ensure, + service_enable => $service_enable, } } } @@ -407,7 +425,7 @@ require => Package[$datadog_agent::params::package_name], } - if !$agent6_enable { + if $agent5_enable { file { '/etc/dd-agent': ensure => directory, owner => $dd_user, @@ -446,6 +464,11 @@ order => '02', } + datadog_agent::tag5{$local_tags: } + datadog_agent::tag5{$facts_to_tags: + lookup_fact => true, + } + concat::fragment{ 'datadog footer': target => '/etc/dd-agent/datadog.conf', content => template('datadog_agent/datadog_footer.conf.erb'), @@ -458,20 +481,26 @@ content => template($extra_template), order => '06', } - $apm_footer_order = '07' - } else { - $apm_footer_order = '06' } if ($apm_enabled == true) and ($apm_env != '') { concat::fragment{ 'datadog apm footer': target => '/etc/dd-agent/datadog.conf', content => template('datadog_agent/datadog_apm_footer.conf.erb'), - order => $apm_footer_order, + order => '07', } } } else { + # lint:ignore:quoted_booleans + $process_enabled_str = $process_enabled ? { true => 'true' , default => 'false' } + # lint:endignore + $base_extra_config = { + 'apm_config' => { 'apm_enabled' => $apm_enabled }, + 'process_config' => { 'process_enabled' => $process_enabled_str }, + } + $extra_config = deep_merge($base_extra_config, $agent6_extra_options) + file { $conf6_dir: ensure => directory, purge => $conf_dir_purge, @@ -482,7 +511,10 @@ notify => Service[$datadog_agent::params::service_name] } - $agent_config = { + $_local_tags = datadog_agent::tag6($local_tags, false) + $_facts_tags = datadog_agent::tag6($facts_to_tags, true) + + $_agent_config = { 'api_key' => $api_key, 'dd_url' => $dd_url, 'cmd_port' => 5001, @@ -493,8 +525,11 @@ 'dogstatsd_non_local_traffic' => $non_local_traffic, 'log_file' => $agent6_log_file, 'log_level' => $log_level, + 'tags' => union($_local_tags, $_facts_tags), } + $agent_config = deep_merge($_agent_config, $extra_config) + file { '/etc/datadog-agent/datadog.yaml': owner => 'dd-agent', group => 'dd-agent', @@ -509,9 +544,8 @@ if $puppet_run_reports { class { 'datadog_agent::reports': api_key => $api_key, - puppet_gem_provider => $puppet_gem_provider, - puppetmaster_user => $puppetmaster_user, dogapi_version => $datadog_agent::params::dogapi_version, + puppetmaster_user => $puppetmaster_user, hostname_extraction_regex => $hostname_extraction_regex, } } diff --git a/manifests/integration.pp b/manifests/integration.pp index 02a6b0b4..3880825b 100644 --- a/manifests/integration.pp +++ b/manifests/integration.pp @@ -12,7 +12,7 @@ } validate_string($integration) - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/${integration}.yaml" } else { $dst = "${datadog_agent::conf_dir}/${integration}.yaml" diff --git a/manifests/integrations/apache.pp b/manifests/integrations/apache.pp index e306e185..98c8285e 100644 --- a/manifests/integrations/apache.pp +++ b/manifests/integrations/apache.pp @@ -39,7 +39,7 @@ validate_array($tags) validate_bool($disable_ssl_validation) - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/apache.yaml" } else { $dst = "${datadog_agent::conf_dir}/apache.yaml" diff --git a/manifests/integrations/cacti.pp b/manifests/integrations/cacti.pp index 34fdc198..032ab03b 100644 --- a/manifests/integrations/cacti.pp +++ b/manifests/integrations/cacti.pp @@ -20,7 +20,7 @@ ) inherits datadog_agent::params { include datadog_agent - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/cacti.yaml" } else { $dst = "${datadog_agent::conf_dir}/cacti.yaml" diff --git a/manifests/integrations/cassandra.pp b/manifests/integrations/cassandra.pp index b1833c2d..c8f45049 100644 --- a/manifests/integrations/cassandra.pp +++ b/manifests/integrations/cassandra.pp @@ -35,7 +35,7 @@ require ::datadog_agent validate_hash($tags) - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/cassandra.yaml" } else { $dst = "${datadog_agent::conf_dir}/cassandra.yaml" diff --git a/manifests/integrations/ceph.pp b/manifests/integrations/ceph.pp index f4c602d2..f50655ea 100644 --- a/manifests/integrations/ceph.pp +++ b/manifests/integrations/ceph.pp @@ -25,7 +25,7 @@ content => "# This file is required for dd ceph \ndd-agent ALL=(ALL) NOPASSWD:/usr/bin/ceph\n" } - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/ceph.yaml" } else { $dst = "${datadog_agent::conf_dir}/ceph.yaml" diff --git a/manifests/integrations/consul.pp b/manifests/integrations/consul.pp index 69032023..355db29b 100644 --- a/manifests/integrations/consul.pp +++ b/manifests/integrations/consul.pp @@ -39,7 +39,7 @@ validate_bool($new_leader_checks) validate_array($service_whitelist) - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/consul.yaml" } else { $dst = "${datadog_agent::conf_dir}/consul.yaml" diff --git a/manifests/integrations/directory.pp b/manifests/integrations/directory.pp index a4e14853..547e473a 100644 --- a/manifests/integrations/directory.pp +++ b/manifests/integrations/directory.pp @@ -93,7 +93,7 @@ $_instances = $instances } - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/directory.yaml" } else { $dst = "${datadog_agent::conf_dir}/directory.yaml" diff --git a/manifests/integrations/disk.pp b/manifests/integrations/disk.pp index a5701a4d..3195e530 100644 --- a/manifests/integrations/disk.pp +++ b/manifests/integrations/disk.pp @@ -47,7 +47,7 @@ validate_re($all_partitions, '^(no|yes)$', "all_partitions should be either 'yes' or 'no'") } - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/disk.yaml" } else { $dst = "${datadog_agent::conf_dir}/disk.yaml" diff --git a/manifests/integrations/dns_check.pp b/manifests/integrations/dns_check.pp index 6dd2ddf1..cf9be754 100644 --- a/manifests/integrations/dns_check.pp +++ b/manifests/integrations/dns_check.pp @@ -37,7 +37,7 @@ validate_array($checks) - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/dns_check.yaml" } else { $dst = "${datadog_agent::conf_dir}/dns_check.yaml" diff --git a/manifests/integrations/docker_daemon.pp b/manifests/integrations/docker_daemon.pp index c6eb2203..da38abc6 100644 --- a/manifests/integrations/docker_daemon.pp +++ b/manifests/integrations/docker_daemon.pp @@ -64,7 +64,7 @@ notify => Service[$datadog_agent::params::service_name] } - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $legacy_conf = "${datadog_agent::conf6_dir}/docker_daemon.yaml" } else { $legacy_conf = "${datadog_agent::conf_dir}/docker.yaml" @@ -74,7 +74,7 @@ ensure => 'absent' } - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/docker.yaml" } else { $dst = "${datadog_agent::conf_dir}/docker_daemon.yaml" diff --git a/manifests/integrations/elasticsearch.pp b/manifests/integrations/elasticsearch.pp index eae8a27e..d47eb385 100644 --- a/manifests/integrations/elasticsearch.pp +++ b/manifests/integrations/elasticsearch.pp @@ -69,7 +69,7 @@ $_instances = $instances } - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/elastic.yaml" } else { $dst = "${datadog_agent::conf_dir}/elastic.yaml" diff --git a/manifests/integrations/fluentd.pp b/manifests/integrations/fluentd.pp index 172fefb6..37e7ebfd 100644 --- a/manifests/integrations/fluentd.pp +++ b/manifests/integrations/fluentd.pp @@ -25,7 +25,7 @@ validate_array($plugin_ids) - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/fluentd.yaml" } else { $dst = "${datadog_agent::conf_dir}/fluentd.yaml" diff --git a/manifests/integrations/generic.pp b/manifests/integrations/generic.pp index 1b113356..aea56bb0 100644 --- a/manifests/integrations/generic.pp +++ b/manifests/integrations/generic.pp @@ -25,7 +25,7 @@ validate_string($integration_name) validate_string($integration_contents) - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/${integration_name}.yaml" } else { $dst = "${datadog_agent::conf_dir}/${integration_name}.yaml" diff --git a/manifests/integrations/haproxy.pp b/manifests/integrations/haproxy.pp index e7d16e21..350cf3fc 100644 --- a/manifests/integrations/haproxy.pp +++ b/manifests/integrations/haproxy.pp @@ -36,7 +36,7 @@ $_instances = $instances } - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/haproxy.yaml" } else { $dst = "${datadog_agent::conf_dir}/haproxy.yaml" diff --git a/manifests/integrations/http_check.pp b/manifests/integrations/http_check.pp index 9ec664fb..91a5b573 100644 --- a/manifests/integrations/http_check.pp +++ b/manifests/integrations/http_check.pp @@ -201,7 +201,7 @@ $_instances = $instances } - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/http_check.yaml" } else { $dst = "${datadog_agent::conf_dir}/http_check.yaml" diff --git a/manifests/integrations/jenkins.pp b/manifests/integrations/jenkins.pp index a7ef1446..8913db8c 100644 --- a/manifests/integrations/jenkins.pp +++ b/manifests/integrations/jenkins.pp @@ -18,7 +18,7 @@ ) inherits datadog_agent::params { include datadog_agent - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/jenkins.yaml" } else { $dst = "${datadog_agent::conf_dir}/jenkins.yaml" diff --git a/manifests/integrations/jmx.pp b/manifests/integrations/jmx.pp index 1f59847a..88a3b888 100644 --- a/manifests/integrations/jmx.pp +++ b/manifests/integrations/jmx.pp @@ -67,7 +67,7 @@ ) inherits datadog_agent::params { include datadog_agent - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/jmx.yaml" } else { $dst = "${datadog_agent::conf_dir}/jmx.yaml" diff --git a/manifests/integrations/kafka.pp b/manifests/integrations/kafka.pp index 5f7c1877..b76bf000 100644 --- a/manifests/integrations/kafka.pp +++ b/manifests/integrations/kafka.pp @@ -35,7 +35,7 @@ require ::datadog_agent validate_hash($tags) - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/kafka.yaml" } else { $dst = "${datadog_agent::conf_dir}/kafka.yaml" diff --git a/manifests/integrations/kong.pp b/manifests/integrations/kong.pp index 0f7e425e..06f6880c 100644 --- a/manifests/integrations/kong.pp +++ b/manifests/integrations/kong.pp @@ -34,7 +34,7 @@ ) inherits datadog_agent::params { include datadog_agent - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/kong.yaml" } else { $dst = "${datadog_agent::conf_dir}/kong.yaml" diff --git a/manifests/integrations/kubernetes.pp b/manifests/integrations/kubernetes.pp index 2edd1f6e..aed36f5e 100644 --- a/manifests/integrations/kubernetes.pp +++ b/manifests/integrations/kubernetes.pp @@ -32,7 +32,7 @@ ) inherits datadog_agent::params { include datadog_agent - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/kubernetes.yaml" } else { $dst = "${datadog_agent::conf_dir}/kubernetes.yaml" diff --git a/manifests/integrations/kubernetes_state.pp b/manifests/integrations/kubernetes_state.pp index cfe9d36b..a16c037e 100644 --- a/manifests/integrations/kubernetes_state.pp +++ b/manifests/integrations/kubernetes_state.pp @@ -24,7 +24,7 @@ ) inherits datadog_agent::params { include datadog_agent - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/kubernetes_state.yaml" } else { $dst = "${datadog_agent::conf_dir}/kubernetes_state.yaml" diff --git a/manifests/integrations/linux_proc_extras.pp b/manifests/integrations/linux_proc_extras.pp index 7755f3be..75390ad6 100644 --- a/manifests/integrations/linux_proc_extras.pp +++ b/manifests/integrations/linux_proc_extras.pp @@ -18,7 +18,7 @@ ) inherits datadog_agent::params { include datadog_agent - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/linux_proc_extras.yaml" } else { $dst = "${datadog_agent::conf_dir}/linux_proc_extras.yaml" diff --git a/manifests/integrations/marathon.pp b/manifests/integrations/marathon.pp index b8c56204..92c7f4ce 100644 --- a/manifests/integrations/marathon.pp +++ b/manifests/integrations/marathon.pp @@ -18,7 +18,7 @@ ) inherits datadog_agent::params { include datadog_agent - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/marathon.yaml" } else { $dst = "${datadog_agent::conf_dir}/marathon.yaml" diff --git a/manifests/integrations/memcache.pp b/manifests/integrations/memcache.pp index b764e01f..8a28c3aa 100644 --- a/manifests/integrations/memcache.pp +++ b/manifests/integrations/memcache.pp @@ -58,7 +58,7 @@ $_instances = $instances } - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/mcache.yaml" } else { $dst = "${datadog_agent::conf_dir}/mcache.yaml" diff --git a/manifests/integrations/mesos_master.pp b/manifests/integrations/mesos_master.pp index ccdbe2c5..3b0a7004 100644 --- a/manifests/integrations/mesos_master.pp +++ b/manifests/integrations/mesos_master.pp @@ -18,7 +18,7 @@ ) inherits datadog_agent::params { include datadog_agent - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/mesos.yaml" } else { $dst = "${datadog_agent::conf_dir}/mesos.yaml" @@ -28,7 +28,7 @@ ensure => 'absent' } - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst_master = "${datadog_agent::conf6_dir}/mesos_master.yaml" } else { $dst_master = "${datadog_agent::conf_dir}/mesos_master.yaml" diff --git a/manifests/integrations/mesos_slave.pp b/manifests/integrations/mesos_slave.pp index 6b94f047..0f9d2ba3 100644 --- a/manifests/integrations/mesos_slave.pp +++ b/manifests/integrations/mesos_slave.pp @@ -17,7 +17,7 @@ $url = 'http://localhost:5051' ) inherits datadog_agent::params { - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/mesos_slave.yaml" } else { $dst = "${datadog_agent::conf_dir}/mesos_slave.yaml" diff --git a/manifests/integrations/mongo.pp b/manifests/integrations/mongo.pp index f9e7d878..ea140076 100644 --- a/manifests/integrations/mongo.pp +++ b/manifests/integrations/mongo.pp @@ -63,7 +63,7 @@ validate_array($servers) - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/mongo.yaml" } else { $dst = "${datadog_agent::conf_dir}/mongo.yaml" diff --git a/manifests/integrations/mysql.pp b/manifests/integrations/mysql.pp index 643c2f3f..02f48edf 100644 --- a/manifests/integrations/mysql.pp +++ b/manifests/integrations/mysql.pp @@ -95,7 +95,7 @@ $_instances = $instances } - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/mysql.yaml" } else { $dst = "${datadog_agent::conf_dir}/mysql.yaml" diff --git a/manifests/integrations/nginx.pp b/manifests/integrations/nginx.pp index a2d7f31c..12a4c4e8 100644 --- a/manifests/integrations/nginx.pp +++ b/manifests/integrations/nginx.pp @@ -29,7 +29,7 @@ validate_array($instances) - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/nginx.yaml" } else { $dst = "${datadog_agent::conf_dir}/nginx.yaml" diff --git a/manifests/integrations/ntp.pp b/manifests/integrations/ntp.pp index 9e74868d..35d3ebb3 100644 --- a/manifests/integrations/ntp.pp +++ b/manifests/integrations/ntp.pp @@ -32,7 +32,7 @@ ) inherits datadog_agent::params { include datadog_agent - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/ntp.yaml" } else { $dst = "${datadog_agent::conf_dir}/ntp.yaml" diff --git a/manifests/integrations/pgbouncer.pp b/manifests/integrations/pgbouncer.pp index 89936462..8ef1a59c 100644 --- a/manifests/integrations/pgbouncer.pp +++ b/manifests/integrations/pgbouncer.pp @@ -56,7 +56,7 @@ validate_array($tags) validate_array($pgbouncers) - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/pgbouncer.yaml" } else { $dst = "${datadog_agent::conf_dir}/pgbouncer.yaml" diff --git a/manifests/integrations/php_fpm.pp b/manifests/integrations/php_fpm.pp index 706a34e6..b3aab76c 100644 --- a/manifests/integrations/php_fpm.pp +++ b/manifests/integrations/php_fpm.pp @@ -40,7 +40,7 @@ $_instances = $instances } - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/php_fpm.yaml" } else { $dst = "${datadog_agent::conf_dir}/php_fpm.yaml" diff --git a/manifests/integrations/postfix.pp b/manifests/integrations/postfix.pp index 9cd931fb..a7efe739 100644 --- a/manifests/integrations/postfix.pp +++ b/manifests/integrations/postfix.pp @@ -52,7 +52,7 @@ $_instances = $instances } - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/postfix.yaml" } else { $dst = "${datadog_agent::conf_dir}/postfix.yaml" diff --git a/manifests/integrations/postgres.pp b/manifests/integrations/postgres.pp index c0d50617..4c8809eb 100644 --- a/manifests/integrations/postgres.pp +++ b/manifests/integrations/postgres.pp @@ -69,7 +69,7 @@ validate_array($tables) validate_bool($use_psycopg2) - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/postgres.yaml" } else { $dst = "${datadog_agent::conf_dir}/postgres.yaml" diff --git a/manifests/integrations/process.pp b/manifests/integrations/process.pp index 326c474d..79f797da 100644 --- a/manifests/integrations/process.pp +++ b/manifests/integrations/process.pp @@ -55,7 +55,7 @@ $local_processes = $processes } - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/process.yaml" } else { $dst = "${datadog_agent::conf_dir}/process.yaml" diff --git a/manifests/integrations/rabbitmq.pp b/manifests/integrations/rabbitmq.pp index 90bdc4db..60a6aa10 100644 --- a/manifests/integrations/rabbitmq.pp +++ b/manifests/integrations/rabbitmq.pp @@ -70,7 +70,7 @@ validate_array($vhosts) include datadog_agent - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/rabbitmq.yaml" } else { $dst = "${datadog_agent::conf_dir}/rabbitmq.yaml" diff --git a/manifests/integrations/redis.pp b/manifests/integrations/redis.pp index 3d676d8e..1c5fbeda 100644 --- a/manifests/integrations/redis.pp +++ b/manifests/integrations/redis.pp @@ -54,7 +54,7 @@ validate_array($_ports) - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/redisdb.yaml" } else { $dst = "${datadog_agent::conf_dir}/redisdb.yaml" diff --git a/manifests/integrations/riak.pp b/manifests/integrations/riak.pp index f6dd39f4..87b78664 100644 --- a/manifests/integrations/riak.pp +++ b/manifests/integrations/riak.pp @@ -27,7 +27,7 @@ validate_string($url) validate_array($tags) - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/riak.yaml" } else { $dst = "${datadog_agent::conf_dir}/riak.yaml" diff --git a/manifests/integrations/solr.pp b/manifests/integrations/solr.pp index da5fdc61..7f537d76 100644 --- a/manifests/integrations/solr.pp +++ b/manifests/integrations/solr.pp @@ -38,7 +38,7 @@ ) inherits datadog_agent::params { include datadog_agent - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/solr.yaml" } else { $dst = "${datadog_agent::conf_dir}/solr.yaml" diff --git a/manifests/integrations/ssh.pp b/manifests/integrations/ssh.pp index ae4600f7..fcbdf209 100644 --- a/manifests/integrations/ssh.pp +++ b/manifests/integrations/ssh.pp @@ -37,7 +37,7 @@ ) inherits datadog_agent::params { include ::datadog_agent - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/ssh.yaml" } else { $dst = "${datadog_agent::conf_dir}/ssh.yaml" diff --git a/manifests/integrations/supervisord.pp b/manifests/integrations/supervisord.pp index 182ea36a..2cebee18 100644 --- a/manifests/integrations/supervisord.pp +++ b/manifests/integrations/supervisord.pp @@ -46,7 +46,7 @@ ) inherits datadog_agent::params { include datadog_agent - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/supervisord.yaml" } else { $dst = "${datadog_agent::conf_dir}/supervisord.yaml" diff --git a/manifests/integrations/tcp_check.pp b/manifests/integrations/tcp_check.pp index b935e6e7..eeda1755 100644 --- a/manifests/integrations/tcp_check.pp +++ b/manifests/integrations/tcp_check.pp @@ -117,7 +117,7 @@ $_instances = $instances } - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/tcp_check.yaml" } else { $dst = "${datadog_agent::conf_dir}/tcp_check.yaml" diff --git a/manifests/integrations/tomcat.pp b/manifests/integrations/tomcat.pp index 23542b5c..48ae4916 100644 --- a/manifests/integrations/tomcat.pp +++ b/manifests/integrations/tomcat.pp @@ -39,7 +39,7 @@ include datadog_agent - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/tomcat.yaml" } else { $dst = "${datadog_agent::conf_dir}/tomcat.yaml" diff --git a/manifests/integrations/twemproxy.pp b/manifests/integrations/twemproxy.pp index e124b39e..0f8e2f84 100644 --- a/manifests/integrations/twemproxy.pp +++ b/manifests/integrations/twemproxy.pp @@ -41,7 +41,7 @@ $_instances = $instances } - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/twemproxy.yaml" } else { $dst = "${datadog_agent::conf_dir}/twemproxy.yaml" diff --git a/manifests/integrations/varnish.pp b/manifests/integrations/varnish.pp index 9e59feb3..5d6d8111 100644 --- a/manifests/integrations/varnish.pp +++ b/manifests/integrations/varnish.pp @@ -28,7 +28,7 @@ ) inherits datadog_agent::params { include datadog_agent - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/varnish.yaml" } else { $dst = "${datadog_agent::conf_dir}/varnish.yaml" diff --git a/manifests/integrations/zk.pp b/manifests/integrations/zk.pp index 6f79709f..b9454147 100644 --- a/manifests/integrations/zk.pp +++ b/manifests/integrations/zk.pp @@ -34,7 +34,7 @@ validate_array($servers) - if $::datadog_agent::agent6_enable { + if !$::datadog_agent::agent5_enable { $dst = "${datadog_agent::conf6_dir}/zk.yaml" } else { $dst = "${datadog_agent::conf_dir}/zk.yaml" diff --git a/manifests/params.pp b/manifests/params.pp index 20f2085f..658d1a71 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -15,23 +15,30 @@ # Sample Usage: # class datadog_agent::params { - $agent6_enable = false - $conf_dir = '/etc/dd-agent/conf.d' - $conf6_dir = '/etc/datadog-agent/conf.d' - $dd_user = 'dd-agent' - $dd_group = 'root' - $dd_groups = undef - $package_name = 'datadog-agent' - $service_name = 'datadog-agent' - $dogapi_version = 'installed' - $conf_dir_purge = false + $agent5_enable = false + $conf_dir = '/etc/dd-agent/conf.d' + $conf6_dir = '/etc/datadog-agent/conf.d' + $dd_user = 'dd-agent' + $dd_group = 'root' + $dd_groups = undef + $package_name = 'datadog-agent' + $service_name = 'datadog-agent' + $dogapi_version = 'installed' + $conf_dir_purge = false + $apt_default_release = 'stable' + $apm_default_enabled = true + $process_default_enabled = true case $::operatingsystem { 'Ubuntu','Debian' : { $rubydev_package = 'ruby-dev' + $agent5_default_repo = 'https://apt.datadoghq.com' + $agent6_default_repo = 'https://apt.datadoghq.com' } 'RedHat','CentOS','Fedora','Amazon','Scientific' : { $rubydev_package = 'ruby-devel' + $agent5_default_repo = "https://yum.datadoghq.com/rpm/${::architecture}/" + $agent6_default_repo = "https://yum.datadoghq.com/rpm/6/${::architecture}/" } default: { fail("Class[datadog_agent]: Unsupported operatingsystem: ${::operatingsystem}") } } diff --git a/manifests/redhat.pp b/manifests/redhat/agent5.pp similarity index 61% rename from manifests/redhat.pp rename to manifests/redhat/agent5.pp index cc85498d..c3463d35 100644 --- a/manifests/redhat.pp +++ b/manifests/redhat/agent5.pp @@ -14,11 +14,13 @@ # Sample Usage: # # -class datadog_agent::redhat( - $baseurl = "https://yum.datadoghq.com/rpm/${::architecture}/", +class datadog_agent::redhat::agent5( + $baseurl = $datadog_agent::params::agent5_default_repo, $gpgkey = 'https://yum.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public', $manage_repo = true, - $agent_version = 'latest' + $agent_version = 'latest', + $service_ensure = 'running', + $service_enable = true, ) inherits datadog_agent::params { validate_bool($manage_repo) @@ -27,10 +29,10 @@ validate_string($baseurl) - remote_file { 'DATADOG_RPM_KEY.public': + file { 'DATADOG_RPM_KEY.public': owner => root, group => root, - mode => '600', + mode => '0600', path => $public_key_local, source => $gpgkey } @@ -39,10 +41,33 @@ command => "/bin/rpm --import ${public_key_local}", onlyif => "/usr/bin/gpg --quiet --with-fingerprint -n ${public_key_local} | grep \'A4C0 B90D 7443 CF6E 4E8A A341 F106 8E14 E094 22B3\'", unless => '/bin/rpm -q gpg-pubkey-e09422b3', - require => Remote_file['DATADOG_RPM_KEY.public'], + require => File['DATADOG_RPM_KEY.public'], + } + + if ($facts['yum_agent6_repo'] or $facts['yum_datadog_legacy_repo']) and $agent_version == 'latest' { + exec { 'datadog_yum_remove_agent6': + command => '/usr/bin/yum -y -q remove datadog-agent', + } + } else { + exec { 'datadog_yum_remove_agent6': + command => ':', # NOOP builtin + noop => true, + refreshonly => true, + provider => 'shell', + } } yumrepo {'datadog': + ensure => absent, + notify => Exec['datadog_yum_remove_agent6'], + } + + yumrepo {'datadog6': + ensure => absent, + notify => Exec['datadog_yum_remove_agent6'], + } + + yumrepo {'datadog5': enabled => 1, gpgcheck => 1, gpgkey => 'https://yum.datadoghq.com/DATADOG_RPM_KEY.public', @@ -51,7 +76,7 @@ require => Exec['install-gpg-key'], } - Package { require => Yumrepo['datadog']} + Package { require => Yumrepo['datadog5']} } package { 'datadog-agent-base': @@ -64,8 +89,8 @@ } service { $datadog_agent::params::service_name: - ensure => $::datadog_agent::service_ensure, - enable => $::datadog_agent::service_enable, + ensure => $service_ensure, + enable => $service_enable, hasstatus => false, pattern => 'dd-agent', provider => 'redhat', diff --git a/manifests/redhat/agent6.pp b/manifests/redhat/agent6.pp index 1f3cfe05..595e4bda 100644 --- a/manifests/redhat/agent6.pp +++ b/manifests/redhat/agent6.pp @@ -4,10 +4,12 @@ # class datadog_agent::redhat::agent6( - $baseurl = "https://yum.datadoghq.com/beta/${::architecture}/", + $baseurl = $datadog_agent::params::agent6_default_repo, $gpgkey = 'https://yum.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public', $manage_repo = true, - $agent_version = 'latest' + $agent_version = 'latest', + $service_ensure = 'running', + $service_enable = true, ) inherits datadog_agent::params { validate_bool($manage_repo) @@ -16,10 +18,10 @@ validate_string($baseurl) - remote_file { 'DATADOG_RPM_KEY.public': + file { 'DATADOG_RPM_KEY.public': owner => root, group => root, - mode => '600', + mode => '0600', path => $public_key_local, source => $gpgkey } @@ -28,10 +30,18 @@ command => "/bin/rpm --import ${public_key_local}", onlyif => "/usr/bin/gpg --quiet --with-fingerprint -n ${public_key_local} | grep \'A4C0 B90D 7443 CF6E 4E8A A341 F106 8E14 E094 22B3\'", unless => '/bin/rpm -q gpg-pubkey-e09422b3', - require => Remote_file['DATADOG_RPM_KEY.public'], + require => File['DATADOG_RPM_KEY.public'], } yumrepo {'datadog': + ensure => absent, + } + + yumrepo {'datadog5': + ensure => absent, + } + + yumrepo {'datadog6': enabled => 1, gpgcheck => 1, gpgkey => 'https://yum.datadoghq.com/DATADOG_RPM_KEY.public', @@ -40,7 +50,7 @@ require => Exec['install-gpg-key'], } - Package { require => Yumrepo['datadog']} + Package { require => Yumrepo['datadog6']} } package { 'datadog-agent-base': @@ -53,8 +63,8 @@ } service { $datadog_agent::params::service_name: - ensure => $::datadog_agent::service_ensure, - enable => $::datadog_agent::service_enable, + ensure => $service_ensure, + enable => $service_enable, hasstatus => false, pattern => 'dd-agent', provider => 'redhat', diff --git a/manifests/reports.pp b/manifests/reports.pp index 60887530..d1947de0 100644 --- a/manifests/reports.pp +++ b/manifests/reports.pp @@ -15,7 +15,6 @@ # class datadog_agent::reports( $api_key, - $puppet_gem_provider, $puppetmaster_user, $dogapi_version, $hostname_extraction_regex = nil @@ -49,8 +48,8 @@ require => File['/etc/datadog-agent'], } - package{'dogapi': + package{ 'dogapi': ensure => $dogapi_version, - provider => $puppet_gem_provider, + provider => 'puppetserver_gem', } } diff --git a/manifests/tag.pp b/manifests/tag5.pp similarity index 95% rename from manifests/tag.pp rename to manifests/tag5.pp index a3a21c2f..ace2a07c 100644 --- a/manifests/tag.pp +++ b/manifests/tag5.pp @@ -1,5 +1,5 @@ # Allow custom tags via a define -define datadog_agent::tag( +define datadog_agent::tag5( $tag_name = $name, $lookup_fact = false, ){ diff --git a/manifests/ubuntu.pp b/manifests/ubuntu.pp deleted file mode 100644 index 7465ae98..00000000 --- a/manifests/ubuntu.pp +++ /dev/null @@ -1,100 +0,0 @@ -# Class: datadog_agent::ubuntu -# -# This class contains the DataDog agent installation mechanism for Ubuntu -# -# Parameters: -# -# Actions: -# -# Requires: -# -# Sample Usage: -# -# - -class datadog_agent::ubuntu( - $apt_key = 'A2923DFF56EDA6E76E55E492D3A80E30382E94DE', - $agent_version = 'latest', - $other_keys = ['935F5A436A5A6E8788F0765B226AE980C7A7DA52'], - $location = 'https://apt.datadoghq.com', - $release = 'stable', - $repos = 'main', -) inherits datadog_agent::params{ - - ensure_packages(['apt-transport-https']) - validate_array($other_keys) - - if !$::datadog_agent::skip_apt_key_trusting { - $mykeys = concat($other_keys, [$apt_key]) - - ::datadog_agent::ubuntu::install_key { $mykeys: - before => File['/etc/apt/sources.list.d/datadog.list'], - } - } - - # This is a hack - I'm not happy about it, but we should rarely - # hit this code path - # - # Also, using $::apt_agent6_beta_repo to access fact instead of - # $facts hash - for compatibility with puppet3.x default behavior - # - # lint:ignore:only_variable_string - if str2bool("${::apt_agent6_beta_repo}") and $agent_version == 'latest' { - # lint:endignore - exec { 'datadog_apt-get_remove_agent6': - command => '/usr/bin/apt-get remove -y -q datadog-agent', - } - } else { - exec { 'datadog_apt-get_remove_agent6': - command => ':', # NOOP builtin - noop => true, - refreshonly => true, - provider => 'shell', - } - } - - # lint:ignore:only_variable_string - if str2bool("${::apt_agent6_beta_repo}") { - # lint:endignore - file { '/etc/apt/sources.list.d/datadog-beta.list': - ensure => absent, - } - } - - file { '/etc/apt/sources.list.d/datadog.list': - ensure => file, - owner => 'root', - group => 'root', - content => template('datadog_agent/datadog.list.erb'), - notify => [Exec['datadog_apt-get_remove_agent6'], - Exec['datadog_apt-get_update']], - require => Package['apt-transport-https'], - } - - exec { 'datadog_apt-get_update': - command => '/usr/bin/apt-get update', - refreshonly => true, - tries => 2, # https://bugs.launchpad.net/launchpad/+bug/1430011 won't get fixed until 16.04 xenial - try_sleep => 30, - require => File['/etc/apt/sources.list.d/datadog.list'], - } - - package { 'datadog-agent-base': - ensure => absent, - before => Package[$datadog_agent::params::package_name], - } - - package { $datadog_agent::params::package_name: - ensure => $agent_version, - require => [File['/etc/apt/sources.list.d/datadog.list'], - Exec['datadog_apt-get_update']], - } - - service { $datadog_agent::params::service_name: - ensure => $::datadog_agent::service_ensure, - enable => $::datadog_agent::service_enable, - hasstatus => false, - pattern => 'dd-agent', - require => Package[$datadog_agent::params::package_name], - } -} diff --git a/manifests/ubuntu/agent5.pp b/manifests/ubuntu/agent5.pp new file mode 100644 index 00000000..67f4c99f --- /dev/null +++ b/manifests/ubuntu/agent5.pp @@ -0,0 +1,93 @@ +# Class: datadog_agent::ubuntu +# +# This class contains the DataDog agent installation mechanism for Ubuntu +# +# Parameters: +# +# Actions: +# +# Requires: +# +# Sample Usage: +# +# + +class datadog_agent::ubuntu::agent5( + $apt_key = 'A2923DFF56EDA6E76E55E492D3A80E30382E94DE', + $agent_version = 'latest', + $other_keys = ['935F5A436A5A6E8788F0765B226AE980C7A7DA52'], + $location = $datadog_agent::params::agent5_default_repo, + $release = $datadog_agent::params::apt_default_release, + $repos = 'main', + $skip_apt_key_trusting = false, + $service_ensure = 'running', + $service_enable = true, +) inherits datadog_agent::params{ + + ensure_packages(['apt-transport-https']) + validate_array($other_keys) + + if !$skip_apt_key_trusting { + $mykeys = concat($other_keys, [$apt_key]) + + ::datadog_agent::ubuntu::install_key { $mykeys: + before => Apt::Source['datadog'], + } + } + + # This is a hack - I'm not happy about it, but we should rarely + # hit this code path. We can't use 'Package' because we later have + # to ensure dastadog-agent is present. + + if ($facts['apt_agent6_beta_repo'] or $facts['apt_agent6_repo']) and $agent_version == 'latest' { + exec { 'datadog_apt-get_remove_agent6': + command => '/usr/bin/apt-get remove -y -q datadog-agent', + } + } else { + exec { 'datadog_apt-get_remove_agent6': + command => ':', # NOOP builtin + noop => true, + refreshonly => true, + provider => 'shell', + } + } + + if $facts['apt_agent6_beta_repo'] { + apt::source { 'datadog-beta': + ensure => absent, + } + } + if $facts['apt_agent6_repo'] { + apt::source { 'datadog6': + ensure => absent, + } + } + + apt::source { 'datadog': + comment => 'Datadog Agent Repository', + location => $location, + release => $release, + repos => $repos, + require => Package['apt-transport-https'], + notify => [Exec['datadog_apt-get_remove_agent6'],Exec['apt_update']], + } + + package { 'datadog-agent-base': + ensure => absent, + before => Package[$datadog_agent::params::package_name], + } + + package { $datadog_agent::params::package_name: + ensure => $agent_version, + require => [Apt::Source['datadog'], + Exec['apt_update']], + } + + service { $datadog_agent::params::service_name: + ensure => $service_ensure, + enable => $service_enable, + hasstatus => false, + pattern => 'dd-agent', + require => Package[$datadog_agent::params::package_name], + } +} diff --git a/manifests/ubuntu/agent6.pp b/manifests/ubuntu/agent6.pp index d44d31c3..8157ba1f 100644 --- a/manifests/ubuntu/agent6.pp +++ b/manifests/ubuntu/agent6.pp @@ -7,41 +7,36 @@ $apt_key = 'A2923DFF56EDA6E76E55E492D3A80E30382E94DE', $agent_version = 'latest', $other_keys = ['935F5A436A5A6E8788F0765B226AE980C7A7DA52'], - $location = 'https://apt.datadoghq.com', - $release = 'beta', - $repos = 'main', + $location = $datadog_agent::params::agent6_default_repo, + $release = $datadog_agent::params::apt_default_release, + $repos = '6', + $skip_apt_key_trusting = false, + $service_ensure = 'running', + $service_enable = true, ) inherits datadog_agent::params { ensure_packages(['apt-transport-https']) validate_array($other_keys) - if !$::datadog_agent::skip_apt_key_trusting { + if !$skip_apt_key_trusting { $mykeys = concat($other_keys, [$apt_key]) ::datadog_agent::ubuntu::install_key { $mykeys: - before => File['/etc/apt/sources.list.d/datadog-beta.list'], + before => Apt::Source['datadog6'], } - } - file { '/etc/apt/sources.list.d/datadog.list': + apt::source { 'datadog': ensure => absent, } - file { '/etc/apt/sources.list.d/datadog-beta.list': - owner => 'root', - group => 'root', - content => template('datadog_agent/datadog.list.erb'), - notify => Exec['datadog_apt-get_update'], - require => Package['apt-transport-https'], - } - - exec { 'datadog_apt-get_update': - command => '/usr/bin/apt-get update', - refreshonly => true, - tries => 2, # https://bugs.launchpad.net/launchpad/+bug/1430011 won't get fixed until 16.04 xenial - try_sleep => 30, - require => File['/etc/apt/sources.list.d/datadog.list'], + apt::source { 'datadog6': + comment => 'Datadog Agent 6 Repository', + location => $location, + release => $release, + repos => $repos, + require => Package['apt-transport-https'], + notify => Exec['apt_update'], } package { 'datadog-agent-base': @@ -51,13 +46,13 @@ package { $datadog_agent::params::package_name: ensure => $agent_version, - require => [File['/etc/apt/sources.list.d/datadog-beta.list'], - Exec['datadog_apt-get_update']], + require => [Apt::Source['datadog6'], + Exec['apt_update']], } service { $datadog_agent::params::service_name: - ensure => $::datadog_agent::service_ensure, - enable => $::datadog_agent::service_enable, + ensure => $service_ensure, + enable => $service_enable, hasstatus => false, pattern => 'dd-agent', require => Package['datadog-agent'], diff --git a/manifests/ubuntu/install_key.pp b/manifests/ubuntu/install_key.pp index 902a72bf..69ac71cf 100644 --- a/manifests/ubuntu/install_key.pp +++ b/manifests/ubuntu/install_key.pp @@ -13,10 +13,8 @@ # # define datadog_agent::ubuntu::install_key() { - $shortkey = regsubst($name, '.*(.{8})$', '\1') - - exec { "key ${name}": - command => "/usr/bin/apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys ${name}", - unless => "/usr/bin/apt-key list | grep ${shortkey} | grep expires", + apt::key { $name: + id => $name, + server => 'hkp://keyserver.ubuntu.com:80', } } diff --git a/metadata.json b/metadata.json index 0788347a..124503bb 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "datadog-datadog_agent", - "version": "1.12.1", + "version": "2.0.0-beta", "author": "James Turnbull () and Rob Terhaar () for Datadog Inc.", "summary": "Install the Datadog monitoring agent and report Puppet runs to Datadog", "license": "Apache-2.0", @@ -31,35 +31,39 @@ }, { "operatingsystem": "Ubuntu", - "operatingsystemrelease": ["10.04", "12.04", "14.04", "16.04", "17.04", "17.10"] + "operatingsystemrelease": ["14.04", "16.04", "17.04", "17.10"] } ], "requirements": [ { "name": "pe", - "version_requirement": "3.2.x" + "version_requirement": "2016.4.x" }, { "name": "puppet", - "version_requirement": ">=2.7.20 <6.0.0" + "version_requirement": ">=4.6.0 <6.0.0" } ], "dependencies": [ { "name": "puppetlabs/stdlib", - "version_requirement": ">=4.6.0 <5.0.0" + "version_requirement": ">=4.24.0 <5.0.0" }, { "name": "puppetlabs/ruby", - "version_requirement": ">=0.2.0 <2.0.0" + "version_requirement": ">=1.0.0 <2.0.0" }, { "name": "puppetlabs/concat", - "version_requirement": ">=2.2.0 <5.0.0" + "version_requirement": ">=4.0.0 <5.0.0" }, { - "name": "lwf/remote_file", - "version_requirement": ">=1.1.3 <2.0.0" + "name": "puppetlabs/apt", + "version_requirement": ">=4.0.0 <5.0.0" + }, + { + "name": "puppetlabs/puppetserver_gem", + "version_requirement": ">=1.0.0 <2.0.0" } ] } diff --git a/spec/classes/datadog_agent_integrations_apache_spec.rb b/spec/classes/datadog_agent_integrations_apache_spec.rb index 1b1bc882..42c86629 100644 --- a/spec/classes/datadog_agent_integrations_apache_spec.rb +++ b/spec/classes/datadog_agent_integrations_apache_spec.rb @@ -2,13 +2,10 @@ describe 'datadog_agent::integrations::apache' do context 'supported agents - v5 and v6' do - agents = { '5' => false, '6' => true } + agents = { '5' => true, '6' => false } agents.each do |_, enabled| - let(:pre_condition) { "class {'::datadog_agent': agent6_enable => #{enabled}}" } - let(:facts) {{ - operatingsystem: 'Ubuntu', - }} - if !enabled + let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" } + if enabled let(:conf_dir) { '/etc/dd-agent/conf.d' } else let(:conf_dir) { '/etc/datadog-agent/conf.d' } @@ -17,7 +14,7 @@ let(:dd_group) { 'root' } let(:dd_package) { 'datadog-agent' } let(:dd_service) { 'datadog-agent' } - let(:agent6_enable) { enabled } + let(:agent5_enable) { enabled } let(:conf_file) { "#{conf_dir}/apache.yaml" } it { should compile.with_all_deps } diff --git a/spec/classes/datadog_agent_integrations_cacti_spec.rb b/spec/classes/datadog_agent_integrations_cacti_spec.rb index d0456b7a..11c15fd7 100644 --- a/spec/classes/datadog_agent_integrations_cacti_spec.rb +++ b/spec/classes/datadog_agent_integrations_cacti_spec.rb @@ -2,13 +2,13 @@ describe 'datadog_agent::integrations::cacti' do context 'supported agents - v5 and v6' do - agents = { '5' => false, '6' => true } + agents = { '5' => true, '6' => false } agents.each do |agent, enabled| - let(:pre_condition) { "class {'::datadog_agent': agent6_enable => #{enabled}}" } + let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" } let(:facts) {{ operatingsystem: 'Ubuntu', }} - if !enabled + if enabled let(:conf_dir) { '/etc/dd-agent/conf.d' } else let(:conf_dir) { '/etc/datadog-agent/conf.d' } @@ -17,7 +17,7 @@ let(:dd_group) { 'root' } let(:dd_package) { 'datadog-agent' } let(:dd_service) { 'datadog-agent' } - let(:agent6_enable) { enabled } + let(:agent5_enable) { enabled } let(:conf_file) { "#{conf_dir}/cacti.yaml" } context 'with default parameters' do diff --git a/spec/classes/datadog_agent_integrations_cassandra_spec.rb b/spec/classes/datadog_agent_integrations_cassandra_spec.rb index 58f03df5..949bb1e3 100644 --- a/spec/classes/datadog_agent_integrations_cassandra_spec.rb +++ b/spec/classes/datadog_agent_integrations_cassandra_spec.rb @@ -2,13 +2,13 @@ describe 'datadog_agent::integrations::cassandra' do context 'supported agents - v5 and v6' do - agents = { '5' => false, '6' => true } + agents = { '5' => true, '6' => false } agents.each do |_, enabled| - let(:pre_condition) { "class {'::datadog_agent': agent6_enable => #{enabled}}" } + let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" } let(:facts) {{ operatingsystem: 'Ubuntu', }} - if !enabled + if enabled let(:conf_dir) { '/etc/dd-agent/conf.d' } else let(:conf_dir) { '/etc/datadog-agent/conf.d' } diff --git a/spec/classes/datadog_agent_integrations_ceph_spec.rb b/spec/classes/datadog_agent_integrations_ceph_spec.rb index 04b8dbc5..079194c6 100644 --- a/spec/classes/datadog_agent_integrations_ceph_spec.rb +++ b/spec/classes/datadog_agent_integrations_ceph_spec.rb @@ -2,13 +2,13 @@ describe 'datadog_agent::integrations::ceph' do context 'supported agents - v5 and v6' do - agents = { '5' => false, '6' => true } + agents = { '5' => true, '6' => false } agents.each do |_, enabled| - let(:pre_condition) { "class {'::datadog_agent': agent6_enable => #{enabled}}" } + let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" } let(:facts) {{ operatingsystem: 'Ubuntu', }} - if !enabled + if enabled let(:conf_dir) { '/etc/dd-agent/conf.d' } else let(:conf_dir) { '/etc/datadog-agent/conf.d' } diff --git a/spec/classes/datadog_agent_integrations_consul_spec.rb b/spec/classes/datadog_agent_integrations_consul_spec.rb index 32747e97..716135a7 100644 --- a/spec/classes/datadog_agent_integrations_consul_spec.rb +++ b/spec/classes/datadog_agent_integrations_consul_spec.rb @@ -2,13 +2,13 @@ describe 'datadog_agent::integrations::consul' do context 'supported agents - v5 and v6' do - agents = { '5' => false, '6' => true } + agents = { '5' => true, '6' => false } agents.each do |_, enabled| - let(:pre_condition) { "class {'::datadog_agent': agent6_enable => #{enabled}}" } + let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" } let(:facts) {{ operatingsystem: 'Ubuntu', }} - if !enabled + if enabled let(:conf_dir) { '/etc/dd-agent/conf.d' } else let(:conf_dir) { '/etc/datadog-agent/conf.d' } diff --git a/spec/classes/datadog_agent_integrations_directory_spec.rb b/spec/classes/datadog_agent_integrations_directory_spec.rb index 26d50397..b411a3f9 100644 --- a/spec/classes/datadog_agent_integrations_directory_spec.rb +++ b/spec/classes/datadog_agent_integrations_directory_spec.rb @@ -2,13 +2,13 @@ describe 'datadog_agent::integrations::directory' do context 'supported agents - v5 and v6' do - agents = { '5' => false, '6' => true } + agents = { '5' => true, '6' => false } agents.each do |_, enabled| - let(:pre_condition) { "class {'::datadog_agent': agent6_enable => #{enabled}}" } + let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" } let(:facts) {{ operatingsystem: 'Ubuntu', }} - if !enabled + if enabled let(:conf_dir) { '/etc/dd-agent/conf.d' } else let(:conf_dir) { '/etc/datadog-agent/conf.d' } diff --git a/spec/classes/datadog_agent_integrations_disk_spec.rb b/spec/classes/datadog_agent_integrations_disk_spec.rb index 9c3ceeaf..43c2a216 100644 --- a/spec/classes/datadog_agent_integrations_disk_spec.rb +++ b/spec/classes/datadog_agent_integrations_disk_spec.rb @@ -2,13 +2,13 @@ describe 'datadog_agent::integrations::disk' do context 'supported agents - v5 and v6' do - agents = { '5' => false, '6' => true } + agents = { '5' => true, '6' => false } agents.each do |_, enabled| - let(:pre_condition) { "class {'::datadog_agent': agent6_enable => #{enabled}}" } + let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" } let(:facts) {{ operatingsystem: 'Ubuntu', }} - if !enabled + if enabled let(:conf_dir) { '/etc/dd-agent/conf.d' } else let(:conf_dir) { '/etc/datadog-agent/conf.d' } diff --git a/spec/classes/datadog_agent_integrations_dns_check_spec.rb b/spec/classes/datadog_agent_integrations_dns_check_spec.rb index e4ab08e1..d6e93534 100644 --- a/spec/classes/datadog_agent_integrations_dns_check_spec.rb +++ b/spec/classes/datadog_agent_integrations_dns_check_spec.rb @@ -2,13 +2,13 @@ describe 'datadog_agent::integrations::dns_check' do context 'supported agents - v5 and v6' do - agents = { '5' => false, '6' => true } + agents = { '5' => true, '6' => false } agents.each do |_, enabled| - let(:pre_condition) { "class {'::datadog_agent': agent6_enable => #{enabled}}" } + let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" } let(:facts) {{ operatingsystem: 'Ubuntu', }} - if !enabled + if enabled let(:conf_dir) { '/etc/dd-agent/conf.d' } else let(:conf_dir) { '/etc/datadog-agent/conf.d' } diff --git a/spec/classes/datadog_agent_integrations_docker_daemon_spec.rb b/spec/classes/datadog_agent_integrations_docker_daemon_spec.rb index 06e0aca0..80285d87 100644 --- a/spec/classes/datadog_agent_integrations_docker_daemon_spec.rb +++ b/spec/classes/datadog_agent_integrations_docker_daemon_spec.rb @@ -2,13 +2,13 @@ describe 'datadog_agent::integrations::docker_daemon' do context 'supported agents - v5 and v6' do - agents = { '5' => false, '6' => true } + agents = { '5' => true, '6' => false } agents.each do |_, enabled| - let(:pre_condition) { "class {'::datadog_agent': agent6_enable => #{enabled}}" } + let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" } let(:facts) {{ operatingsystem: 'Ubuntu', }} - if !enabled + if enabled let(:conf_dir) { '/etc/dd-agent/conf.d' } else let(:conf_dir) { '/etc/datadog-agent/conf.d' } @@ -17,7 +17,7 @@ let(:dd_group) { 'root' } let(:dd_package) { 'datadog-agent' } let(:dd_service) { 'datadog-agent' } - if !enabled + if enabled let(:conf_file) { "#{conf_dir}/docker_daemon.yaml" } else let(:conf_file) { "#{conf_dir}/docker.yaml" } diff --git a/spec/classes/datadog_agent_integrations_elasticsearch_spec.rb b/spec/classes/datadog_agent_integrations_elasticsearch_spec.rb index b573e260..e39ca5d1 100644 --- a/spec/classes/datadog_agent_integrations_elasticsearch_spec.rb +++ b/spec/classes/datadog_agent_integrations_elasticsearch_spec.rb @@ -2,13 +2,13 @@ describe 'datadog_agent::integrations::elasticsearch' do context 'supported agents - v5 and v6' do - agents = { '5' => false, '6' => true } + agents = { '5' => true, '6' => false } agents.each do |_, enabled| - let(:pre_condition) { "class {'::datadog_agent': agent6_enable => #{enabled}}" } + let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" } let(:facts) {{ operatingsystem: 'Ubuntu', }} - if !enabled + if enabled let(:conf_dir) { '/etc/dd-agent/conf.d' } else let(:conf_dir) { '/etc/datadog-agent/conf.d' } diff --git a/spec/classes/datadog_agent_integrations_fluentd_spec.rb b/spec/classes/datadog_agent_integrations_fluentd_spec.rb index 894e0b19..d790c9a8 100644 --- a/spec/classes/datadog_agent_integrations_fluentd_spec.rb +++ b/spec/classes/datadog_agent_integrations_fluentd_spec.rb @@ -2,13 +2,13 @@ describe 'datadog_agent::integrations::fluentd' do context 'supported agents - v5 and v6' do - agents = { '5' => false, '6' => true } + agents = { '5' => true, '6' => false } agents.each do |_, enabled| - let(:pre_condition) { "class {'::datadog_agent': agent6_enable => #{enabled}}" } + let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" } let(:facts) {{ operatingsystem: 'Ubuntu', }} - if !enabled + if enabled let(:conf_dir) { '/etc/dd-agent/conf.d' } else let(:conf_dir) { '/etc/datadog-agent/conf.d' } diff --git a/spec/classes/datadog_agent_integrations_haproxy_spec.rb b/spec/classes/datadog_agent_integrations_haproxy_spec.rb index 4a9ea4ac..d61bbcd4 100644 --- a/spec/classes/datadog_agent_integrations_haproxy_spec.rb +++ b/spec/classes/datadog_agent_integrations_haproxy_spec.rb @@ -2,14 +2,14 @@ describe 'datadog_agent::integrations::haproxy' do context 'supported agents - v5 and v6' do - agents = { '5' => false, '6' => true } + agents = { '5' => true, '6' => false } agents.each do |_, enabled| - let(:pre_condition) { "class {'::datadog_agent': agent6_enable => #{enabled}}" } + let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" } let(:facts) {{ operatingsystem: 'Ubuntu', ipaddress: '1.2.3.4', }} - if !enabled + if enabled let(:conf_dir) { '/etc/dd-agent/conf.d' } else let(:conf_dir) { '/etc/datadog-agent/conf.d' } diff --git a/spec/classes/datadog_agent_integrations_http_check_spec.rb b/spec/classes/datadog_agent_integrations_http_check_spec.rb index af7dc37d..9689e1df 100644 --- a/spec/classes/datadog_agent_integrations_http_check_spec.rb +++ b/spec/classes/datadog_agent_integrations_http_check_spec.rb @@ -2,13 +2,13 @@ describe 'datadog_agent::integrations::http_check' do context 'supported agents - v5 and v6' do - agents = { '5' => false, '6' => true } + agents = { '5' => true, '6' => false } agents.each do |_, enabled| - let(:pre_condition) { "class {'::datadog_agent': agent6_enable => #{enabled}}" } + let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" } let(:facts) {{ operatingsystem: 'Ubuntu', }} - if !enabled + if enabled let(:conf_dir) { '/etc/dd-agent/conf.d' } else let(:conf_dir) { '/etc/datadog-agent/conf.d' } diff --git a/spec/classes/datadog_agent_integrations_jenkins_spec.rb b/spec/classes/datadog_agent_integrations_jenkins_spec.rb index 49de7570..2f1342fe 100644 --- a/spec/classes/datadog_agent_integrations_jenkins_spec.rb +++ b/spec/classes/datadog_agent_integrations_jenkins_spec.rb @@ -2,13 +2,13 @@ describe 'datadog_agent::integrations::jenkins' do context 'supported agents - v5 and v6' do - agents = { '5' => false, '6' => true } + agents = { '5' => true, '6' => false } agents.each do |_, enabled| - let(:pre_condition) { "class {'::datadog_agent': agent6_enable => #{enabled}}" } + let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" } let(:facts) {{ operatingsystem: 'Ubuntu', }} - if !enabled + if enabled let(:conf_dir) { '/etc/dd-agent/conf.d' } else let(:conf_dir) { '/etc/datadog-agent/conf.d' } diff --git a/spec/classes/datadog_agent_integrations_jmx_spec.rb b/spec/classes/datadog_agent_integrations_jmx_spec.rb index 4f4e81ef..423cf7a0 100644 --- a/spec/classes/datadog_agent_integrations_jmx_spec.rb +++ b/spec/classes/datadog_agent_integrations_jmx_spec.rb @@ -2,13 +2,13 @@ describe 'datadog_agent::integrations::jmx' do context 'supported agents - v5 and v6' do - agents = { '5' => false, '6' => true } + agents = { '5' => true, '6' => false } agents.each do |_, enabled| - let(:pre_condition) { "class {'::datadog_agent': agent6_enable => #{enabled}}" } + let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" } let(:facts) {{ operatingsystem: 'Ubuntu', }} - if !enabled + if enabled let(:conf_dir) { '/etc/dd-agent/conf.d' } else let(:conf_dir) { '/etc/datadog-agent/conf.d' } diff --git a/spec/classes/datadog_agent_integrations_kong_spec.rb b/spec/classes/datadog_agent_integrations_kong_spec.rb index 415952d7..49914449 100644 --- a/spec/classes/datadog_agent_integrations_kong_spec.rb +++ b/spec/classes/datadog_agent_integrations_kong_spec.rb @@ -2,13 +2,13 @@ describe 'datadog_agent::integrations::kong' do context 'supported agents - v5 and v6' do - agents = { '5' => false, '6' => true } + agents = { '5' => true, '6' => false } agents.each do |_, enabled| - let(:pre_condition) { "class {'::datadog_agent': agent6_enable => #{enabled}}" } + let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" } let(:facts) {{ operatingsystem: 'Ubuntu', }} - if !enabled + if enabled let(:conf_dir) { '/etc/dd-agent/conf.d' } else let(:conf_dir) { '/etc/datadog-agent/conf.d' } diff --git a/spec/classes/datadog_agent_integrations_kubernetes_spec.rb b/spec/classes/datadog_agent_integrations_kubernetes_spec.rb index 53b77b00..de164bd4 100644 --- a/spec/classes/datadog_agent_integrations_kubernetes_spec.rb +++ b/spec/classes/datadog_agent_integrations_kubernetes_spec.rb @@ -2,13 +2,13 @@ describe 'datadog_agent::integrations::kubernetes' do context 'supported agents - v5 and v6' do - agents = { '5' => false, '6' => true } + agents = { '5' => true, '6' => false } agents.each do |_, enabled| - let(:pre_condition) { "class {'::datadog_agent': agent6_enable => #{enabled}}" } + let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" } let(:facts) {{ operatingsystem: 'Ubuntu', }} - if !enabled + if enabled let(:conf_dir) { '/etc/dd-agent/conf.d' } else let(:conf_dir) { '/etc/datadog-agent/conf.d' } @@ -17,7 +17,7 @@ let(:dd_group) { 'root' } let(:dd_package) { 'datadog-agent' } let(:dd_service) { 'datadog-agent' } - if !enabled + if enabled let(:conf_file) { "#{conf_dir}/kubernetes.yaml" } else let(:conf_file) { "#{conf_dir}/kubernetes.yaml" } diff --git a/spec/classes/datadog_agent_integrations_kubernetes_state_spec.rb b/spec/classes/datadog_agent_integrations_kubernetes_state_spec.rb index 641ec28e..474d911d 100644 --- a/spec/classes/datadog_agent_integrations_kubernetes_state_spec.rb +++ b/spec/classes/datadog_agent_integrations_kubernetes_state_spec.rb @@ -2,13 +2,13 @@ describe 'datadog_agent::integrations::kubernetes_state' do context 'supported agents - v5 and v6' do - agents = { '5' => false, '6' => true } + agents = { '5' => true, '6' => false } agents.each do |_, enabled| - let(:pre_condition) { "class {'::datadog_agent': agent6_enable => #{enabled}}" } + let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" } let(:facts) {{ operatingsystem: 'Ubuntu', }} - if !enabled + if enabled let(:conf_dir) { '/etc/dd-agent/conf.d' } else let(:conf_dir) { '/etc/datadog-agent/conf.d' } @@ -17,7 +17,7 @@ let(:dd_group) { 'root' } let(:dd_package) { 'datadog-agent' } let(:dd_service) { 'datadog-agent' } - if !enabled + if enabled let(:conf_file) { "#{conf_dir}/kubernetes_state.yaml" } else let(:conf_file) { "#{conf_dir}/kubernetes_state.yaml" } diff --git a/spec/classes/datadog_agent_integrations_marathon_spec.rb b/spec/classes/datadog_agent_integrations_marathon_spec.rb index cc283e41..7818a60a 100644 --- a/spec/classes/datadog_agent_integrations_marathon_spec.rb +++ b/spec/classes/datadog_agent_integrations_marathon_spec.rb @@ -2,13 +2,13 @@ describe 'datadog_agent::integrations::marathon' do context 'supported agents - v5 and v6' do - agents = { '5' => false, '6' => true } + agents = { '5' => true, '6' => false } agents.each do |_, enabled| - let(:pre_condition) { "class {'::datadog_agent': agent6_enable => #{enabled}}" } + let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" } let(:facts) {{ operatingsystem: 'Ubuntu', }} - if !enabled + if enabled let(:conf_dir) { '/etc/dd-agent/conf.d' } else let(:conf_dir) { '/etc/datadog-agent/conf.d' } diff --git a/spec/classes/datadog_agent_integrations_memcache_spec.rb b/spec/classes/datadog_agent_integrations_memcache_spec.rb index 71dcbda8..5713c064 100644 --- a/spec/classes/datadog_agent_integrations_memcache_spec.rb +++ b/spec/classes/datadog_agent_integrations_memcache_spec.rb @@ -2,13 +2,13 @@ describe 'datadog_agent::integrations::memcache' do context 'supported agents - v5 and v6' do - agents = { '5' => false, '6' => true } + agents = { '5' => true, '6' => false } agents.each do |_, enabled| - let(:pre_condition) { "class {'::datadog_agent': agent6_enable => #{enabled}}" } + let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" } let(:facts) {{ operatingsystem: 'Ubuntu', }} - if !enabled + if enabled let(:conf_dir) { '/etc/dd-agent/conf.d' } else let(:conf_dir) { '/etc/datadog-agent/conf.d' } diff --git a/spec/classes/datadog_agent_integrations_mesos_master_spec.rb b/spec/classes/datadog_agent_integrations_mesos_master_spec.rb index bfb73b6e..f79a26ce 100644 --- a/spec/classes/datadog_agent_integrations_mesos_master_spec.rb +++ b/spec/classes/datadog_agent_integrations_mesos_master_spec.rb @@ -2,13 +2,13 @@ describe 'datadog_agent::integrations::mesos_master' do context 'supported agents - v5 and v6' do - agents = { '5' => false, '6' => true } + agents = { '5' => true, '6' => false } agents.each do |_, enabled| - let(:pre_condition) { "class {'::datadog_agent': agent6_enable => #{enabled}}" } + let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" } let(:facts) {{ operatingsystem: 'Ubuntu', }} - if !enabled + if enabled let(:conf_dir) { '/etc/dd-agent/conf.d' } else let(:conf_dir) { '/etc/datadog-agent/conf.d' } diff --git a/spec/classes/datadog_agent_integrations_mongo_spec.rb b/spec/classes/datadog_agent_integrations_mongo_spec.rb index 6fe7109c..bb624f3f 100644 --- a/spec/classes/datadog_agent_integrations_mongo_spec.rb +++ b/spec/classes/datadog_agent_integrations_mongo_spec.rb @@ -2,13 +2,13 @@ describe 'datadog_agent::integrations::mongo' do context 'supported agents - v5 and v6' do - agents = { '5' => false, '6' => true } + agents = { '5' => true, '6' => false } agents.each do |_, enabled| - let(:pre_condition) { "class {'::datadog_agent': agent6_enable => #{enabled}}" } + let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" } let(:facts) {{ operatingsystem: 'Ubuntu', }} - if !enabled + if enabled let(:conf_dir) { '/etc/dd-agent/conf.d' } else let(:conf_dir) { '/etc/datadog-agent/conf.d' } diff --git a/spec/classes/datadog_agent_integrations_mysql_spec.rb b/spec/classes/datadog_agent_integrations_mysql_spec.rb index ef7db2f3..cb266859 100644 --- a/spec/classes/datadog_agent_integrations_mysql_spec.rb +++ b/spec/classes/datadog_agent_integrations_mysql_spec.rb @@ -2,13 +2,13 @@ describe 'datadog_agent::integrations::mysql' do context 'supported agents - v5 and v6' do - agents = { '5' => false, '6' => true } + agents = { '5' => true, '6' => false } agents.each do |_, enabled| - let(:pre_condition) { "class {'::datadog_agent': agent6_enable => #{enabled}}" } + let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" } let(:facts) {{ operatingsystem: 'Ubuntu', }} - if !enabled + if enabled let(:conf_dir) { '/etc/dd-agent/conf.d' } else let(:conf_dir) { '/etc/datadog-agent/conf.d' } diff --git a/spec/classes/datadog_agent_integrations_nginx_spec.rb b/spec/classes/datadog_agent_integrations_nginx_spec.rb index 78bf747f..c3865fff 100644 --- a/spec/classes/datadog_agent_integrations_nginx_spec.rb +++ b/spec/classes/datadog_agent_integrations_nginx_spec.rb @@ -2,13 +2,13 @@ describe 'datadog_agent::integrations::nginx' do context 'supported agents - v5 and v6' do - agents = { '5' => false, '6' => true } + agents = { '5' => true, '6' => false } agents.each do |_, enabled| - let(:pre_condition) { "class {'::datadog_agent': agent6_enable => #{enabled}}" } + let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" } let(:facts) {{ operatingsystem: 'Ubuntu', }} - if !enabled + if enabled let(:conf_dir) { '/etc/dd-agent/conf.d' } else let(:conf_dir) { '/etc/datadog-agent/conf.d' } diff --git a/spec/classes/datadog_agent_integrations_ntp_spec.rb b/spec/classes/datadog_agent_integrations_ntp_spec.rb index 7f4fe90b..70d80d36 100644 --- a/spec/classes/datadog_agent_integrations_ntp_spec.rb +++ b/spec/classes/datadog_agent_integrations_ntp_spec.rb @@ -2,13 +2,13 @@ describe 'datadog_agent::integrations::ntp' do context 'supported agents - v5 and v6' do - agents = { '5' => false, '6' => true } + agents = { '5' => true, '6' => false } agents.each do |_, enabled| - let(:pre_condition) { "class {'::datadog_agent': agent6_enable => #{enabled}}" } + let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" } let(:facts) {{ operatingsystem: 'Ubuntu', }} - if !enabled + if enabled let(:conf_dir) { '/etc/dd-agent/conf.d' } else let(:conf_dir) { '/etc/datadog-agent/conf.d' } diff --git a/spec/classes/datadog_agent_integrations_pgbouncer_spec.rb b/spec/classes/datadog_agent_integrations_pgbouncer_spec.rb index 86f6f690..e1ac878c 100644 --- a/spec/classes/datadog_agent_integrations_pgbouncer_spec.rb +++ b/spec/classes/datadog_agent_integrations_pgbouncer_spec.rb @@ -2,13 +2,13 @@ describe 'datadog_agent::integrations::pgbouncer' do context 'supported agents - v5 and v6' do - agents = { '5' => false, '6' => true } + agents = { '5' => true, '6' => false } agents.each do |_, enabled| - let(:pre_condition) { "class {'::datadog_agent': agent6_enable => #{enabled}}" } + let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" } let(:facts) {{ operatingsystem: 'Ubuntu', }} - if !enabled + if enabled let(:conf_dir) { '/etc/dd-agent/conf.d' } else let(:conf_dir) { '/etc/datadog-agent/conf.d' } diff --git a/spec/classes/datadog_agent_integrations_php_fpm_spec.rb b/spec/classes/datadog_agent_integrations_php_fpm_spec.rb index f6c797e5..d7c24b81 100644 --- a/spec/classes/datadog_agent_integrations_php_fpm_spec.rb +++ b/spec/classes/datadog_agent_integrations_php_fpm_spec.rb @@ -2,13 +2,13 @@ describe 'datadog_agent::integrations::php_fpm' do context 'supported agents - v5 and v6' do - agents = { '5' => false, '6' => true } + agents = { '5' => true, '6' => false } agents.each do |_, enabled| - let(:pre_condition) { "class {'::datadog_agent': agent6_enable => #{enabled}}" } + let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" } let(:facts) {{ operatingsystem: 'Ubuntu', }} - if !enabled + if enabled let(:conf_dir) { '/etc/dd-agent/conf.d' } else let(:conf_dir) { '/etc/datadog-agent/conf.d' } diff --git a/spec/classes/datadog_agent_integrations_postfix_spec.rb b/spec/classes/datadog_agent_integrations_postfix_spec.rb index a9f955d7..48045f1e 100644 --- a/spec/classes/datadog_agent_integrations_postfix_spec.rb +++ b/spec/classes/datadog_agent_integrations_postfix_spec.rb @@ -2,13 +2,13 @@ describe 'datadog_agent::integrations::postfix' do context 'supported agents - v5 and v6' do - agents = { '5' => false, '6' => true } + agents = { '5' => true, '6' => false } agents.each do |_, enabled| - let(:pre_condition) { "class {'::datadog_agent': agent6_enable => #{enabled}}" } + let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" } let(:facts) {{ operatingsystem: 'Ubuntu', }} - if !enabled + if enabled let(:conf_dir) { '/etc/dd-agent/conf.d' } else let(:conf_dir) { '/etc/datadog-agent/conf.d' } diff --git a/spec/classes/datadog_agent_integrations_postgres_spec.rb b/spec/classes/datadog_agent_integrations_postgres_spec.rb index 34696c07..2aa9e749 100644 --- a/spec/classes/datadog_agent_integrations_postgres_spec.rb +++ b/spec/classes/datadog_agent_integrations_postgres_spec.rb @@ -2,13 +2,13 @@ describe 'datadog_agent::integrations::postgres' do context 'supported agents - v5 and v6' do - agents = { '5' => false, '6' => true } + agents = { '5' => true, '6' => false } agents.each do |_, enabled| - let(:pre_condition) { "class {'::datadog_agent': agent6_enable => #{enabled}}" } + let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" } let(:facts) {{ operatingsystem: 'Ubuntu', }} - if !enabled + if enabled let(:conf_dir) { '/etc/dd-agent/conf.d' } else let(:conf_dir) { '/etc/datadog-agent/conf.d' } diff --git a/spec/classes/datadog_agent_integrations_process_spec.rb b/spec/classes/datadog_agent_integrations_process_spec.rb index b3af2e04..e92155a4 100644 --- a/spec/classes/datadog_agent_integrations_process_spec.rb +++ b/spec/classes/datadog_agent_integrations_process_spec.rb @@ -2,13 +2,13 @@ describe 'datadog_agent::integrations::process' do context 'supported agents - v5 and v6' do - agents = { '5' => false, '6' => true } + agents = { '5' => true, '6' => false } agents.each do |_, enabled| - let(:pre_condition) { "class {'::datadog_agent': agent6_enable => #{enabled}}" } + let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" } let(:facts) {{ operatingsystem: 'Ubuntu', }} - if !enabled + if enabled let(:conf_dir) { '/etc/dd-agent/conf.d' } else let(:conf_dir) { '/etc/datadog-agent/conf.d' } diff --git a/spec/classes/datadog_agent_integrations_rabbitmq_spec.rb b/spec/classes/datadog_agent_integrations_rabbitmq_spec.rb index a44b590c..8bc8ccc0 100644 --- a/spec/classes/datadog_agent_integrations_rabbitmq_spec.rb +++ b/spec/classes/datadog_agent_integrations_rabbitmq_spec.rb @@ -2,13 +2,13 @@ describe 'datadog_agent::integrations::rabbitmq' do context 'supported agents - v5 and v6' do - agents = { '5' => false, '6' => true } + agents = { '5' => true, '6' => false } agents.each do |_, enabled| - let(:pre_condition) { "class {'::datadog_agent': agent6_enable => #{enabled}}" } + let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" } let(:facts) {{ operatingsystem: 'Ubuntu', }} - if !enabled + if enabled let(:conf_dir) { '/etc/dd-agent/conf.d' } else let(:conf_dir) { '/etc/datadog-agent/conf.d' } diff --git a/spec/classes/datadog_agent_integrations_redis_spec.rb b/spec/classes/datadog_agent_integrations_redis_spec.rb index 509bf454..255dd153 100644 --- a/spec/classes/datadog_agent_integrations_redis_spec.rb +++ b/spec/classes/datadog_agent_integrations_redis_spec.rb @@ -2,13 +2,13 @@ describe 'datadog_agent::integrations::redis' do context 'supported agents - v5 and v6' do - agents = { '5' => false, '6' => true } + agents = { '5' => true, '6' => false } agents.each do |_, enabled| - let(:pre_condition) { "class {'::datadog_agent': agent6_enable => #{enabled}}" } + let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" } let(:facts) {{ operatingsystem: 'Ubuntu', }} - if !enabled + if enabled let(:conf_dir) { '/etc/dd-agent/conf.d' } else let(:conf_dir) { '/etc/datadog-agent/conf.d' } diff --git a/spec/classes/datadog_agent_integrations_riak_spec.rb b/spec/classes/datadog_agent_integrations_riak_spec.rb index c4a4b2be..9be05acd 100644 --- a/spec/classes/datadog_agent_integrations_riak_spec.rb +++ b/spec/classes/datadog_agent_integrations_riak_spec.rb @@ -2,13 +2,13 @@ describe 'datadog_agent::integrations::riak' do context 'supported agents - v5 and v6' do - agents = { '5' => false, '6' => true } + agents = { '5' => true, '6' => false } agents.each do |_, enabled| - let(:pre_condition) { "class {'::datadog_agent': agent6_enable => #{enabled}}" } + let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" } let(:facts) {{ operatingsystem: 'Ubuntu', }} - if !enabled + if enabled let(:conf_dir) { '/etc/dd-agent/conf.d' } else let(:conf_dir) { '/etc/datadog-agent/conf.d' } diff --git a/spec/classes/datadog_agent_integrations_snmp_spec.rb b/spec/classes/datadog_agent_integrations_snmp_spec.rb index e09df5f5..5ae83687 100644 --- a/spec/classes/datadog_agent_integrations_snmp_spec.rb +++ b/spec/classes/datadog_agent_integrations_snmp_spec.rb @@ -1,9 +1,6 @@ require 'spec_helper' describe 'datadog_agent::integrations::snmp' do - let(:facts) {{ - operatingsystem: 'Ubuntu', - }} let(:conf_dir) { '/etc/dd-agent/conf.d' } let(:dd_user) { 'dd-agent' } let(:dd_group) { 'root' } diff --git a/spec/classes/datadog_agent_integrations_solr_spec.rb b/spec/classes/datadog_agent_integrations_solr_spec.rb index 0682ff44..f927faf8 100644 --- a/spec/classes/datadog_agent_integrations_solr_spec.rb +++ b/spec/classes/datadog_agent_integrations_solr_spec.rb @@ -2,13 +2,13 @@ describe 'datadog_agent::integrations::solr' do context 'supported agents - v5 and v6' do - agents = { '5' => false, '6' => true } + agents = { '5' => true, '6' => false } agents.each do |_, enabled| - let(:pre_condition) { "class {'::datadog_agent': agent6_enable => #{enabled}}" } + let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" } let(:facts) {{ operatingsystem: 'Ubuntu', }} - if !enabled + if enabled let(:conf_dir) { '/etc/dd-agent/conf.d' } else let(:conf_dir) { '/etc/datadog-agent/conf.d' } diff --git a/spec/classes/datadog_agent_integrations_ssh_spec.rb b/spec/classes/datadog_agent_integrations_ssh_spec.rb index 9818b158..b4545e26 100644 --- a/spec/classes/datadog_agent_integrations_ssh_spec.rb +++ b/spec/classes/datadog_agent_integrations_ssh_spec.rb @@ -2,13 +2,13 @@ describe 'datadog_agent::integrations::ssh' do context 'supported agents - v5 and v6' do - agents = { '5' => false, '6' => true } + agents = { '5' => true, '6' => false } agents.each do |_, enabled| - let(:pre_condition) { "class {'::datadog_agent': agent6_enable => #{enabled}}" } + let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" } let(:facts) {{ operatingsystem: 'Ubuntu', }} - if !enabled + if enabled let(:conf_dir) { '/etc/dd-agent/conf.d' } else let(:conf_dir) { '/etc/datadog-agent/conf.d' } diff --git a/spec/classes/datadog_agent_integrations_supervisrd_spec.rb b/spec/classes/datadog_agent_integrations_supervisrd_spec.rb index f7b903fc..55680068 100644 --- a/spec/classes/datadog_agent_integrations_supervisrd_spec.rb +++ b/spec/classes/datadog_agent_integrations_supervisrd_spec.rb @@ -1,91 +1,103 @@ require 'spec_helper' describe 'datadog_agent::integrations::supervisord' 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}/supervisord.yaml" } + context 'supported agents - v5 and v6' do + agents = { '5' => true, '6' => false } + agents.each do |_, enabled| + let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" } + if enabled + let(:conf_dir) { '/etc/dd-agent/conf.d' } + else + let(:conf_dir) { '/etc/datadog-agent/conf.d' } + end - 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}]") } + let(:facts) {{ + operatingsystem: 'Ubuntu', + }} + let(:conf_dir) { '/etc/datadog-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}/supervisord.yaml" } - context 'with default parameters' do - it { should contain_file(conf_file).with_content(%r{name: server0\s+host: localhost\s+port: 9001}) } - end + 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 one supervisord' do - context 'without processes' do - let(:params) {{ - instances: [ - { - 'servername' => 'server0', - 'socket' => 'unix://var/run/supervisor.sock', - }, - ] - }} - it { should contain_file(conf_file).with_content(%r{name: server0\s+socket: unix://var/run/supervisor.sock}) } - end - context 'with processes' do - let(:params) {{ - instances: [ - { - 'servername' => 'server0', - 'socket' => 'unix://var/run/supervisor.sock', - 'proc_names' => %w{ java apache2 }, - }, - ] - }} - it { should contain_file(conf_file).with_content(%r{name: server0\s+socket: unix://var/run/supervisor.sock\s+proc_names:\s+- java\s+- apache2}) } - end - end + context 'with default parameters' do + it { should contain_file(conf_file).with_content(%r{name: server0\s+host: localhost\s+port: 9001}) } + end - context 'with multiple supervisord' do - context 'without processes parameter array' do - let(:params) {{ - instances: [ - { - 'servername' => 'server0', - 'socket' => 'unix://var/run/supervisor.sock', - }, - { - 'servername' => 'server1', - 'hostname' => 'localhost', - 'port' => '9001', - }, - ] - }} - it { should contain_file(conf_file).with_content(%r{name: server0\s+socket: unix://var/run/supervisor.sock}) } - it { should contain_file(conf_file).with_content(%r{name: server1\s+host: localhost\s+port: 9001}) } - end - context 'with processes parameter array' do - let(:params) {{ - instances: [ - { - 'servername' => 'server0', - 'socket' => 'unix://var/run/supervisor.sock', - 'proc_names' => %w{ webapp nginx }, - }, - { - 'servername' => 'server1', - 'hostname' => 'localhost', - 'port' => '9001', - 'proc_names' => %w{ java apache2 }, - }, - ] - }} - it { should contain_file(conf_file).with_content(%r{name: server0\s+socket: unix://var/run/supervisor.sock\s+proc_names:\s+- webapp\s+- nginx}) } - it { should contain_file(conf_file).with_content(%r{name: server1\s+host: localhost\s+port: 9001\s+proc_names:\s+- java\s+- apache2}) } + context 'with one supervisord' do + context 'without processes' do + let(:params) {{ + instances: [ + { + 'servername' => 'server0', + 'socket' => 'unix://var/run/supervisor.sock', + }, + ] + }} + it { should contain_file(conf_file).with_content(%r{name: server0\s+socket: unix://var/run/supervisor.sock}) } + end + context 'with processes' do + let(:params) {{ + instances: [ + { + 'servername' => 'server0', + 'socket' => 'unix://var/run/supervisor.sock', + 'proc_names' => %w{ java apache2 }, + }, + ] + }} + it { should contain_file(conf_file).with_content(%r{name: server0\s+socket: unix://var/run/supervisor.sock\s+proc_names:\s+- java\s+- apache2}) } + end + end + + context 'with multiple supervisord' do + context 'without processes parameter array' do + let(:params) {{ + instances: [ + { + 'servername' => 'server0', + 'socket' => 'unix://var/run/supervisor.sock', + }, + { + 'servername' => 'server1', + 'hostname' => 'localhost', + 'port' => '9001', + }, + ] + }} + it { should contain_file(conf_file).with_content(%r{name: server0\s+socket: unix://var/run/supervisor.sock}) } + it { should contain_file(conf_file).with_content(%r{name: server1\s+host: localhost\s+port: 9001}) } + end + context 'with processes parameter array' do + let(:params) {{ + instances: [ + { + 'servername' => 'server0', + 'socket' => 'unix://var/run/supervisor.sock', + 'proc_names' => %w{ webapp nginx }, + }, + { + 'servername' => 'server1', + 'hostname' => 'localhost', + 'port' => '9001', + 'proc_names' => %w{ java apache2 }, + }, + ] + }} + it { should contain_file(conf_file).with_content(%r{name: server0\s+socket: unix://var/run/supervisor.sock\s+proc_names:\s+- webapp\s+- nginx}) } + it { should contain_file(conf_file).with_content(%r{name: server1\s+host: localhost\s+port: 9001\s+proc_names:\s+- java\s+- apache2}) } + end + end end end end diff --git a/spec/classes/datadog_agent_integrations_tcp_check_spec.rb b/spec/classes/datadog_agent_integrations_tcp_check_spec.rb index d28c8fff..55cf5169 100644 --- a/spec/classes/datadog_agent_integrations_tcp_check_spec.rb +++ b/spec/classes/datadog_agent_integrations_tcp_check_spec.rb @@ -2,13 +2,13 @@ describe 'datadog_agent::integrations::tcp_check' do context 'supported agents - v5 and v6' do - agents = { '5' => false, '6' => true } + agents = { '5' => true, '6' => false } agents.each do |_, enabled| - let(:pre_condition) { "class {'::datadog_agent': agent6_enable => #{enabled}}" } + let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" } let(:facts) {{ operatingsystem: 'Ubuntu', }} - if !enabled + if enabled let(:conf_dir) { '/etc/dd-agent/conf.d' } else let(:conf_dir) { '/etc/datadog-agent/conf.d' } diff --git a/spec/classes/datadog_agent_integrations_tomcat_spec.rb b/spec/classes/datadog_agent_integrations_tomcat_spec.rb index 3a93a9b4..38a40198 100644 --- a/spec/classes/datadog_agent_integrations_tomcat_spec.rb +++ b/spec/classes/datadog_agent_integrations_tomcat_spec.rb @@ -2,13 +2,13 @@ describe 'datadog_agent::integrations::tomcat' do context 'supported agents - v5 and v6' do - agents = { '5' => false, '6' => true } + agents = { '5' => true, '6' => false } agents.each do |_, enabled| - let(:pre_condition) { "class {'::datadog_agent': agent6_enable => #{enabled}}" } + let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" } let(:facts) {{ operatingsystem: 'Ubuntu', }} - if !enabled + if enabled let(:conf_dir) { '/etc/dd-agent/conf.d' } else let(:conf_dir) { '/etc/datadog-agent/conf.d' } diff --git a/spec/classes/datadog_agent_integrations_twemproxy_spec.rb b/spec/classes/datadog_agent_integrations_twemproxy_spec.rb index 437e7d6e..f8eacdcd 100644 --- a/spec/classes/datadog_agent_integrations_twemproxy_spec.rb +++ b/spec/classes/datadog_agent_integrations_twemproxy_spec.rb @@ -2,13 +2,13 @@ describe 'datadog_agent::integrations::twemproxy' do context 'supported agents - v5 and v6' do - agents = { '5' => false, '6' => true } + agents = { '5' => true, '6' => false } agents.each do |_, enabled| - let(:pre_condition) { "class {'::datadog_agent': agent6_enable => #{enabled}}" } + let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" } let(:facts) {{ operatingsystem: 'Ubuntu', }} - if !enabled + if enabled let(:conf_dir) { '/etc/dd-agent/conf.d' } else let(:conf_dir) { '/etc/datadog-agent/conf.d' } diff --git a/spec/classes/datadog_agent_integrations_varnish_spec.rb b/spec/classes/datadog_agent_integrations_varnish_spec.rb index 54579db1..0028fe91 100644 --- a/spec/classes/datadog_agent_integrations_varnish_spec.rb +++ b/spec/classes/datadog_agent_integrations_varnish_spec.rb @@ -2,13 +2,13 @@ describe 'datadog_agent::integrations::varnish' do context 'supported agents - v5 and v6' do - agents = { '5' => false, '6' => true } + agents = { '5' => true, '6' => false } agents.each do |_, enabled| - let(:pre_condition) { "class {'::datadog_agent': agent6_enable => #{enabled}}" } + let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" } let(:facts) {{ operatingsystem: 'Ubuntu', }} - if !enabled + if enabled let(:conf_dir) { '/etc/dd-agent/conf.d' } else let(:conf_dir) { '/etc/datadog-agent/conf.d' } diff --git a/spec/classes/datadog_agent_integrations_zk_spec.rb b/spec/classes/datadog_agent_integrations_zk_spec.rb index 0218a4fa..be50ef2e 100644 --- a/spec/classes/datadog_agent_integrations_zk_spec.rb +++ b/spec/classes/datadog_agent_integrations_zk_spec.rb @@ -2,13 +2,13 @@ describe 'datadog_agent::integrations::zk' do context 'supported agents - v5 and v6' do - agents = { '5' => false, '6' => true } + agents = { '5' => true, '6' => false } agents.each do |_, enabled| - let(:pre_condition) { "class {'::datadog_agent': agent6_enable => #{enabled}}" } + let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" } let(:facts) {{ operatingsystem: 'Ubuntu', }} - if !enabled + if enabled let(:conf_dir) { '/etc/dd-agent/conf.d' } else let(:conf_dir) { '/etc/datadog-agent/conf.d' } diff --git a/spec/classes/datadog_agent_redhat_spec.rb b/spec/classes/datadog_agent_redhat_spec.rb index 318646fd..1ebdfbb9 100644 --- a/spec/classes/datadog_agent_redhat_spec.rb +++ b/spec/classes/datadog_agent_redhat_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'datadog_agent::redhat' do +describe 'datadog_agent::redhat::agent5' do let(:facts) do { osfamily: 'redhat', @@ -13,7 +13,7 @@ context 'with manage_repo => true' do let(:params){ {:manage_repo => true} } it do - should contain_yumrepo('datadog') + should contain_yumrepo('datadog5') .with_enabled(1)\ .with_gpgcheck(1)\ .with_gpgkey('https://yum.datadoghq.com/DATADOG_RPM_KEY.public')\ @@ -24,6 +24,8 @@ let(:params){ {:manage_repo => false} } it do should_not contain_yumrepo('datadog') + should_not contain_yumrepo('datadog5') + should_not contain_yumrepo('datadog6') end end @@ -59,17 +61,19 @@ context 'with manage_repo => true' do let(:params){ {:manage_repo => true} } it do - should contain_yumrepo('datadog') + should contain_yumrepo('datadog6') .with_enabled(1)\ .with_gpgcheck(1)\ .with_gpgkey('https://yum.datadoghq.com/DATADOG_RPM_KEY.public')\ - .with_baseurl('https://yum.datadoghq.com/beta/x86_64/') + .with_baseurl('https://yum.datadoghq.com/rpm/6/x86_64/') end end context 'with manage_repo => false' do let(:params){ {:manage_repo => false} } it do should_not contain_yumrepo('datadog') + should_not contain_yumrepo('datadog5') + should_not contain_yumrepo('datadog6') end end diff --git a/spec/classes/datadog_agent_reports_spec.rb b/spec/classes/datadog_agent_reports_spec.rb index 374b1f3a..fd2d8aa1 100644 --- a/spec/classes/datadog_agent_reports_spec.rb +++ b/spec/classes/datadog_agent_reports_spec.rb @@ -8,7 +8,6 @@ hostname_extraction_regex: nil, puppetmaster_user: 'puppet', dogapi_version: 'installed', - puppet_gem_provider: 'gem' } end ALL_OS.each do |operatingsystem| @@ -16,7 +15,8 @@ let(:facts) do { operatingsystem: operatingsystem, - osfamily: DEBIAN_OS.include?(operatingsystem) ? 'debian' : 'redhat' + osfamily: DEBIAN_OS.include?(operatingsystem) ? 'debian' : 'redhat', + operatingsystemrelease: DEBIAN_OS.include?(operatingsystem) ? '14.04' : '7', } end @@ -42,7 +42,7 @@ it do should contain_package('dogapi')\ .with_ensure('installed') - .with_provider('gem') + .with_provider('puppetserver_gem') end it do @@ -60,8 +60,7 @@ api_key: 'notanapikey', hostname_extraction_regex: nil, puppetmaster_user: 'puppet', - dogapi_version: '1.2.2', - puppet_gem_provider: 'gem' + dogapi_version: '1.2.2' } end describe "datadog_agent class dogapi version override" do @@ -86,7 +85,7 @@ it do should contain_package('dogapi')\ .with_ensure('1.2.2') - .with_provider('gem') + .with_provider('puppetserver_gem') end it do diff --git a/spec/classes/datadog_agent_spec.rb b/spec/classes/datadog_agent_spec.rb index f13c5a36..5e84c90d 100644 --- a/spec/classes/datadog_agent_spec.rb +++ b/spec/classes/datadog_agent_spec.rb @@ -22,7 +22,9 @@ context 'all supported operating systems' do ALL_OS.each do |operatingsystem| describe "datadog_agent class common actions on #{operatingsystem}" do - let(:params) { { puppet_run_reports: true, puppet_gem_provider: 'gem' } } + let(:params) { { puppet_run_reports: true, + agent5_enable: true, + } } let(:facts) do { operatingsystem: operatingsystem, @@ -208,7 +210,7 @@ context 'for APM' do it { should contain_concat__fragment('datadog footer').with( - 'content' => /^apm_enabled: false\n/, + 'content' => /^apm_enabled: true\n/, )} end @@ -216,261 +218,348 @@ context 'with user provided paramaters' do context 'with a custom dd_url' do - let(:params) {{:dd_url => 'https://notaurl.datadoghq.com'}} + let(:params) {{ :dd_url => 'https://notaurl.datadoghq.com', + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog header').with( 'content' => /^dd_url: https:\/\/notaurl.datadoghq.com\n/, )} end context 'with a custom proxy_host' do - let(:params) {{:proxy_host => 'localhost'}} + let(:params) {{ :proxy_host => 'localhost', + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog header').with( 'content' => /^proxy_host: localhost\n/, )} end context 'with a custom proxy_port' do - let(:params) {{:proxy_port => '1234'}} + let(:params) {{ :proxy_port => '1234', + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog header').with( 'content' => /^proxy_port: 1234\n/, )} end context 'with a custom proxy_port, specified as an integer' do - let(:params) {{:proxy_port => 1234}} + let(:params) {{ :proxy_port => 1234, + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog header').with( 'content' => /^proxy_port: 1234\n/, )} end context 'with a custom proxy_user' do - let(:params) {{:proxy_user => 'notauser'}} + let(:params) {{ :proxy_user => 'notauser', + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog header').with( 'content' => /^proxy_user: notauser\n/, )} end context 'with a custom api_key' do - let(:params) {{:api_key => 'notakey'}} + let(:params) {{ :api_key => 'notakey', + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog header').with( 'content' => /^api_key: notakey\n/, )} end context 'with a custom hostname' do - let(:params) {{:host => 'notahost'}} + let(:params) {{ :host => 'notahost', + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog header').with( 'content' => /^hostname: notahost\n/, )} end context 'with non_local_traffic set to true' do - let(:params) {{:non_local_traffic => true}} + let(:params) {{ :non_local_traffic => true, + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').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'}} + let(:params) {{ :log_level => 'critical', + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^log_level: CRITICAL\n/, )} end context 'with a custom hostname' do - let(:params) {{:host => 'notahost'}} + let(:params) {{ :host => 'notahost', + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog header').with( 'content' => /^hostname: notahost\n/, )} end context 'with log_to_syslog set to false' do - let(:params) {{:log_to_syslog => false}} + let(:params) {{ :log_to_syslog => false, + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^log_to_syslog: no\n/, )} end context 'with skip_ssl_validation set to true' do - let(:params) {{:skip_ssl_validation => true }} + let(:params) {{ :skip_ssl_validation => true, + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog header').with( 'content' => /^skip_ssl_validation: true\n/, )} end context 'with collect_ec2_tags set to yes' do - let(:params) {{:collect_ec2_tags => true }} + let(:params) {{ :collect_ec2_tags => true, + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^collect_ec2_tags: true\n/, )} end context 'with collect_instance_metadata set to no' do - let(:params) {{:collect_instance_metadata => false }} + let(:params) {{ :collect_instance_metadata => false, + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').with( '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', + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').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', + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^listen_port: 17125\n/, )} end context 'with a custom port set to 17125, specified as an integer' do - let(:params) {{:listen_port => 17125 }} + let(:params) {{ :listen_port => 17125, + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^listen_port: 17125\n/, )} end context 'listening for graphite data on port 17124' do - let(:params) {{:graphite_listen_port => '17124' }} + let(:params) {{ :graphite_listen_port => '17124', + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^graphite_listen_port: 17124\n/, )} end context 'listening for graphite data on port 17124, port specified as an integer' do - let(:params) {{:graphite_listen_port => 17124 }} + let(:params) {{ :graphite_listen_port => 17124, + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').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' }} + let(:params) {{ :additional_checksd => '/etc/dd-agent/checks_custom.d', + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').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' }} + let(:params) {{ :additional_checksd => '/etc/dd-agent/checks_custom.d', + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').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' }} + let(:params) {{ :additional_checksd => '/etc/dd-agent/checks_custom.d', + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').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 => true }} + let(:params) {{ :use_curl_http_client => true, + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^use_curl_http_client: true\n/, )} end context 'with a custom bind_host' do - let(:params) {{:bind_host => 'test' }} + let(:params) {{ :bind_host => 'test', + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^bind_host: test\n/, )} end context 'with pup enabled' do - let(:params) {{:use_pup => true }} + let(:params) {{ :use_pup => true, + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^use_pup: yes\n/, )} end context 'with a custom pup_port' do - let(:params) {{:pup_port => '17126' }} + let(:params) {{ :pup_port => '17126', + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^pup_port: 17126\n/, )} end context 'with a custom pup_port, specified as an integer' do - let(:params) {{:pup_port => 17126 }} + let(:params) {{ :pup_port => 17126, + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^pup_port: 17126\n/, )} end context 'with a custom pup_interface' do - let(:params) {{:pup_interface => 'notalocalhost' }} + let(:params) {{ :pup_interface => 'notalocalhost', + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^pup_interface: notalocalhost\n/, )} end context 'with a custom pup_url' do - let(:params) {{:pup_url => 'http://localhost:17126' }} + let(:params) {{ :pup_url => 'http://localhost:17126', + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^pup_url: http:\/\/localhost:17126\n/, )} end context 'with use_dogstatsd set to no' do - let(:params) {{:use_dogstatsd => false}} + let(:params) {{ :use_dogstatsd => false, + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^use_dogstatsd: no\n/, )} end context 'with use_dogstatsd set to yes' do - let(:params) {{:use_dogstatsd => true}} + let(:params) {{ :use_dogstatsd => true, + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^use_dogstatsd: yes\n/, )} end context 'with dogstatsd_port set to 8126 - must be specified as an integer!' do - let(:params) {{:dogstatsd_port => 8126 }} + let(:params) {{ :dogstatsd_port => 8126, + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^dogstatsd_port: 8126\n/, )} end context 'with dogstatsd_port set to 8126' do - let(:params) {{:dogstatsd_port => 8126}} + let(:params) {{ :dogstatsd_port => 8126, + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^dogstatsd_port: 8126\n/, )} end context 'with dogstatsd_target set to localhost:17124' do - let(:params) {{:dogstatsd_target => 'http://localhost:17124'}} + let(:params) {{ :dogstatsd_target => 'http://localhost:17124', + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^dogstatsd_target: http:\/\/localhost:17124\n/, )} end context 'with dogstatsd_interval set to 5' do - let(:params) {{:dogstatsd_interval => '5' }} + let(:params) {{ :dogstatsd_interval => '5', + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^dogstatsd_interval: 5\n/, )} end context 'with dogstatsd_interval set to 5' do - let(:params) {{:dogstatsd_interval => '5' }} + let(:params) {{ :dogstatsd_interval => '5', + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^dogstatsd_interval: 5\n/, )} end context 'with dogstatsd_normalize set to false' do - let(:params) {{:dogstatsd_normalize => false }} + let(:params) {{ :dogstatsd_normalize => false, + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^dogstatsd_normalize: no\n/, )} end context 'with statsd_forward_host set to localhost:3958' do - let(:params) {{:statsd_forward_host => 'localhost:3958' }} + let(:params) {{ :statsd_forward_host => 'localhost:3958', + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^statsd_forward_host: localhost:3958\n/, )} end context 'with statsd_forward_port set to 8126' do - let(:params) {{:statsd_forward_port => '8126' }} + let(:params) {{ :statsd_forward_port => '8126', + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^statsd_forward_port: 8126\n/, )} end context 'with statsd_forward_port set to 8126, specified as an integer' do - let(:params) {{:statsd_forward_port => 8126 }} + let(:params) {{ :statsd_forward_port => 8126, + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^statsd_forward_port: 8126\n/, )} end context 'with device_blacklist_re set to test' do - let(:params) {{:device_blacklist_re => 'test' }} + let(:params) {{ :device_blacklist_re => 'test', + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^device_blacklist_re: test\n/, )} end context 'with device_blacklist_re set to test' do - let(:params) {{:device_blacklist_re => 'test' }} + let(:params) {{ :device_blacklist_re => 'test', + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^device_blacklist_re: test\n/, )} end context 'with ganglia_host set to localhost and ganglia_port set to 12345' do - let(:params) {{:ganglia_host => 'testhost', :ganglia_port => '12345' }} + let(:params) {{ :ganglia_host => 'testhost', + :ganglia_port => '12345', + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^ganglia_port: 12345\n/, )} @@ -479,87 +568,114 @@ )} end context 'with ganglia_host set to localhost and ganglia_port set to 12345, port specified as an integer' do - let(:params) {{:ganglia_host => 'testhost', :ganglia_port => 12345 }} + let(:params) {{ :ganglia_host => 'testhost', + :ganglia_port => 12345, + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').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'] }} + let(:params) {{ :dogstreams => ['/path/to/log1:/path/to/parser'], + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').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/' }} + let(:params) {{ :custom_emitters => '/test/emitter/', + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^custom_emitters: \/test\/emitter\/\n/, )} end context 'with custom_emitters set to /test/emitter' do - let(:params) {{:custom_emitters => '/test/emitter/' }} + let(:params) {{ :custom_emitters => '/test/emitter/', + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').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' }} + let(:params) {{ :collector_log_file => '/test/log', + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').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' }} + let(:params) {{ :forwarder_log_file => '/test/log', + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').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' }} + let(:params) {{ :forwarder_log_file => '/test/log', + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').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' }} + let(:params) {{ :dogstatsd_log_file => '/test/log', + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').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' }} + let(:params) {{ :pup_log_file => '/test/log', + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^pup_log_file: \/test\/log\n/, )} end context 'with syslog location set to localhost' do - let(:params) {{:syslog_host => 'localhost' }} + let(:params) {{ :syslog_host => 'localhost', + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^syslog_host: localhost\n/, )} end context 'with syslog port set to 8080' do - let(:params) {{:syslog_port => '8080' }} + let(:params) {{ :syslog_port => '8080', + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^syslog_port: 8080\n/, )} end context 'with syslog port set to 8080, specified as an integer' do - let(:params) {{:syslog_port => 8080 }} + let(:params) {{ :syslog_port => 8080, + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^syslog_port: 8080\n/, )} end context 'with apm_enabled set to true' do - let(:params) {{:apm_enabled => true }} + let(:params) {{ :apm_enabled => true, + :agent5_enable => true, + }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^apm_enabled: true\n/, )} end context 'with apm_enabled set to true and env specified' do - let(:params) { - {:apm_enabled => true, - :apm_env => 'foo', + let(:params) {{ :apm_enabled => true, + :apm_env => 'foo', + :agent5_enable => true, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^apm_enabled: true\n/, @@ -571,16 +687,16 @@ 'content' => /^env: foo\n/, )} it { should contain_concat__fragment('datadog apm footer').with( - 'order' => '06', + 'order' => '07', )} end context 'with service_discovery enabled' do - let(:params) { - {:service_discovery_backend => 'docker', - :sd_config_backend => 'etcd', - :sd_backend_host => 'localhost', - :sd_backend_port => '8080', - :sd_jmx_enable => true, + let(:params) {{ :service_discovery_backend => 'docker', + :sd_config_backend => 'etcd', + :sd_backend_host => 'localhost', + :sd_backend_port => '8080', + :sd_jmx_enable => true, + :agent5_enable => true, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^service_discovery_backend: docker\n/, @@ -599,8 +715,8 @@ )} end context 'with extra_template enabled' do - let(:params) { - {:extra_template => 'custom_datadog/extra_template_test.erb', + let(:params) {{ :extra_template => 'custom_datadog/extra_template_test.erb', + :agent5_enable => true, }} it { should contain_concat__fragment('datadog extra_template footer').with( 'order' => '06', @@ -616,17 +732,19 @@ let(:params) {{ :apm_enabled => true, :apm_env => 'foo', + :agent5_enable => true, }} it { should contain_concat__fragment('datadog apm footer').with( - 'order' => '06', + 'order' => '07', )} end context 'with APM enabled but no APM env' do let(:params) {{ :apm_enabled => true, + :agent5_enable => true, }} it { should_not contain_concat__fragment('datadog apm footer').with( - 'order' => '06', + 'order' => '07', )} end context 'with extra_template and APM enabled' do @@ -634,6 +752,7 @@ :extra_template => 'custom_datadog/extra_template_test.erb', :apm_enabled => true, :apm_env => 'foo', + :agent5_enable => true, }} it { should contain_concat__fragment('datadog extra_template footer').with( 'order' => '06', @@ -646,8 +765,8 @@ )} end context 'with process_agent enabled' do - let(:params) { - {:process_agent_enabled => true, + let(:params) {{ :process_enabled => true, + :agent5_enable => true, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^process_agent_enabled: true\n/, @@ -658,14 +777,14 @@ end if DEBIAN_OS.include?(operatingsystem) - it { should contain_class('datadog_agent::ubuntu') } + it { should contain_class('datadog_agent::ubuntu::agent5') } elsif REDHAT_OS.include?(operatingsystem) - it { should contain_class('datadog_agent::redhat') } + it { should contain_class('datadog_agent::redhat::agent5') } end end describe "datadog_agent 6 class common actions on #{operatingsystem}" do - let(:params) { { puppet_run_reports: true, puppet_gem_provider: 'gem', agent6_enable: true } } + let(:params) { { puppet_run_reports: true } } let(:facts) do { operatingsystem: operatingsystem, @@ -717,6 +836,99 @@ it { should contain_file('/etc/datadog-agent/datadog.yaml').with( 'content' => /^log_level: info\n/, )} + it { should contain_file('/etc/datadog-agent/datadog.yaml').with( + 'content' => /^apm_config:\n/, + )} + it { should contain_file('/etc/datadog-agent/datadog.yaml').with( + 'content' => /^\ \ apm_enabled: true\n/, + )} + it { should contain_file('/etc/datadog-agent/datadog.yaml').with( + 'content' => /^process_config:\n/, + )} + it { should contain_file('/etc/datadog-agent/datadog.yaml').with( + 'content' => /^\ \ process_enabled: 'true'\n/, + )} + end + end + + context 'with apm_extra_config' do + context 'with extra_options and APM enabled' do + let(:params) {{ + :apm_enabled => true, + :apm_env => 'foo', + :agent6_extra_options => { + 'apm_config' => { + 'foo' => 'bar', + 'bar' => 'haz', + } + } + }} + it { should contain_file('/etc/datadog-agent/datadog.yaml').with( + 'content' => /^apm_config:\n/, + )} + it { should contain_file('/etc/datadog-agent/datadog.yaml').with( + 'content' => /^\ \ apm_enabled: true\n/, + )} + it { should contain_file('/etc/datadog-agent/datadog.yaml').with( + 'content' => /^\ \ foo: bar\n/, + )} + it { should contain_file('/etc/datadog-agent/datadog.yaml').with( + 'content' => /^\ \ bar: haz\n/, + )} + end + context 'with extra_options and Process enabled' do + let(:params) {{ + :apm_enabled => false, + :process_enabled => true, + :agent6_extra_options => { + 'process_config' => { + 'foo' => 'bar', + 'bar' => 'haz', + } + } + }} + it { should contain_file('/etc/datadog-agent/datadog.yaml').with( + 'content' => /^apm_config:\n/, + )} + it { should contain_file('/etc/datadog-agent/datadog.yaml').with( + 'content' => /^\ \ apm_enabled: false\n/, + )} + it { should contain_file('/etc/datadog-agent/datadog.yaml').with( + 'content' => /^process_config:\n/, + )} + it { should contain_file('/etc/datadog-agent/datadog.yaml').with( + 'content' => /^\ \ process_enabled: 'true'\n/, + )} + it { should contain_file('/etc/datadog-agent/datadog.yaml').with( + 'content' => /^\ \ foo: bar\n/, + )} + it { should contain_file('/etc/datadog-agent/datadog.yaml').with( + 'content' => /^\ \ bar: haz\n/, + )} + end + context 'with extra_options and process options overriden' do + let(:params) {{ + :process_enabled => true, + :agent6_extra_options => { + 'process_config' => { + 'process_enabled' => 'disabled', + 'foo' => 'bar', + 'bar' => 'haz', + } + } + }} + it { should contain_file('/etc/datadog-agent/datadog.yaml').with( + 'content' => /^process_config:\n/, + )} + it { should contain_file('/etc/datadog-agent/datadog.yaml').with( + 'content' => /^\ \ process_enabled: disabled\n/, + )} + it { should contain_file('/etc/datadog-agent/datadog.yaml').with( + 'content' => /^\ \ foo: bar\n/, + )} + it { should contain_file('/etc/datadog-agent/datadog.yaml').with( + 'content' => /^\ \ bar: haz\n/, + )} end end end @@ -726,7 +938,7 @@ context "with facts to tags set" do describe "ensure facts_array outputs a list of tags" do - let(:params) { { puppet_run_reports: true, puppet_gem_provider: 'gem', facts_to_tags: ['osfamily', 'facts_array']} } + let(:params) { { puppet_run_reports: true, facts_to_tags: ['osfamily', 'facts_array']} } let(:facts) do { operatingsystem: 'CentOS', diff --git a/spec/classes/datadog_agent_ubuntu_spec.rb b/spec/classes/datadog_agent_ubuntu_spec.rb index 0bf53269..ad3d716b 100644 --- a/spec/classes/datadog_agent_ubuntu_spec.rb +++ b/spec/classes/datadog_agent_ubuntu_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'datadog_agent::ubuntu' do +describe 'datadog_agent::ubuntu::agent5' do let(:facts) do { osfamily: 'debian', @@ -9,7 +9,7 @@ end it do - contain_file('/etc/apt/sources.list.d/datadog-beta.list') + contain_file('/etc/apt/sources.list.d/datadog6.list') .with_ensure('absent') contain_file('/etc/apt/sources.list.d/datadog.list')\ .with_content(%r{deb\s+https://apt.datadoghq.com/\s+stable\s+main}) @@ -20,9 +20,9 @@ it { should contain_datadog_agent__ubuntu__install_key('A2923DFF56EDA6E76E55E492D3A80E30382E94DE') } it do should contain_file('/etc/apt/sources.list.d/datadog.list')\ - .that_notifies('exec[datadog_apt-get_update]') + .that_notifies('exec[apt_update]') end - it { should contain_exec('datadog_apt-get_update') } + it { should contain_exec('apt_update') } # it should install the packages it do @@ -37,7 +37,7 @@ it do should contain_package('datadog-agent')\ .that_requires('file[/etc/apt/sources.list.d/datadog.list]')\ - .that_requires('exec[datadog_apt-get_update]') + .that_requires('exec[apt_update]') end # it should be able to start the service and enable the service by default @@ -58,7 +58,7 @@ it do contain_file('/etc/apt/sources.list.d/datadog.list') .with_ensure('absent') - contain_file('/etc/apt/sources.list.d/datadog-beta.list')\ + contain_file('/etc/apt/sources.list.d/datadog6.list')\ .with_content(%r{deb\s+https://apt.datadoghq.com/\s+beta\s+main}) end @@ -67,15 +67,15 @@ it { should contain_datadog_agent__ubuntu__install_key('A2923DFF56EDA6E76E55E492D3A80E30382E94DE') } it do - should contain_file('/etc/apt/sources.list.d/datadog-beta.list')\ - .that_notifies('exec[datadog_apt-get_update]') + should contain_file('/etc/apt/sources.list.d/datadog6.list')\ + .that_notifies('exec[apt_update]') end - it { should contain_exec('datadog_apt-get_update') } + it { should contain_exec('apt_update') } # it should install the packages it do should contain_package('apt-transport-https')\ - .that_comes_before('file[/etc/apt/sources.list.d/datadog-beta.list]') + .that_comes_before('file[/etc/apt/sources.list.d/datadog6.list]') end it do should contain_package('datadog-agent-base')\ @@ -84,8 +84,8 @@ end it do should contain_package('datadog-agent')\ - .that_requires('file[/etc/apt/sources.list.d/datadog-beta.list]')\ - .that_requires('exec[datadog_apt-get_update]') + .that_requires('file[/etc/apt/sources.list.d/datadog6.list]')\ + .that_requires('exec[apt_update]') end # it should be able to start the service and enable the service by default diff --git a/spec/defines/datadog_agent__integration_spec.rb b/spec/defines/datadog_agent__integration_spec.rb index 39100a37..7df00915 100644 --- a/spec/defines/datadog_agent__integration_spec.rb +++ b/spec/defines/datadog_agent__integration_spec.rb @@ -1,25 +1,37 @@ require 'spec_helper' describe "datadog_agent::integration" do - let (:title) { "test" } - let(:facts) do - { - operatingsystem: 'CentOS', - osfamily: 'redhat' - } - end - let (:params) {{ - :instances => [ - { 'one' => "two" } - ] - }} - it { should compile } - it { should contain_file('/etc/dd-agent/conf.d/test.yaml').with_content(/init_config: /) } - gem_spec = Gem.loaded_specs['puppet'] - if gem_spec.version >= Gem::Version.new('4.0.0') - it { should contain_file('/etc/dd-agent/conf.d/test.yaml').with_content(/---\ninit_config: \ninstances:\n- one: two\n/) } - else - it { should contain_file('/etc/dd-agent/conf.d/test.yaml').with_content(/--- \n init_config: \n instances: \n - one: two/) } + context 'supported agents - v5 and v6' do + agents = { '5' => true, '6' => false } + agents.each do |_, enabled| + let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" } + if enabled + let(:conf_dir) { '/etc/dd-agent/conf.d' } + else + let(:conf_dir) { '/etc/datadog-agent/conf.d' } + end + + let (:title) { "test" } + let(:facts) do + { + operatingsystem: 'CentOS', + osfamily: 'redhat' + } + end + let (:params) {{ + :instances => [ + { 'one' => "two" } + ] + }} + it { should compile } + it { should contain_file("#{conf_dir}/test.yaml").with_content(/init_config: /) } + gem_spec = Gem.loaded_specs['puppet'] + if gem_spec.version >= Gem::Version.new('4.0.0') + it { should contain_file("#{conf_dir}/test.yaml").with_content(/---\ninit_config: \ninstances:\n- one: two\n/) } + else + it { should contain_file("#{conf_dir}/test.yaml").with_content(/--- \n init_config: \n instances: \n - one: two/) } + end + it { should contain_file("#{conf_dir}/test.yaml").that_notifies("Service[datadog-agent]") } end - it { should contain_file('/etc/dd-agent/conf.d/test.yaml').that_notifies("Service[datadog-agent]") } + end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 26ed00a4..cb5ebc55 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,6 +1,30 @@ require 'puppetlabs_spec_helper/module_spec_helper' +require 'rspec-puppet-facts' + +include RspecPuppetFacts DEBIAN_OS = %w(Ubuntu Debian) REDHAT_OS = %w(RedHat CentOS Fedora Amazon Scientific) ALL_OS = DEBIAN_OS + REDHAT_OS +RSpec.configure do |c| + c.default_facts = { + 'architecture' => 'x86_64', + 'operatingsystem' => 'Ubuntu', + 'osfamily' => 'Debian', + 'operatingsystemmajrelease' => '14', + 'operatingsystemminrelease' => '04', + 'operatingsystemrelease' => '14.04', + 'lsbdistrelease' => '14.04', + 'lsbdistcodename' => 'trusty', + 'os' => { + 'name' => 'Ubuntu', + 'family' => 'Debian', + 'release' => { + 'major' => '14', + 'minor' => '04', + 'full' => '14.04' + } + } + } +end diff --git a/templates/agent-conf.d/jmx.yaml.erb b/templates/agent-conf.d/jmx.yaml.erb index 82816cb9..382e17f7 100644 --- a/templates/agent-conf.d/jmx.yaml.erb +++ b/templates/agent-conf.d/jmx.yaml.erb @@ -1,26 +1,5 @@ <% require 'yaml' - -if RUBY_VERSION < "1.9" -# Hack to avoid ruby 1.8 always reordering the hashes and -# changing this template resource at every run -# See https://github.com/DataDog/puppet-datadog-agent/issues/43 -# Taken from http://www.dzone.com/snippets/generating-yaml-hashes-sorted -class Hash - # Replacing the to_yaml function so it'll serialize hashes sorted (by their keys) - # - # Original function is in /usr/lib/ruby/1.8/yaml/rubytypes.rb - def to_yaml( opts = {} ) - YAML::quick_emit( object_id, opts ) do |out| - out.map( taguri, to_yaml_style ) do |map| - sort.each do |k, v| # <-- here's my addition (the 'sort') - map.add( k, v ) - end - end - end - end -end -end %> <%= {'init_config'=>@init_config, 'instances'=>@instances}.to_yaml %> diff --git a/templates/agent-conf.d/nginx.yaml.erb b/templates/agent-conf.d/nginx.yaml.erb index a77f6a79..d5c1ee15 100644 --- a/templates/agent-conf.d/nginx.yaml.erb +++ b/templates/agent-conf.d/nginx.yaml.erb @@ -17,31 +17,7 @@ # - instance:bar <% - require 'yaml' - -if RUBY_VERSION < "1.9" -# Hack to avoid ruby 1.8 always reordering the hashes and -# changing this template resource at every run -# -# Taken from http://www.dzone.com/snippets/generating-yaml-hashes-sorted -class Hash - # Replacing the to_yaml function so it'll serialize hashes sorted (by their keys) - # - # Original function is in /usr/lib/ruby/1.8/yaml/rubytypes.rb - def to_yaml( opts = {} ) - YAML::quick_emit( object_id, opts ) do |out| - out.map( taguri, to_yaml_style ) do |map| - sort.each do |k, v| # <-- here's my addition (the 'sort') - map.add( k, v ) - end - end - end - end -end -end - - %> <%= {'init_config'=>nil, 'instances'=>@instances}.to_yaml %> diff --git a/templates/agent-conf.d/pgbouncer.yaml.erb b/templates/agent-conf.d/pgbouncer.yaml.erb index 1446bdc5..8d9e2d19 100644 --- a/templates/agent-conf.d/pgbouncer.yaml.erb +++ b/templates/agent-conf.d/pgbouncer.yaml.erb @@ -1,26 +1,5 @@ <% require 'yaml' - -if RUBY_VERSION < "1.9" -# Hack to avoid ruby 1.8 always reordering the hashes and -# changing this template resource at every run -# See https://github.com/DataDog/puppet-datadog-agent/issues/43 -# Taken from http://www.dzone.com/snippets/generating-yaml-hashes-sorted -class Hash - # Replacing the to_yaml function so it'll serialize hashes sorted (by their keys) - # - # Original function is in /usr/lib/ruby/1.8/yaml/rubytypes.rb - def to_yaml( opts = {} ) - YAML::quick_emit( object_id, opts ) do |out| - out.map( taguri, to_yaml_style ) do |map| - sort.each do |k, v| # <-- here's my addition (the 'sort') - map.add( k, v ) - end - end - end - end -end -end %> <%- if @pgbouncers.empty? -%> diff --git a/templates/agent-conf.d/process.yaml.erb b/templates/agent-conf.d/process.yaml.erb index 4bcd774f..349ac047 100644 --- a/templates/agent-conf.d/process.yaml.erb +++ b/templates/agent-conf.d/process.yaml.erb @@ -64,27 +64,6 @@ <% require 'yaml' - -if RUBY_VERSION < "1.9" -# Hack to avoid ruby 1.8 always reordering the hashes and -# changing this template resource at every run -# See https://github.com/DataDog/puppet-datadog-agent/issues/43 -# Taken from http://www.dzone.com/snippets/generating-yaml-hashes-sorted -class Hash - # Replacing the to_yaml function so it'll serialize hashes sorted (by their keys) - # - # Original function is in /usr/lib/ruby/1.8/yaml/rubytypes.rb - def to_yaml( opts = {} ) - YAML::quick_emit( object_id, opts ) do |out| - out.map( taguri, to_yaml_style ) do |map| - sort.each do |k, v| # <-- here's my addition (the 'sort') - map.add( k, v ) - end - end - end - end -end -end %> <%= {'init_config'=>nil, 'instances'=>@local_processes}.to_yaml %> diff --git a/templates/datadog.list.erb b/templates/datadog.list.erb deleted file mode 100644 index d37acf91..00000000 --- a/templates/datadog.list.erb +++ /dev/null @@ -1,5 +0,0 @@ -# -# Datadog dd-agent repository: managed by puppet -# - -deb <%= @location %> <%= @release %> <%= @repos %> diff --git a/templates/datadog6.yaml.erb b/templates/datadog6.yaml.erb index 611a69b1..44c16790 100644 --- a/templates/datadog6.yaml.erb +++ b/templates/datadog6.yaml.erb @@ -1,28 +1,7 @@ <% require 'yaml' - -if RUBY_VERSION < "1.9" -# Hack to avoid ruby 1.8 always reordering the hashes and -# changing this template resource at every run -# See https://github.com/DataDog/puppet-datadog-agent/issues/43 -# Taken from http://www.dzone.com/snippets/generating-yaml-hashes-sorted -class Hash - # Replacing the to_yaml function so it'll serialize hashes sorted (by their keys) - # - # Original function is in /usr/lib/ruby/1.8/yaml/rubytypes.rb - def to_yaml( opts = {} ) - YAML::quick_emit( object_id, opts ) do |out| - out.map( taguri, to_yaml_style ) do |map| - sort.each do |k, v| # <-- here's my addition (the 'sort') - map.add( k, v ) - end - end - end - end -end -end %> # # MANAGED BY PUPPET # -<%= @agent_config.to_yaml.gsub(/^\s{2}/, '') %> +<%= @agent_config.to_yaml %> diff --git a/templates/datadog_footer.conf.erb b/templates/datadog_footer.conf.erb index 6b6deaba..4acea97d 100644 --- a/templates/datadog_footer.conf.erb +++ b/templates/datadog_footer.conf.erb @@ -336,8 +336,8 @@ sd_jmx_enable: <%= @sd_jmx_enable %> consul_token: <%= @consul_token %> <% end -%> -<% if @process_agent_enabled -%> -process_agent_enabled: <%= @process_agent_enabled %> +<% if @process_enabled -%> +process_agent_enabled: <%= @process_enabled %> <% end -%> # ========================================================================== #