diff --git a/CHANGELOG.md b/CHANGELOG.md index b5f5f235..74ddbeb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,31 @@ Changes ======= +# 3.0.0 / 2019-12-18 + +### Overview + +**This release will install Agent 7.x by default.** + +Some config parameters prefixed with `agent6`/`agent5` have been renamed to +accomodate this change. Please read the [docs]() for more details and update +your configuration accordingly. + +Datadog Agent 7 uses Python 3 so if you were running any custom checks written +in Python, they must now be compatible with Python 3. If you were not running +any custom checks or if your custom checks are already compatible with Python 3, +then it is safe to upgrade. + +### Notes + +* [MAJOR] Agent 7 support. See [#588][]. + * Introduces `agent_major_version` parameter that replaces `agent5_enable`. + * Removes `agent6`/`agent5` prefixes in argument names. + * Unifies config for Agent 5/6 repos and removes the use of facter. +* [IMPROVEMENT] Removes uses of `validate_legacy`. +* [IMPROVEMENT] Keeps the group ownership of config files as `dd-agent`. +* [IMPROVEMENT] Removes `service_name` and `package_name` parameters. + # 2.10.0 / 2019-12-12 ### Notes @@ -166,7 +191,7 @@ Changes # 2.0.0 / 2018-02-27 ### Overview -This release is a mejor release, there are a some breaking changes. We have +This release is a major release, there are a some breaking changes. We have tried to keep the interface as similar as possible to what the community was already used to, but have had to make some changes and cleaned up some of the interfaces to some classes. Most notably the main `datadog_agent` @@ -691,6 +716,7 @@ Please read the [docs]() for more details. [#581]: https://github.com/DataDog/puppet-datadog-agent/issues/581 [#584]: https://github.com/DataDog/puppet-datadog-agent/issues/584 [#587]: https://github.com/DataDog/puppet-datadog-agent/issues/587 +[#588]: https://github.com/DataDog/puppet-datadog-agent/issues/588 [@Aramack]: https://github.com/Aramack [@BIAndrews]: https://github.com/BIAndrews [@ColinHebert]: https://github.com/ColinHebert diff --git a/README.md b/README.md index 77e3dd59..4d059464 100644 --- a/README.md +++ b/README.md @@ -6,29 +6,18 @@ Puppet & Datadog [![Puppet Forge Downloads](https://img.shields.io/puppetforge/dt/datadog/datadog_agent.svg)](https://forge.puppetlabs.com/datadog/datadog_agent) -Description ------------ +## Description A module to: -1. Install the [DataDog][1] Agent. +1. Install the [Datadog][1] Agent. 2. Send Puppet run reports to [Datadog][1]. -Releases --------- - -The current version of this Puppet module is compatible with Puppet >= 4.6.x. For users running on older versions of Puppet the legacy module, series 1.x, should support most use-cases. - -The majority of users should be able to use the current version, as the Puppet versions supported in the 1.x series of the module have been EOL'd. - -Some features might be back-ported if there's enough demand, but in general only maintenance is performed on the 1.x series of the module. Future feature development is performed on the newer Puppet module. - -Version 2.x ------------ - ## Requirements -For detailed information on compatibility, check the [module page][2] on the Puppet forge. +The current version of this Puppet module supports both Linux and Windows and is compatible with Puppet >= 4.6.x. + +For detailed information on compatibility, check the [module page on Puppet Forge][2]. ## Installation @@ -46,56 +35,24 @@ class{ 'datadog_agent': } ``` -### Upgrade from the previous module version 1.x - -Most of the manifests are backward compatible. However, there are important changes to the main manifest: - -- By default Datadog Agent 6.x is installed. - - To use Agent 5.x in your nodes set 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. -- APM Tracing and Process Agents are now opt-in options and are disabled by default. - - The main `datadog_agent` class has parameters to enable and configure the Agents easily. -- Increased granularity for apt/yum repo configuration. -- New location for Datadog Puppet reporting configuration. +### Upgrade from the previous module version 2.x - -Version 1.x ------------ - -## Requirements - -Puppet >=2.7.x and <=4.2.x. For detailed information on compatibility, check the [module page][2] 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 easier for maintenance. - -* Delete the Datadog module `rm -r /etc/puppet/modules/datadog` -* 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` +- By default Datadog Agent 7.x is installed. To use an earlier Agent version change the setting `agent_major_version`. +- `agent5_enable` is no longer used, as it has been replaced by `agent_major_version`. +- `agent6_extra_options` has been renamed to `agent_extra_options` since it now applies to both Agent version 6 and 7. +- `agent6_log_file` has been renamed to `agent_log_file` since it now applies to both Agent version 6 and 7. +- `agent5_repo_uri` and `agent6_repo_uri` become `agent_repo_uri` for all Agent versions. +- `conf_dir` and `conf6_dir` become `conf_dir` for all Agent versions. +- The repository file created on Linux is now named `datadog` for all agent versions instead of `datadog5`/`datadog6`. Usage ----- -The following instructions are for both Puppet module versions (1.x, 2.x). - -Note: 2.x installs Agent v6 by default, whereas 1.x defaults to Agent v5. - -Once the `datadog_agent` module is installed on your `puppetserver`/`puppetmaster`, follow these configuration steps: +Once the `datadog_agent` module is installed on your `puppetserver`/`puppetmaster` (or on a masterless host), follow these configuration steps: -1. Update the default class parameters with your [API key][3]. +1. Find your Datadog [API key][3]. -2. Specify the module on any nodes you wish to install the DataDog Agent. +2. Specify the module on any nodes you wish to install the Datadog Agent. ``` include datadog_agent @@ -118,13 +75,8 @@ Once the `datadog_agent` module is installed on your `puppetserver`/`puppetmaste } ``` - - To support reporting, your Puppet master needs the [dogapi][4] gem installed. To install, either run the Puppet Agent on your master with this configuration or install it manually with `gem`. You might need to restart your `puppetserver` service for the freshly installed `dogapi-rb` gem to be picked up. - - On version 2.x, `puppetserver_gem` is defined as a module dependency, it is installed automatically when the module is installed. - - On version 1.x: - - If you are 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` does *not* work. - - You may install `dogapi-rb` with `gem` as the system-level Ruby is used. - - The gem provider is configurable by setting it to `puppetserver_gem` (set by default on PE/POSS (>=3.7.0)) or `gem` if on older versions of Puppet. - - For users running puppet in standalone/masterless mode you will need to set the `puppet_gem_provider` to `puppet_gem` (or `gem` depending on versions) to ensure the `dogapi-rb` is available. + - To support reporting, your Puppet master needs the [dogapi][4] gem installed. To install, either run the Puppet Agent on your master with this configuration or install it manually with `gem`. You might need to restart your `puppetserver` service for the freshly installed `dogapi` gem to be picked up. + - `puppetserver_gem` is defined as a module dependency, it is installed automatically when the module is installed. 3. Include any other integrations you want the agent to use, for example: @@ -166,7 +118,7 @@ The field `ensure` can be either `present` (default) or `absent`, the later bein Reporting --------- -Ensure `dogapi-rb` is available on your system as explained earlier. +Ensure the `dogapi` gem is available on your system as explained earlier. 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 send a run report after each check-in back to the master. @@ -265,7 +217,7 @@ Run Puppet Agent ---------------- ``` -sudo systemctl /etc/init.d/puppetmaster restart +sudo systemctl restart puppetserver sudo puppet agent --onetime --no-daemonize --no-splay --verbose ``` @@ -306,18 +258,17 @@ datadog_agent::tags: These variables can be set in the `datadog_agent` class to control settings in the Agent: -#### 2.x - | variable name | description | |-----------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `agent_major_version` | The version of the Agent to install: either 5, 6 or 7 (default: 7). | +| `agent_version` | Lets you pin a specific minor version of the agent to install, eg: `1:7.16.0-1`. Leave empty to install the latest version (not recommended). | | `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. | -| `datadog_site` | The Datadog site to report to. Defaults to `datadoghq.com`, set to `datadoghq.eu` to report to the EU site. Supported since v2.4.0 of the module, and only with Agent v6+ | -| `dd_url` | The Datadog intake server URL. You are unlikely to need to change this. Overrides `datadog_site` | +| `datadog_site` | The Datadog site to report to. Defaults to `datadoghq.com`, set to `datadoghq.eu` to report to the EU site (Agent versions 6 and 7 only). | +| `dd_url` | The Datadog intake server URL. You are unlikely to need to change this. Overrides `datadog_site` | | `host` | Overrides the node's host name. | | `local_tags` | An array of strings that are set as tags for the node. | | `non_local_traffic` | Set this to allow other nodes to relay their traffic through this one. | -| `agent5_enable` | A boolean to install Agent v5 and override the Agent v6 default. | | `apm_enabled` | A boolean to enable the APM Agent (defaults to false). | | `apm_analyzed_spans` | A hash to add APM events for the Trace Search & Analytics tool. (defaults to undef). For example: `{ 'app\|rails.request' => 1, 'service-name\|operation-name' => 0.8 }` | | `process_enabled` | A boolean to enable the process agent (defaults to false). | @@ -325,31 +276,14 @@ These variables can be set in the `datadog_agent` class to control settings in t | `custom_sensitive_words` | An array to add more words beyond the default ones used by the scrubbing feature (defaults to []). | | `logs_enabled` | A boolean to enable the logs agent (defaults to false). | | `container_collect_all` | A boolean to enable logs collection for all containers. | -| `agent6_extra_options` | A hash to provide additional configuration options to Agent v6. | +| `agent_extra_options` | A hash to provide additional configuration options (Agent versions 6 and 7 only). | | `hostname_extraction_regex` | A regex used to extract the hostname captured group to report the run in Datadog instead of reporting the Puppet nodename, for example:
`'^(?.*\.datadoghq\.com)(\.i-\w{8}\..*)?$'` | ##### Notes: -- `agent6_extra_options` is used to provide a fine grain control of additional Agent v6 config options. A deep merge is performed that may override options provided in the `datadog_agent` class parameters. +- `agent_extra_options` is used to provide a fine grain control of additional Agent v6/v7 config options. A deep merge is performed that may override options provided in the `datadog_agent` class parameters. - `hostname_extraction_regex` is useful when the Puppet module and the Datadog Agent are reporting different host names for the same host in the infrastructure list. -#### 1.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` | The Datadog intake server URL. You are unlikely to need to change this. | -| `host` | Overrides the node's host name. | -| `local_tags` | An array of strings that are set as tags for the node. | -| `non_local_traffic` | Set this to allow other nodes to relay their traffic through this one. | -| `agent6_enable` | A boolean to install Agent v6 and override the Agent v5 default. | - -### Proxy Settings - -To connect to the Internet through a proxy, set `proxy_host`, `proxy_port`, `proxy_user` and `proxy_password`. - - Module Development and Testing ============================== @@ -388,4 +322,3 @@ pre-commit install [4]: https://github.com/DataDog/dogapi-rb [5]: https://app.datadoghq.com/account/settings#integrations [6]: https://app.datadoghq.com/event/stream - diff --git a/lib/facter/agent_repo.rb b/lib/facter/agent_repo.rb deleted file mode 100644 index ec14eb92..00000000 --- a/lib/facter/agent_repo.rb +++ /dev/null @@ -1,31 +0,0 @@ -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 and !File.zero? yumpath - end -end - -Facter.add('yum_datadog_legacy_repo') do - setcode do - yumpath = '/etc/yum.repos.d/datadog.repo' - File.exist? yumpath and !File.zero? yumpath - end -end diff --git a/manifests/init.pp b/manifests/init.pp index 7c1109fd..83e6a5f5 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -68,15 +68,7 @@ # statsd metrics to another host. # $manage_repo # Boolean to indicate whether this module should attempt to manage -# the package repo. Default true. -# $proxy_host -# Set value of 'proxy_host' variable. Default is blank. -# $proxy_port -# Set value of 'proxy_port' variable. Default is blank. -# $proxy_user -# Set value of 'proxy_user' variable. Default is blank. -# $proxy_password -# Set value of 'proxy_password' variable. Default is blank. +# the package repo. Only for RPM-based distros. Default true. # $graphite_listen_port # Set graphite listener port # $extra_template @@ -156,8 +148,8 @@ # $custom_emitters # Specifies a comma seperated list of non standard emitters to be used # String. Default: empty -# $agent6_log_file -# Specifies the log file location for the agent6 +# $agent_log_file +# Specifies the log file location (Agent 6 and 7 only). # String. Default: empty # $collector_log_file # Specifies the log file location for the collector system @@ -204,10 +196,15 @@ # $cmd_port # The port on which the IPC api listens # Integer. Default: 5001 -# -# Actions: -# -# Requires: +# $agent_repo_uri +# Where to download the agent from. When undef, it uses the following defaults: +# APT: https://apt.datadoghq.com/ +# RPM: https://yum.datadoghq.com/stable/7/x86_64/ (with matching agent version and architecture) +# Windows: https://https://s3.amazonaws.com/ddagent-windows-stable/ +# String. Default: undef +# $apt_release +# The distribution channel to be used for the APT repo. Eg: 'stable' or 'beta'. +# String. Default: stable # # Sample Usage: # @@ -224,107 +221,119 @@ # # class datadog_agent( - $dd_url = '', - $datadog_site = $datadog_agent::params::datadog_site, - $host = '', - $api_key = 'your_API_key', - $collect_ec2_tags = false, - $collect_gce_tags = false, - $collect_instance_metadata = true, - $tags = [], + String $dd_url = '', + String $datadog_site = $datadog_agent::params::datadog_site, + String $host = '', + String $api_key = 'your_API_key', + Boolean $collect_ec2_tags = false, + Boolean $collect_gce_tags = false, + Boolean $collect_instance_metadata = true, + Array $tags = [], $integrations = {}, $hiera_integrations = false, - $hiera_tags = false, - $facts_to_tags = [], - $puppet_run_reports = false, - $puppetmaster_user = $settings::user, + Boolean $hiera_tags = false, + Array $facts_to_tags = [], + Boolean $puppet_run_reports = false, + String $puppetmaster_user = $settings::user, String $puppet_gem_provider = $datadog_agent::params::gem_provider, - $non_local_traffic = false, - $dogstreams = [], - $log_level = 'info', - $log_to_syslog = true, + Boolean $non_local_traffic = false, + Array $dogstreams = [], + String $log_level = 'info', + Boolean $log_to_syslog = true, $service_ensure = 'running', $service_enable = true, - $manage_repo = true, + Boolean $manage_repo = true, $hostname_extraction_regex = undef, - $hostname_fqdn = false, + Boolean $hostname_fqdn = false, $dogstatsd_port = 8125, $dogstatsd_socket = '', - $statsd_forward_host = '', + String $statsd_forward_host = '', $statsd_forward_port = '', - $statsd_histogram_percentiles = '0.95', + String $statsd_histogram_percentiles = '0.95', Optional[String] $proxy_host = undef, Optional[Variant[Integer, Pattern[/^\d*$/]]] $proxy_port = undef, Optional[String] $proxy_user = undef, Optional[String] $proxy_password = undef, $graphite_listen_port = '', - $extra_template = '', - $ganglia_host = '', + String $extra_template = '', + String $ganglia_host = '', $ganglia_port = 8651, - $skip_ssl_validation = false, - $skip_apt_key_trusting = false, - $use_curl_http_client = false, - $recent_point_threshold = '', + Boolean $skip_ssl_validation = false, + Boolean $skip_apt_key_trusting = false, + Boolean $use_curl_http_client = false, + String $recent_point_threshold = '', $listen_port = '', Optional[String] $additional_checksd = undef, - $bind_host = '', - $use_pup = false, + String $bind_host = '', + Boolean $use_pup = false, $pup_port = '', - $pup_interface = '', - $pup_url = '', - $use_dogstatsd = true, - $dogstatsd_target = '', - $dogstatsd_interval = '', - $dogstatsd_normalize = true, - $device_blacklist_re = '', - $custom_emitters = '', - $agent6_log_file = $datadog_agent::params::agent6_log_file, - $collector_log_file = '', - $forwarder_log_file = '', - $dogstatsd_log_file = '', - $pup_log_file = '', - $syslog_host = '', + String $pup_interface = '', + String $pup_url = '', + Boolean $use_dogstatsd = true, + String $dogstatsd_target = '', + String $dogstatsd_interval = '', + Boolean $dogstatsd_normalize = true, + String $device_blacklist_re = '', + String $custom_emitters = '', + String $agent_log_file = $datadog_agent::params::agent_log_file, + String $collector_log_file = '', + String $forwarder_log_file = '', + String $dogstatsd_log_file = '', + String $pup_log_file = '', + String $syslog_host = '', $syslog_port = '', - $service_discovery_backend = '', - $sd_config_backend = '', - $sd_backend_host = '', - $sd_backend_port = 0, - $sd_template_dir = '', - $sd_jmx_enable = false, - $consul_token = '', - $cmd_port = 5001, - $agent5_enable = $datadog_agent::params::agent5_enable, - $conf_dir = $datadog_agent::params::conf5_dir, - $conf6_dir = $datadog_agent::params::conf6_dir, - $conf_dir_purge = $datadog_agent::params::conf_dir_purge, - $service_name = $datadog_agent::params::service_name, - $package_name = $datadog_agent::params::package_name, + String $service_discovery_backend = '', + String $sd_config_backend = '', + String $sd_backend_host = '', + Integer $sd_backend_port = 0, + String $sd_template_dir = '', + Boolean $sd_jmx_enable = false, + String $consul_token = '', + Integer $cmd_port = 5001, + Optional[Integer] $agent_major_version = undef, + Optional[String] $conf_dir = undef, + Boolean $conf_dir_purge = $datadog_agent::params::conf_dir_purge, $dd_user = $datadog_agent::params::dd_user, $dd_group = $datadog_agent::params::dd_group, $dd_groups = $datadog_agent::params::dd_groups, - $apm_enabled = $datadog_agent::params::apm_default_enabled, - $apm_env = 'none', - $apm_non_local_traffic = false, + Boolean $apm_enabled = $datadog_agent::params::apm_default_enabled, + String $apm_env = 'none', + Boolean $apm_non_local_traffic = false, Optional[Hash[String, Float[0, 1]]] $apm_analyzed_spans = undef, - $process_enabled = $datadog_agent::params::process_default_enabled, - $scrub_args = $datadog_agent::params::process_default_scrub_args, - $custom_sensitive_words = $datadog_agent::params::process_default_custom_words, - $logs_enabled = $datadog_agent::params::logs_enabled, + Boolean $process_enabled = $datadog_agent::params::process_default_enabled, + Boolean $scrub_args = $datadog_agent::params::process_default_scrub_args, + Array $custom_sensitive_words = $datadog_agent::params::process_default_custom_words, + Boolean $logs_enabled = $datadog_agent::params::logs_enabled, $logs_open_files_limit = $datadog_agent::params::logs_open_files_limit, - $container_collect_all = $datadog_agent::params::container_collect_all, - Hash[String[1], Data] $agent6_extra_options = {}, - $agent5_repo_uri = $datadog_agent::params::agent5_default_repo, - $agent6_repo_uri = $datadog_agent::params::agent6_default_repo, + Boolean $container_collect_all = $datadog_agent::params::container_collect_all, + Hash[String[1], Data] $agent_extra_options = {}, + Optional[String] $agent_repo_uri = undef, Optional[Boolean] $use_apt_backup_keyserver = $datadog_agent::params::use_apt_backup_keyserver, - $apt_backup_keyserver = $datadog_agent::params::apt_backup_keyserver, - $apt_keyserver = $datadog_agent::params::apt_keyserver, - $apt_release = $datadog_agent::params::apt_default_release, + String $apt_backup_keyserver = $datadog_agent::params::apt_backup_keyserver, + String $apt_keyserver = $datadog_agent::params::apt_keyserver, + String $apt_release = $datadog_agent::params::apt_default_release, String $win_msi_location = 'C:/Windows/temp', # Temporary directory where the msi file is downloaded, must exist Enum['present', 'absent'] $win_ensure = 'present', #TODO: Implement uninstall also for apt and rpm install methods Optional[String] $service_provider = undef, Optional[String] $agent_version = $datadog_agent::params::agent_version, ) inherits datadog_agent::params { + #In this regex, version '1:6.15.0~rc.1-1' would match as $1='1:', $2='6', $3='15', $4='0', $5='~rc.1', $6='1' + if $agent_version != 'latest' and $agent_version =~ /([0-9]+:)?([0-9]+)\.([0-9]+)\.([0-9]+)((?:~|-)[^0-9\s-]+[^-\s]*)?(?:-([0-9]+))?/ { + $_agent_major_version = 0 + $2 # Cast to integer + if $agent_major_version != undef and $agent_major_version != $_agent_major_version { + fail('Provided and deduced agent_major_version don\'t match') + } + } elsif $agent_major_version != undef { + $_agent_major_version = $agent_major_version + } else { + $_agent_major_version = $datadog_agent::params::default_agent_major_version + } + + if $_agent_major_version != 5 and $_agent_major_version != 6 and $_agent_major_version != 7 { + fail('agent_major_version must be either 5, 6 or 7') + } + # Allow ports to be passed as integers or strings. # lint:ignore:only_variable_string $_dogstatsd_port = "${dogstatsd_port}" @@ -335,75 +344,22 @@ $_syslog_port = "${syslog_port}" # lint:endignore - validate_legacy(String, 'validate_string', $dd_url) - validate_legacy(String, 'validate_string', $datadog_site) - validate_legacy(String, 'validate_string', $host) - validate_legacy(Boolean, 'validate_bool', $hostname_fqdn) - validate_legacy(String, 'validate_string', $api_key) - validate_legacy(Array, 'validate_array', $tags) - validate_legacy(Boolean, 'validate_bool', $hiera_tags) - validate_legacy(Array, 'validate_array', $dogstreams) - validate_legacy(Array, 'validate_array', $facts_to_tags) - validate_legacy(Boolean, 'validate_bool', $puppet_run_reports) - validate_legacy(String, 'validate_string', $puppetmaster_user) - validate_legacy(Boolean, 'validate_bool', $non_local_traffic) - validate_legacy(Boolean, 'validate_bool', $log_to_syslog) - validate_legacy(Boolean, 'validate_bool', $manage_repo) - validate_legacy(String, 'validate_string', $log_level) validate_legacy(String, 'validate_re', $_dogstatsd_port, '^\d*$') - validate_legacy(String, 'validate_string', $statsd_histogram_percentiles) validate_legacy(String, 'validate_re', $_statsd_forward_port, '^\d*$') validate_legacy(String, 'validate_re', $_graphite_listen_port, '^\d*$') - validate_legacy(String, 'validate_string', $extra_template) - validate_legacy(String, 'validate_string', $ganglia_host) - validate_legacy(Integer, 'validate_integer', $ganglia_port) - validate_legacy(Boolean, 'validate_bool', $skip_ssl_validation) - validate_legacy(Boolean, 'validate_bool', $skip_apt_key_trusting) - validate_legacy(Boolean, 'validate_bool', $use_curl_http_client) - validate_legacy(Boolean, 'validate_bool', $collect_ec2_tags) - validate_legacy(Boolean, 'validate_bool', $collect_gce_tags) - validate_legacy(Boolean, 'validate_bool', $collect_instance_metadata) - validate_legacy(String, 'validate_string', $recent_point_threshold) validate_legacy(String, 'validate_re', $_listen_port, '^\d*$') - validate_legacy(String, 'validate_string', $bind_host) - validate_legacy(Boolean, 'validate_bool', $use_pup) validate_legacy(String, 'validate_re', $_pup_port, '^\d*$') - validate_legacy(String, 'validate_string', $pup_interface) - validate_legacy(String, 'validate_string', $pup_url) - validate_legacy(Boolean, 'validate_bool', $use_dogstatsd) - validate_legacy(String, 'validate_string', $dogstatsd_target) - validate_legacy(String, 'validate_string', $dogstatsd_interval) - validate_legacy(Boolean, 'validate_bool', $dogstatsd_normalize) - validate_legacy(String, 'validate_string', $statsd_forward_host) - validate_legacy(String, 'validate_string', $device_blacklist_re) - validate_legacy(String, 'validate_string', $custom_emitters) - validate_legacy(String, 'validate_string', $agent6_log_file) - validate_legacy(String, 'validate_string', $collector_log_file) - validate_legacy(String, 'validate_string', $forwarder_log_file) - validate_legacy(String, 'validate_string', $dogstatsd_log_file) - validate_legacy(String, 'validate_string', $pup_log_file) - validate_legacy(String, 'validate_string', $syslog_host) validate_legacy(String, 'validate_re', $_syslog_port, '^\d*$') - validate_legacy(String, 'validate_string', $service_discovery_backend) - validate_legacy(String, 'validate_string', $sd_config_backend) - validate_legacy(String, 'validate_string', $sd_backend_host) - validate_legacy(Integer, 'validate_integer', $sd_backend_port) - validate_legacy(String, 'validate_string', $sd_template_dir) - validate_legacy(Boolean, 'validate_bool', $sd_jmx_enable) - validate_legacy(String, 'validate_string', $consul_token) - validate_legacy(Boolean, 'validate_bool', $apm_enabled) - validate_legacy(Boolean, 'validate_bool', $apm_non_local_traffic) - validate_legacy(Boolean, 'validate_bool', $agent5_enable) - validate_legacy(String, 'validate_string', $apm_env) - validate_legacy(Boolean, 'validate_bool', $process_enabled) - validate_legacy(Boolean, 'validate_bool', $scrub_args) - validate_legacy(Array, 'validate_array', $custom_sensitive_words) - validate_legacy(Boolean, 'validate_bool', $logs_enabled) - validate_legacy(Boolean, 'validate_bool', $container_collect_all) - validate_legacy(String, 'validate_string', $agent5_repo_uri) - validate_legacy(String, 'validate_string', $agent6_repo_uri) - validate_legacy(String, 'validate_string', $apt_release) - validate_legacy(Integer, 'validate_integer', $cmd_port) + + if $conf_dir == undef { + if $_agent_major_version == 5 { + $_conf_dir = $datadog_agent::params::legacy_conf_dir + } else { + $_conf_dir = $datadog_agent::params::conf_dir + } + } else { + $_conf_dir = $conf_dir + } if $hiera_tags { $local_tags = lookup({ 'name' => 'datadog_agent::tags', 'merge' => 'unique', 'default_value' => []}) @@ -437,63 +393,42 @@ case $::operatingsystem { 'Ubuntu','Debian' : { - if $agent5_enable { - class { 'datadog_agent::ubuntu::agent5': - agent_version => $agent_version, - service_ensure => $service_ensure, - service_enable => $service_enable, - service_provider => $service_provider, - location => $agent5_repo_uri, - release => $apt_release, - skip_apt_key_trusting => $skip_apt_key_trusting, - apt_keyserver => $_apt_keyserver, - } - } else { - class { 'datadog_agent::ubuntu::agent6': - agent_version => $agent_version, - service_ensure => $service_ensure, - service_enable => $service_enable, - service_provider => $service_provider, - location => $agent6_repo_uri, - release => $apt_release, - skip_apt_key_trusting => $skip_apt_key_trusting, - apt_keyserver => $_apt_keyserver, - } + class { 'datadog_agent::ubuntu': + agent_major_version => $_agent_major_version, + agent_version => $agent_version, + service_ensure => $service_ensure, + service_enable => $service_enable, + service_provider => $service_provider, + agent_repo_uri => $agent_repo_uri, + release => $apt_release, + skip_apt_key_trusting => $skip_apt_key_trusting, + apt_keyserver => $_apt_keyserver, } } 'RedHat','CentOS','Fedora','Amazon','Scientific','OracleLinux' : { - if $agent5_enable { - class { 'datadog_agent::redhat::agent5': - baseurl => $agent5_repo_uri, - manage_repo => $manage_repo, - agent_version => $agent_version, - service_ensure => $service_ensure, - service_enable => $service_enable, - service_provider => $service_provider, - } - } else { - class { 'datadog_agent::redhat::agent6': - baseurl => $agent6_repo_uri, - manage_repo => $manage_repo, - agent_version => $agent_version, - service_ensure => $service_ensure, - service_enable => $service_enable, - service_provider => $service_provider, - } + class { 'datadog_agent::redhat': + agent_major_version => $_agent_major_version, + agent_repo_uri => $agent_repo_uri, + manage_repo => $manage_repo, + agent_version => $agent_version, + service_ensure => $service_ensure, + service_enable => $service_enable, + service_provider => $service_provider, } } 'Windows' : { - class { 'datadog_agent::windows::agent6' : - baseurl => $agent6_repo_uri, - agent_version => $agent_version, - service_ensure => $service_ensure, - service_enable => $service_enable, - msi_location => $win_msi_location, - api_key => $api_key, - hostname => $host, - service_name => $service_name, - tags => $local_tags, - ensure => $win_ensure + class { 'datadog_agent::windows' : + agent_major_version => $_agent_major_version, + agent_repo_uri => $agent_repo_uri, + agent_version => $agent_version, + service_ensure => $service_ensure, + service_enable => $service_enable, + msi_location => $win_msi_location, + api_key => $api_key, + hostname => $host, + service_name => $service_name, + tags => $local_tags, + ensure => $win_ensure } if ($win_ensure == absent) { return() #Config files will remain unchanged on uninstall @@ -520,12 +455,16 @@ } } - if $agent5_enable { + if $_agent_major_version == 5 { if ($::operatingsystem == 'Windows') { fail('Installation of agent 5 with puppet is not supported on Windows') } + if !empty($agent_extra_options) { + notify { 'Setting agent_extra_options has no effect with Agent 5': } + } + file { '/etc/dd-agent': ensure => directory, owner => $dd_user, @@ -534,7 +473,7 @@ require => Package[$datadog_agent::params::package_name], } - file { $conf_dir: + file { $_conf_dir: ensure => directory, purge => $conf_dir_purge, recurse => true, @@ -603,20 +542,20 @@ order => '08', } } - } else { #Agent 6 + } else { #Agent 6/7 - # notify of broken params on agent6 + # notify of broken params on agent6/7 if !empty($proxy_host) { - notify { 'Setting proxy_host will have no effect on agent6 please use agent6_extra_options to set your proxy': } + notify { 'Setting proxy_host is only used with Agent 5. Please use agent_extra_options to set your proxy': } } if !empty($proxy_port) { - notify { 'Setting proxy_port will have no effect on agent6 please use agent6_extra_options to set your proxy': } + notify { 'Setting proxy_port is only used with Agent 5. Please use agent_extra_options to set your proxy': } } if !empty($proxy_user) { - notify { 'Setting proxy_user will have no effect on agent6 please use agent6_extra_options to set your proxy': } + notify { 'Setting proxy_user is only used with Agent 5. Please use agent_extra_options to set your proxy': } } if !empty($proxy_password) { - notify { 'Setting proxy_password will have no effect on agent6 please use agent6_extra_options to set your proxy': } + notify { 'Setting proxy_password is only used with Agent 5. Please use agent_extra_options to set your proxy': } } # lint:ignore:quoted_booleans @@ -693,13 +632,13 @@ $extra_config = deep_merge( $base_extra_config, $logs_base_config, - $agent6_extra_options, + $agent_extra_options, $apm_analyzed_span_config, $statsd_forward_config, $host_config, $additional_checksd_config) - file { $conf6_dir: + file { $_conf_dir: ensure => directory, purge => $conf_dir_purge, recurse => true, @@ -720,12 +659,12 @@ 'hostname_fqdn' => $hostname_fqdn, 'collect_ec2_tags' => $collect_ec2_tags, 'collect_gce_tags' => $collect_gce_tags, - 'confd_path' => $conf6_dir, + 'confd_path' => $_conf_dir, 'enable_metadata_collection' => $collect_instance_metadata, 'dogstatsd_port' => $dogstatsd_port, 'dogstatsd_socket' => $dogstatsd_socket, 'dogstatsd_non_local_traffic' => $non_local_traffic, - 'log_file' => $agent6_log_file, + 'log_file' => $agent_log_file, 'log_level' => $log_level, 'tags' => unique(flatten(union($_local_tags, $_facts_tags))), } @@ -741,9 +680,9 @@ file { 'C:/ProgramData/Datadog/datadog.yaml': owner => $dd_user, - group => 'S-1-5-32-544', #Administrators + group => $dd_group, mode => '0660', - content => template('datadog_agent/datadog6.yaml.erb'), + content => template('datadog_agent/datadog.yaml.erb'), notify => Service[$datadog_agent::params::service_name], require => File['C:/ProgramData/Datadog'], } @@ -752,9 +691,9 @@ file { '/etc/datadog-agent/datadog.yaml': owner => $dd_user, - group => 'dd-agent', + group => $dd_group, mode => '0640', - content => template('datadog_agent/datadog6.yaml.erb'), + content => template('datadog_agent/datadog.yaml.erb'), notify => Service[$datadog_agent::params::service_name], require => File['/etc/datadog-agent'], } diff --git a/manifests/integration.pp b/manifests/integration.pp index 0391ce33..932ab806 100644 --- a/manifests/integration.pp +++ b/manifests/integration.pp @@ -1,20 +1,15 @@ define datadog_agent::integration ( - $instances, - $init_config = undef, - $logs = undef, - $integration = $title, + Array $instances, + Optional[Hash] $init_config = undef, + Optional[Array] $logs = undef, + String $integration = $title, ){ include datadog_agent - validate_legacy(Array, 'validate_array', $instances) - validate_legacy(Optional[Hash], 'validate_hash', $init_config) - validate_legacy(Optional[Array], 'validate_array', $logs) - validate_legacy(String, 'validate_string', $integration) - - if !$::datadog_agent::agent5_enable { - $dst = "${datadog_agent::conf6_dir}/${integration}.d/conf.yaml" - file { "${datadog_agent::conf6_dir}/${integration}.d": + if $::datadog_agent::_agent_major_version > 5 { + $dst = "${datadog_agent::params::conf_dir}/${integration}.d/conf.yaml" + file { "${datadog_agent::params::conf_dir}/${integration}.d": ensure => directory, owner => $datadog_agent::dd_user, group => $datadog_agent::dd_group, @@ -22,7 +17,7 @@ before => File[$dst] } } else { - $dst = "${datadog_agent::conf5_dir}/${integration}.yaml" + $dst = "${datadog_agent::params::legacy_conf_dir}/${integration}.yaml" } file { $dst: @@ -31,7 +26,7 @@ group => $datadog_agent::dd_group, mode => $datadog_agent::params::permissions_file, content => to_instances_yaml($init_config, $instances, $logs), - notify => Service[$datadog_agent::service_name] + notify => Service[$datadog_agent::params::service_name] } } diff --git a/manifests/integrations/activemq_xml.pp b/manifests/integrations/activemq_xml.pp index db0d2b04..4a46b8bf 100644 --- a/manifests/integrations/activemq_xml.pp +++ b/manifests/integrations/activemq_xml.pp @@ -54,9 +54,9 @@ ) inherits datadog_agent::params { include datadog_agent - $legacy_dst = "${datadog_agent::conf5_dir}/activemq_xml.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/activemq_xml.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/activemq_xml.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/activemq_xml.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/integrations/apache.pp b/manifests/integrations/apache.pp index e273c426..247d57a0 100644 --- a/manifests/integrations/apache.pp +++ b/manifests/integrations/apache.pp @@ -27,21 +27,17 @@ # } # class datadog_agent::integrations::apache ( - $url = 'http://localhost/server-status?auto', - $username = undef, - $password = undef, - $tags = [], - $disable_ssl_validation = false + String $url = 'http://localhost/server-status?auto', + Optional[String] $username = undef, + Optional[String] $password = undef, + Array $tags = [], + Boolean $disable_ssl_validation = false ) inherits datadog_agent::params { include datadog_agent - validate_legacy('String', 'validate_string', $url) - validate_legacy('Array', 'validate_array', $tags) - validate_legacy('Boolean', 'validate_bool', $disable_ssl_validation) - - $legacy_dst = "${datadog_agent::conf5_dir}/apache.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/apache.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/apache.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/apache.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/integrations/cacti.pp b/manifests/integrations/cacti.pp index 0b16d31e..d46f172c 100644 --- a/manifests/integrations/cacti.pp +++ b/manifests/integrations/cacti.pp @@ -20,9 +20,9 @@ ) inherits datadog_agent::params { include datadog_agent - $legacy_dst = "${datadog_agent::conf5_dir}/cacti.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/cacti.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/cacti.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/cacti.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/integrations/cassandra.pp b/manifests/integrations/cassandra.pp index a1819f43..b82c5fd0 100644 --- a/manifests/integrations/cassandra.pp +++ b/manifests/integrations/cassandra.pp @@ -26,19 +26,17 @@ # # class datadog_agent::integrations::cassandra( - $host = 'localhost', - $port = 7199, - $user = undef, - $password = undef, - $tags = {}, + String $host = 'localhost', + Integer $port = 7199, + Optional[String] $user = undef, + Optional[String] $password = undef, + Optional[Hash] $tags = {}, ) inherits datadog_agent::params { require ::datadog_agent - validate_legacy(Optional[Hash], 'validate_hash', $tags) - - $legacy_dst = "${datadog_agent::conf5_dir}/cassandra.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/cassandra.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/cassandra.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/cassandra.d" file { $legacy_dst: ensure => 'absent' diff --git a/manifests/integrations/ceph.pp b/manifests/integrations/ceph.pp index c1387cea..80d19e63 100644 --- a/manifests/integrations/ceph.pp +++ b/manifests/integrations/ceph.pp @@ -19,16 +19,13 @@ ) inherits datadog_agent::params { include datadog_agent - validate_legacy('Array', 'validate_array', $tags) - validate_legacy('String', 'validate_string', $ceph_cmd) - file { '/etc/sudoers.d/datadog_ceph': content => "# This file is required for dd ceph \ndd-agent ALL=(ALL) NOPASSWD:/usr/bin/ceph\n" } - $legacy_dst = "${datadog_agent::conf5_dir}/ceph.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/ceph.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/ceph.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/ceph.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/integrations/consul.pp b/manifests/integrations/consul.pp index 754fd220..1c5d38c0 100644 --- a/manifests/integrations/consul.pp +++ b/manifests/integrations/consul.pp @@ -35,14 +35,9 @@ ) inherits datadog_agent::params { include datadog_agent - validate_legacy('String', 'validate_string', $url) - validate_legacy('Boolean', 'validate_bool', $catalog_checks) - validate_legacy('Boolean', 'validate_bool', $new_leader_checks) - validate_legacy('Optional[Array]', 'validate_array', $service_whitelist) - - $legacy_dst = "${datadog_agent::conf5_dir}/consul.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/consul.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/consul.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/consul.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/integrations/directory.pp b/manifests/integrations/directory.pp index 675cb22c..c6338f3d 100644 --- a/manifests/integrations/directory.pp +++ b/manifests/integrations/directory.pp @@ -67,11 +67,6 @@ ) inherits datadog_agent::params { include datadog_agent - validate_legacy(String, 'validate_string', $directory) - validate_legacy(Boolean, 'validate_bool', $filegauges) - validate_legacy(Boolean, 'validate_bool', $recursive) - validate_legacy(Boolean, 'validate_bool', $countonly) - if !$instances and $directory == '' { fail('bad directory argument and no instances hash provided') } @@ -93,9 +88,9 @@ $_instances = $instances } - $legacy_dst = "${datadog_agent::conf5_dir}/directory.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/directory.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/directory.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/directory.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/integrations/disk.pp b/manifests/integrations/disk.pp index c232bb7a..16315527 100644 --- a/manifests/integrations/disk.pp +++ b/manifests/integrations/disk.pp @@ -69,9 +69,9 @@ fail('error during compilation') } - $legacy_dst = "${datadog_agent::conf5_dir}/disk.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/disk.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/disk.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/disk.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/integrations/dns_check.pp b/manifests/integrations/dns_check.pp index 5c0f0412..fbe43848 100644 --- a/manifests/integrations/dns_check.pp +++ b/manifests/integrations/dns_check.pp @@ -35,11 +35,9 @@ ) inherits datadog_agent::params { include datadog_agent - validate_legacy('Array', 'validate_array', $checks) - - $legacy_dst = "${datadog_agent::conf5_dir}/dns_check.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/dns_check.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/dns_check.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/dns_check.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/integrations/docker_daemon.pp b/manifests/integrations/docker_daemon.pp index 96e1c003..30ef4683 100644 --- a/manifests/integrations/docker_daemon.pp +++ b/manifests/integrations/docker_daemon.pp @@ -64,8 +64,8 @@ notify => Service[$datadog_agent::params::service_name] } - if !$::datadog_agent::agent5_enable { - $legacy_dir = "${datadog_agent::conf6_dir}/docker_daemon.d" + if $::datadog_agent::_agent_major_version > 5 { + $legacy_dir = "${datadog_agent::params::conf_dir}/docker_daemon.d" file { $legacy_dir: ensure => directory, @@ -77,15 +77,15 @@ } $legacy_conf = "${legacy_dir}/conf.yaml" } else { - $legacy_conf = "${datadog_agent::conf5_dir}/docker.yaml" + $legacy_conf = "${datadog_agent::params::legacy_conf_dir}/docker.yaml" } file { $legacy_conf: ensure => 'absent' } - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/docker.d" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/docker.d" file { $dst_dir: ensure => directory, @@ -97,7 +97,7 @@ } $dst = "${dst_dir}/conf.yaml" } else { - $dst = "${datadog_agent::conf5_dir}/docker_daemon.yaml" + $dst = "${datadog_agent::params::legacy_conf_dir}/docker_daemon.yaml" } file { $dst: diff --git a/manifests/integrations/elasticsearch.pp b/manifests/integrations/elasticsearch.pp index 23d93476..0101ce29 100644 --- a/manifests/integrations/elasticsearch.pp +++ b/manifests/integrations/elasticsearch.pp @@ -24,37 +24,26 @@ # } # class datadog_agent::integrations::elasticsearch( - $cluster_stats = false, + Boolean $cluster_stats = false, Optional[String] $password = undef, - $pending_task_stats = true, - $pshard_stats = false, + Boolean$pending_task_stats = true, + Boolean $pshard_stats = false, Optional[String] $ssl_cert = undef, Optional[String] $ssl_key = undef, Variant[Boolean, String] $ssl_verify = true, - $tags = [], - $url = 'http://localhost:9200', + Array $tags = [], + String $url = 'http://localhost:9200', Optional[String] $username = undef, - $instances = undef + Optional[Array] $instances = undef ) inherits datadog_agent::params { include datadog_agent - validate_legacy(Array, 'validate_array', $tags) # $ssl_verify can be a bool or a string # https://github.com/DataDog/dd-agent/blob/master/checks.d/elastic.py#L454-L455 if validate_legacy('Variant[Boolean, String]', 'is_string', $ssl_verify){ validate_absolute_path($ssl_verify) } - - validate_legacy('Boolean', 'validate_bool', $cluster_stats) - validate_legacy('Boolean', 'validate_bool', $pending_task_stats) - validate_legacy('Boolean', 'validate_bool', $pshard_stats) - - validate_legacy('Optional[String]', 'validate_string', $password) - validate_legacy('Optional[String]', 'validate_string', $ssl_cert) - validate_legacy('Optional[String]', 'validate_string', $ssl_key) - validate_legacy('Optional[String]', 'validate_string', $username) - if !$instances and $url { $_instances = [{ 'cluster_stats' => $cluster_stats, @@ -74,9 +63,9 @@ $_instances = $instances } - $legacy_dst = "${datadog_agent::conf5_dir}/elastic.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/elastic.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/elastic.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/elastic.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/integrations/fluentd.pp b/manifests/integrations/fluentd.pp index acbee072..89e683d9 100644 --- a/manifests/integrations/fluentd.pp +++ b/manifests/integrations/fluentd.pp @@ -23,11 +23,9 @@ ) inherits datadog_agent::params { include ::datadog_agent - validate_legacy('Optional[Array]', 'validate_array', $plugin_ids) - - $legacy_dst = "${datadog_agent::conf5_dir}/fluentd.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/fluentd.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/fluentd.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/fluentd.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/integrations/generic.pp b/manifests/integrations/generic.pp index 7b284e34..3835b8d7 100644 --- a/manifests/integrations/generic.pp +++ b/manifests/integrations/generic.pp @@ -22,12 +22,9 @@ Optional[String] $integration_contents = undef, ) inherits datadog_agent::params { - validate_legacy('Optional[String]', 'validate_string', $integration_name) - validate_legacy('Optional[String]', 'validate_string', $integration_contents) - - $legacy_dst = "${datadog_agent::conf5_dir}/${integration_name}.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/${integration_name}.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/${integration_name}.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/${integration_name}.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/integrations/haproxy.pp b/manifests/integrations/haproxy.pp index 65f0e484..fa1d6bfe 100644 --- a/manifests/integrations/haproxy.pp +++ b/manifests/integrations/haproxy.pp @@ -17,10 +17,10 @@ # } # class datadog_agent::integrations::haproxy( - $creds = {}, - $url = "http://${::ipaddress}:8080", - $options = {}, - $instances = undef, + $creds = {}, + $url = "http://${::ipaddress}:8080", + $options = {}, + Optional[Array] $instances = undef ) inherits datadog_agent::params { include datadog_agent @@ -36,9 +36,9 @@ $_instances = $instances } - $legacy_dst = "${datadog_agent::conf5_dir}/haproxy.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/haproxy.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/haproxy.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/haproxy.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/integrations/http_check.pp b/manifests/integrations/http_check.pp index 05c3dcaa..73189608 100644 --- a/manifests/integrations/http_check.pp +++ b/manifests/integrations/http_check.pp @@ -189,7 +189,7 @@ $allow_redirects = true, $tags = [], $contact = [], - $instances = undef, + Optional[Array] $instances = undef, $ca_certs = undef, ) inherits datadog_agent::params { include datadog_agent @@ -229,9 +229,9 @@ $_instances = $instances } - $legacy_dst = "${datadog_agent::conf5_dir}/http_check.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/http_check.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/http_check.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/http_check.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/integrations/jenkins.pp b/manifests/integrations/jenkins.pp index f180fd52..708aaf59 100644 --- a/manifests/integrations/jenkins.pp +++ b/manifests/integrations/jenkins.pp @@ -18,9 +18,9 @@ ) inherits datadog_agent::params { include datadog_agent - $legacy_dst = "${datadog_agent::conf5_dir}/jenkins.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/jenkins.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/jenkins.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/jenkins.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/integrations/jmx.pp b/manifests/integrations/jmx.pp index eca96f3a..e2246c1e 100644 --- a/manifests/integrations/jmx.pp +++ b/manifests/integrations/jmx.pp @@ -67,9 +67,9 @@ ) inherits datadog_agent::params { include datadog_agent - $legacy_dst = "${datadog_agent::conf5_dir}/jmx.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/jmx.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/jmx.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/jmx.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/integrations/kafka.pp b/manifests/integrations/kafka.pp index 3624fdf8..fae25ca7 100644 --- a/manifests/integrations/kafka.pp +++ b/manifests/integrations/kafka.pp @@ -86,9 +86,9 @@ $servers = $instances } - $legacy_dst = "${datadog_agent::conf5_dir}/kafka.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/kafka.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/kafka.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/kafka.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/integrations/kong.pp b/manifests/integrations/kong.pp index 9172b433..b90f244b 100644 --- a/manifests/integrations/kong.pp +++ b/manifests/integrations/kong.pp @@ -34,9 +34,9 @@ ) inherits datadog_agent::params { include datadog_agent - $legacy_dst = "${datadog_agent::conf5_dir}/kong.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/kong.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/kong.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/kong.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/integrations/kubernetes.pp b/manifests/integrations/kubernetes.pp index 27966b2e..e43d871b 100644 --- a/manifests/integrations/kubernetes.pp +++ b/manifests/integrations/kubernetes.pp @@ -32,9 +32,9 @@ ) inherits datadog_agent::params { include datadog_agent - $legacy_dst = "${datadog_agent::conf5_dir}/kubernetes.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/kubernetes.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/kubernetes.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/kubernetes.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/integrations/kubernetes_state.pp b/manifests/integrations/kubernetes_state.pp index d6653906..bdf1da11 100644 --- a/manifests/integrations/kubernetes_state.pp +++ b/manifests/integrations/kubernetes_state.pp @@ -24,9 +24,9 @@ ) inherits datadog_agent::params { include datadog_agent - $legacy_dst = "${datadog_agent::conf5_dir}/kubernetes_state.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/kubernetes_state.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/kubernetes_state.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/kubernetes_state.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/integrations/linux_proc_extras.pp b/manifests/integrations/linux_proc_extras.pp index 92ba5c49..9531bea6 100644 --- a/manifests/integrations/linux_proc_extras.pp +++ b/manifests/integrations/linux_proc_extras.pp @@ -18,9 +18,9 @@ ) inherits datadog_agent::params { include datadog_agent - $legacy_dst = "${datadog_agent::conf5_dir}/linux_proc_extras.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/linux_proc_extras.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/linux_proc_extras.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/linux_proc_extras.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/integrations/logs.pp b/manifests/integrations/logs.pp index d78167b1..7e36b53a 100644 --- a/manifests/integrations/logs.pp +++ b/manifests/integrations/logs.pp @@ -39,11 +39,10 @@ class datadog_agent::integrations::logs( Array $logs = [], ) inherits datadog_agent::params { - unless $::datadog_agent::agent5_enable { + unless $::datadog_agent::_agent_major_version == 5 { include datadog_agent - validate_legacy('Array', 'validate_array', $logs) - file { "${datadog_agent::conf6_dir}/logs.yaml": + file { "${datadog_agent::params::conf_dir}/logs.yaml": ensure => file, owner => $datadog_agent::params::dd_user, group => $datadog_agent::params::dd_group, diff --git a/manifests/integrations/marathon.pp b/manifests/integrations/marathon.pp index 54f54aaf..dc79a1be 100644 --- a/manifests/integrations/marathon.pp +++ b/manifests/integrations/marathon.pp @@ -18,9 +18,9 @@ ) inherits datadog_agent::params { include datadog_agent - $legacy_dst = "${datadog_agent::conf5_dir}/marathon.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/marathon.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/marathon.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/marathon.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/integrations/memcache.pp b/manifests/integrations/memcache.pp index 3216b9ae..6610a4bd 100644 --- a/manifests/integrations/memcache.pp +++ b/manifests/integrations/memcache.pp @@ -40,9 +40,6 @@ ) inherits datadog_agent::params { include datadog_agent - validate_legacy('String', 'validate_string', $url) - validate_legacy('Array', 'validate_array', $tags) - if !$instances and $url { $_instances = [{ 'url' => $url, @@ -57,9 +54,9 @@ $_instances = $instances } - $legacy_dst = "${datadog_agent::conf5_dir}/mcache.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/mcache.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/mcache.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/mcache.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/integrations/mesos_master.pp b/manifests/integrations/mesos_master.pp index 40e237e6..f86572ee 100644 --- a/manifests/integrations/mesos_master.pp +++ b/manifests/integrations/mesos_master.pp @@ -18,8 +18,8 @@ ) inherits datadog_agent::params { include datadog_agent - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/mesos.d" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/mesos.d" file { $dst_dir: ensure => directory, @@ -31,16 +31,16 @@ } $dst = "${dst_dir}/conf.yaml" } else { - $dst = "${datadog_agent::conf5_dir}/mesos.yaml" + $dst = "${datadog_agent::params::legacy_conf_dir}/mesos.yaml" } file { $dst: ensure => 'absent' } - $legacy_dst_master = "${datadog_agent::conf5_dir}/mesos_master.yaml" - if !$::datadog_agent::agent5_enable { - $dst_master_dir = "${datadog_agent::conf6_dir}/mesos_master.d" + $legacy_dst_master = "${datadog_agent::params::legacy_conf_dir}/mesos_master.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_master_dir = "${datadog_agent::params::conf_dir}/mesos_master.d" file { $legacy_dst_master: ensure => 'absent' } diff --git a/manifests/integrations/mesos_slave.pp b/manifests/integrations/mesos_slave.pp index 48a16aa3..6e936289 100644 --- a/manifests/integrations/mesos_slave.pp +++ b/manifests/integrations/mesos_slave.pp @@ -17,9 +17,9 @@ $url = 'http://localhost:5051' ) inherits datadog_agent::params { - $legacy_dst = "${datadog_agent::conf5_dir}/mesos_slave.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/mesos_slave.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/mesos_slave.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/mesos_slave.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/integrations/mongo.pp b/manifests/integrations/mongo.pp index f32af612..d6829643 100644 --- a/manifests/integrations/mongo.pp +++ b/manifests/integrations/mongo.pp @@ -57,16 +57,13 @@ # } # class datadog_agent::integrations::mongo( - $servers = [{'host' => 'localhost', 'port' => '27017'}] + Array $servers = [{'host' => 'localhost', 'port' => '27017'}] ) inherits datadog_agent::params { include datadog_agent - - validate_legacy('Array', 'validate_array', $servers) - - $legacy_dst = "${datadog_agent::conf5_dir}/mongo.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/mongo.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/mongo.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/mongo.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/integrations/mysql.pp b/manifests/integrations/mysql.pp index 810cf8d7..ed2dee0b 100644 --- a/manifests/integrations/mysql.pp +++ b/manifests/integrations/mysql.pp @@ -83,9 +83,6 @@ ) inherits datadog_agent::params { include datadog_agent - validate_legacy('Optional[String]', 'validate_string', $sock) - validate_legacy('Array', 'validate_array', $tags) - if ($host == undef and $sock == undef) or ($host != undef and $port == undef and $sock == undef) { fail('invalid MySQL configuration') @@ -114,9 +111,9 @@ $_instances = $instances } - $legacy_dst = "${datadog_agent::conf5_dir}/mysql.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/mysql.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/mysql.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/mysql.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/integrations/network.pp b/manifests/integrations/network.pp index d2939052..0ef6389d 100644 --- a/manifests/integrations/network.pp +++ b/manifests/integrations/network.pp @@ -29,11 +29,9 @@ ) inherits datadog_agent::params { include ::datadog_agent - validate_legacy('Array', 'validate_array', $excluded_interfaces) - - $legacy_dst = "${datadog_agent::conf5_dir}/network.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/network.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/network.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/network.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/integrations/nginx.pp b/manifests/integrations/nginx.pp index 0c2e94c0..f40b895f 100644 --- a/manifests/integrations/nginx.pp +++ b/manifests/integrations/nginx.pp @@ -63,11 +63,9 @@ ) inherits datadog_agent::params { include datadog_agent - validate_legacy('Array', 'validate_array', $instances) - - $legacy_dst = "${datadog_agent::conf5_dir}/nginx.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/nginx.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/nginx.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/nginx.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/integrations/ntp.pp b/manifests/integrations/ntp.pp index 40b4d421..2d65d25a 100644 --- a/manifests/integrations/ntp.pp +++ b/manifests/integrations/ntp.pp @@ -32,9 +32,9 @@ ) inherits datadog_agent::params { include datadog_agent - $legacy_dst = "${datadog_agent::conf5_dir}/ntp.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/ntp.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/ntp.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/ntp.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/integrations/pgbouncer.pp b/manifests/integrations/pgbouncer.pp index 9f2ef9b1..b1d595f1 100644 --- a/manifests/integrations/pgbouncer.pp +++ b/manifests/integrations/pgbouncer.pp @@ -53,12 +53,9 @@ ) inherits datadog_agent::params { include datadog_agent - validate_legacy('Array', 'validate_array', $tags) - validate_legacy('Array', 'validate_array', $pgbouncers) - - $legacy_dst = "${datadog_agent::conf5_dir}/pgbouncer.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/pgbouncer.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/pgbouncer.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/pgbouncer.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/integrations/php_fpm.pp b/manifests/integrations/php_fpm.pp index 652d051c..1bcf8ab8 100644 --- a/manifests/integrations/php_fpm.pp +++ b/manifests/integrations/php_fpm.pp @@ -45,9 +45,9 @@ $_instances = $instances } - $legacy_dst = "${datadog_agent::conf5_dir}/php_fpm.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/php_fpm.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/php_fpm.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/php_fpm.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/integrations/postfix.pp b/manifests/integrations/postfix.pp index bf97a8c3..fe799cd4 100644 --- a/manifests/integrations/postfix.pp +++ b/manifests/integrations/postfix.pp @@ -29,17 +29,13 @@ # } # class datadog_agent::integrations::postfix ( - $directory = '/var/spool/postfix', + String $directory = '/var/spool/postfix', Array $queues = [ 'active', 'deferred', 'incoming' ], Optional[Array] $tags = [], Optional[Array] $instances = undef, ) inherits datadog_agent::params { include datadog_agent - validate_legacy('String', 'validate_string', $directory) - validate_legacy('Optional[Array]', 'validate_array', $queues) - validate_legacy('Optional[Array]', 'validate_array', $tags) - if !$instances and $directory { $_instances = [{ 'directory' => $directory, @@ -52,9 +48,9 @@ $_instances = $instances } - $legacy_dst = "${datadog_agent::conf5_dir}/postfix.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/postfix.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/postfix.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/postfix.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/integrations/postgres.pp b/manifests/integrations/postgres.pp index 1e8c97e8..9d98dcc2 100644 --- a/manifests/integrations/postgres.pp +++ b/manifests/integrations/postgres.pp @@ -102,13 +102,9 @@ ) inherits datadog_agent::params { include datadog_agent - validate_legacy('Array[String]', 'validate_array', $tags) - validate_legacy('Array[String]', 'validate_array', $tables) - validate_legacy('Boolean', 'validate_bool', $use_psycopg2) - - $legacy_dst = "${datadog_agent::conf5_dir}/postgres.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/postgres.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/postgres.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/postgres.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/integrations/postgres_custom_metric.pp b/manifests/integrations/postgres_custom_metric.pp index cb837d87..91a7b913 100644 --- a/manifests/integrations/postgres_custom_metric.pp +++ b/manifests/integrations/postgres_custom_metric.pp @@ -21,8 +21,6 @@ Boolean $relation = false, Array $descriptors = [], ) { - validate_legacy('Hash', 'validate_hash', $metrics) - validate_legacy('Array', 'validate_array', $descriptors) if $query !~ '^.*%s.*$' { fail('custom_metrics require %s for metric substitution') diff --git a/manifests/integrations/process.pp b/manifests/integrations/process.pp index d54b0f69..66ee1ee8 100644 --- a/manifests/integrations/process.pp +++ b/manifests/integrations/process.pp @@ -46,18 +46,15 @@ ) inherits datadog_agent::params { include datadog_agent - validate_legacy('Boolean', 'validate_bool', $hiera_processes) - validate_legacy('Array', 'validate_array', $processes) - if $hiera_processes { $local_processes = lookup({ 'name' => 'datadog_agent::integrations::process::processes', 'merge' => 'unique', 'default_value' => $processes }) } else { $local_processes = $processes } - $legacy_dst = "${datadog_agent::conf5_dir}/process.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/process.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/process.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/process.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/integrations/rabbitmq.pp b/manifests/integrations/rabbitmq.pp index 60988df1..36b82dff 100644 --- a/manifests/integrations/rabbitmq.pp +++ b/manifests/integrations/rabbitmq.pp @@ -65,23 +65,11 @@ Array $exchanges_regexes = [], ) inherits datadog_agent::params { - validate_legacy('String', 'validate_string', $url) - validate_legacy('Optional[String]', 'validate_string', $username) - validate_legacy('Optional[String]', 'validate_string', $password) - validate_legacy('Boolean', 'validate_bool', $ssl_verify) - validate_legacy('Boolean', 'validate_bool', $tag_families) - validate_legacy('Array', 'validate_array', $nodes) - validate_legacy('Array', 'validate_array', $nodes_regexes) - validate_legacy('Array', 'validate_array', $queues) - validate_legacy('Array', 'validate_array', $queues_regexes) - validate_legacy('Array', 'validate_array', $exchanges) - validate_legacy('Array', 'validate_array', $exchanges_regexes) - validate_legacy('Array', 'validate_array', $vhosts) include datadog_agent - $legacy_dst = "${datadog_agent::conf5_dir}/rabbitmq.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/rabbitmq.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/rabbitmq.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/rabbitmq.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/integrations/redis.pp b/manifests/integrations/redis.pp index 24d82480..9d5db2b9 100644 --- a/manifests/integrations/redis.pp +++ b/manifests/integrations/redis.pp @@ -55,20 +55,12 @@ ) inherits datadog_agent::params { include datadog_agent - validate_legacy('Array', 'validate_array', $tags) - validate_legacy('Array', 'validate_array', $keys) - validate_legacy('Boolean', 'validate_bool', $warn_on_missing_keys) - validate_legacy('Boolean', 'validate_bool', $command_stats) - validate_legacy('Optional[Array]', 'validate_array', $ports) - if $ports == undef { $_ports = [ $port ] } else { $_ports = $ports } - validate_legacy('Array', 'validate_array', $_ports) - $_port_instances = $_ports.map |$instance_port| { { 'host' => $host, @@ -82,9 +74,9 @@ } } - $legacy_dst = "${datadog_agent::conf5_dir}/redisdb.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/redisdb.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/redisdb.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/redisdb.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/integrations/riak.pp b/manifests/integrations/riak.pp index 692a1f5f..78437b3b 100644 --- a/manifests/integrations/riak.pp +++ b/manifests/integrations/riak.pp @@ -24,12 +24,9 @@ ) inherits datadog_agent::params { include datadog_agent - validate_legacy('String', 'validate_string', $url) - validate_legacy('Array', 'validate_array', $tags) - - $legacy_dst = "${datadog_agent::conf5_dir}/riak.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/riak.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/riak.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/riak.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/integrations/snmp.pp b/manifests/integrations/snmp.pp index a39405be..b5579edf 100755 --- a/manifests/integrations/snmp.pp +++ b/manifests/integrations/snmp.pp @@ -69,9 +69,9 @@ 3 => $snmp_v3_instances, } - $legacy_dst = "${datadog_agent::conf5_dir}/snmp.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/snmp.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/snmp.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/snmp.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/integrations/solr.pp b/manifests/integrations/solr.pp index efb82592..b5ea60ba 100644 --- a/manifests/integrations/solr.pp +++ b/manifests/integrations/solr.pp @@ -38,9 +38,9 @@ ) inherits datadog_agent::params { include datadog_agent - $legacy_dst = "${datadog_agent::conf5_dir}/solr.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/solr.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/solr.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/solr.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/integrations/ssh.pp b/manifests/integrations/ssh.pp index 60ef49f0..ada1d9e3 100644 --- a/manifests/integrations/ssh.pp +++ b/manifests/integrations/ssh.pp @@ -37,9 +37,9 @@ ) inherits datadog_agent::params { include ::datadog_agent - $legacy_dst = "${datadog_agent::conf5_dir}/ssh.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/ssh_check.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/ssh.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/ssh_check.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/integrations/supervisord.pp b/manifests/integrations/supervisord.pp index f1eeabd1..3019ef1b 100644 --- a/manifests/integrations/supervisord.pp +++ b/manifests/integrations/supervisord.pp @@ -46,9 +46,9 @@ ) inherits datadog_agent::params { include datadog_agent - $legacy_dst = "${datadog_agent::conf5_dir}/supervisord.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/supervisord.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/supervisord.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/supervisord.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/integrations/system_core.pp b/manifests/integrations/system_core.pp index 33014b4a..8125ef45 100644 --- a/manifests/integrations/system_core.pp +++ b/manifests/integrations/system_core.pp @@ -9,9 +9,9 @@ class datadog_agent::integrations::system_core inherits datadog_agent::params { include datadog_agent - $legacy_dst = "${datadog_agent::conf5_dir}/system_core.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/system_core.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/system_core.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/system_core.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/integrations/tcp_check.pp b/manifests/integrations/tcp_check.pp index 4a7c2243..8b04451c 100644 --- a/manifests/integrations/tcp_check.pp +++ b/manifests/integrations/tcp_check.pp @@ -86,16 +86,16 @@ class datadog_agent::integrations::tcp_check ( - $check_name = undef, - $host = undef, - $port = undef, - $timeout = 10, - $threshold = undef, - $window = undef, - $collect_response_time = undef, - $skip_event = undef, - $tags = [], - $instances = undef, + $check_name = undef, + $host = undef, + $port = undef, + Integer $timeout = 10, + $threshold = undef, + $window = undef, + $collect_response_time = undef, + $skip_event = undef, + Array $tags = [], + Optional[Array] $instances = undef, ) inherits datadog_agent::params { include datadog_agent @@ -117,9 +117,9 @@ $_instances = $instances } - $legacy_dst = "${datadog_agent::conf5_dir}/tcp_check.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/tcp_check.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/tcp_check.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/tcp_check.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/integrations/tomcat.pp b/manifests/integrations/tomcat.pp index a4df8cad..9ab5baa6 100644 --- a/manifests/integrations/tomcat.pp +++ b/manifests/integrations/tomcat.pp @@ -42,9 +42,9 @@ include datadog_agent - $legacy_dst = "${datadog_agent::conf5_dir}/tomcat.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/tomcat.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/tomcat.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/tomcat.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/integrations/twemproxy.pp b/manifests/integrations/twemproxy.pp index ea3022f6..38c42005 100644 --- a/manifests/integrations/twemproxy.pp +++ b/manifests/integrations/twemproxy.pp @@ -41,9 +41,9 @@ $_instances = $instances } - $legacy_dst = "${datadog_agent::conf5_dir}/twemproxy.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/twemproxy.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/twemproxy.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/twemproxy.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/integrations/varnish.pp b/manifests/integrations/varnish.pp index e53ecf21..3a348a0b 100644 --- a/manifests/integrations/varnish.pp +++ b/manifests/integrations/varnish.pp @@ -28,9 +28,9 @@ ) inherits datadog_agent::params { include datadog_agent - $legacy_dst = "${datadog_agent::conf5_dir}/varnish.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/varnish.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/varnish.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/varnish.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/integrations/zk.pp b/manifests/integrations/zk.pp index c7433f45..0ef8df0d 100644 --- a/manifests/integrations/zk.pp +++ b/manifests/integrations/zk.pp @@ -32,11 +32,9 @@ ) inherits datadog_agent::params { include datadog_agent - validate_legacy('Array', 'validate_array', $servers) - - $legacy_dst = "${datadog_agent::conf5_dir}/zk.yaml" - if !$::datadog_agent::agent5_enable { - $dst_dir = "${datadog_agent::conf6_dir}/zk.d" + $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/zk.yaml" + if $::datadog_agent::_agent_major_version > 5 { + $dst_dir = "${datadog_agent::params::conf_dir}/zk.d" file { $legacy_dst: ensure => 'absent' } diff --git a/manifests/params.pp b/manifests/params.pp index aeb2f1fd..0706c355 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -2,18 +2,11 @@ # # This class contains the parameters for the Datadog module # -# Parameters: -# -# Actions: -# -# Requires: -# -# Sample Usage: -# + class datadog_agent::params { $datadog_site = 'datadoghq.com' - $agent5_enable = false $dd_groups = undef + $default_agent_major_version = 7 $agent_version = 'latest' $dogapi_version = 'installed' $gem_provider = 'puppetserver_gem' @@ -29,19 +22,17 @@ $use_apt_backup_keyserver = false $apt_backup_keyserver = 'hkp://pool.sks-keyservers.net:80' $apt_keyserver = 'hkp://keyserver.ubuntu.com:80' + $sysprobe_service_name = 'datadog-agent-sysprobe' case $::operatingsystem { 'Ubuntu','Debian' : { $rubydev_package = 'ruby-dev' - $agent5_default_repo = 'https://apt.datadoghq.com' - $agent6_default_repo = 'https://apt.datadoghq.com' - $conf5_dir = '/etc/dd-agent/conf.d' - $conf6_dir = '/etc/datadog-agent/conf.d' + $legacy_conf_dir = '/etc/dd-agent/conf.d' + $conf_dir = '/etc/datadog-agent/conf.d' $dd_user = 'dd-agent' - $dd_group = 'root' + $dd_group = 'dd-agent' $service_name = 'datadog-agent' - $sysprobe_service_name = 'datadog-agent-sysprobe' - $agent6_log_file = '/var/log/datadog/agent.log' + $agent_log_file = '/var/log/datadog/agent.log' $package_name = 'datadog-agent' $permissions_directory = '0755' $permissions_file = '0644' @@ -50,15 +41,12 @@ } 'RedHat','CentOS','Fedora','Amazon','Scientific','OracleLinux' : { $rubydev_package = 'ruby-devel' - $agent5_default_repo = "https://yum.datadoghq.com/rpm/${::architecture}/" - $agent6_default_repo = "https://yum.datadoghq.com/stable/6/${::architecture}/" - $conf5_dir = '/etc/dd-agent/conf.d' - $conf6_dir = '/etc/datadog-agent/conf.d' + $legacy_conf_dir = '/etc/dd-agent/conf.d' + $conf_dir = '/etc/datadog-agent/conf.d' $dd_user = 'dd-agent' - $dd_group = 'root' + $dd_group = 'dd-agent' $service_name = 'datadog-agent' - $sysprobe_service_name = 'datadog-agent-sysprobe' - $agent6_log_file = '/var/log/datadog/agent.log' + $agent_log_file = '/var/log/datadog/agent.log' $package_name = 'datadog-agent' $permissions_directory = '0755' $permissions_file = '0644' @@ -66,14 +54,12 @@ $agent_binary = '/opt/datadog-agent/bin/agent/agent' } 'Windows': { - $agent5_default_repo = '' # Param in init.pp so needs to be defined, but not used on Windows - $agent6_default_repo = 'https://s3.amazonaws.com/ddagent-windows-stable/' - $conf5_dir = 'C:/ProgramData/Datadog/agent5' # Not a real path, but integrations use it to ensure => absent so it needs to be a valid path - $conf6_dir = 'C:/ProgramData/Datadog/conf.d' + $legacy_conf_dir = 'C:/ProgramData/Datadog/agent5' # Not a real path, but integrations use it to ensure => absent so it needs to be a valid path + $conf_dir = 'C:/ProgramData/Datadog/conf.d' $dd_user = 'ddagentuser' $dd_group = 'S-1-5-32-544' # Administrators group, passed as SID so it works on localized Windows versions $service_name = 'datadogagent' - $agent6_log_file = 'C:/ProgramData/Datadog/logs/agent.log' + $agent_log_file = 'C:/ProgramData/Datadog/logs/agent.log' $package_name = 'Datadog Agent' # Must be the app's DisplayName. https://puppet.com/docs/puppet/latest/resources_package_windows.html $permissions_directory = '0775' # On Windows, the Administrators group needs to maintain access, $permissions_file = '0664' # otherwise puppet itself won't be able to access the file. Reported diff --git a/manifests/redhat/agent6.pp b/manifests/redhat.pp similarity index 62% rename from manifests/redhat/agent6.pp rename to manifests/redhat.pp index 37e9a88e..5f9cec77 100644 --- a/manifests/redhat/agent6.pp +++ b/manifests/redhat.pp @@ -1,11 +1,11 @@ -# Class: datadog_agent::redhat::agent6 +# Class: datadog_agent::redhat # # This class contains the DataDog agent installation mechanism for Red Hat derivatives # -class datadog_agent::redhat::agent6( - String $baseurl = $datadog_agent::params::agent6_default_repo, - String $gpgkey = 'https://yum.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public', +class datadog_agent::redhat( + Integer $agent_major_version = $datadog_agent::params::default_agent_major_version, + Optional[String] $agent_repo_uri = undef, Boolean $manage_repo = true, String $agent_version = $datadog_agent::params::agent_version, String $service_ensure = 'running', @@ -13,30 +13,49 @@ Optional[String] $service_provider = undef, ) inherits datadog_agent::params { - validate_legacy('Boolean', 'validate_bool', $manage_repo) - validate_legacy('Boolean', 'validate_bool', $service_enable) if $manage_repo { - $public_key_local = '/etc/pki/rpm-gpg/DATADOG_RPM_KEY.public' - validate_legacy('String', 'validate_string', $baseurl) + case $agent_major_version { + 5 : { + $defaulturl = "https://yum.datadoghq.com/rpm/${::architecture}/" + $gpgkey = 'https://yum.datadoghq.com/DATADOG_RPM_KEY.public' + } + 6 : { + $defaulturl = "https://yum.datadoghq.com/stable/6/${::architecture}/" + $gpgkey = 'https://yum.datadoghq.com/DATADOG_RPM_KEY.public' + } + 7 : { + $defaulturl = "https://yum.datadoghq.com/stable/7/${::architecture}/" + $gpgkey = 'https://yum.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public' + } + default: { fail('invalid agent_major_version') } + } + + if ($agent_repo_uri != undef) { + $baseurl = $agent_repo_uri + } else { + $baseurl = $defaulturl + } - file { 'DATADOG_RPM_KEY.public': + $public_key_local = '/etc/pki/rpm-gpg/DATADOG_RPM_KEY.public' + + file { 'DATADOG_RPM_KEY_E09422B3.public': owner => root, group => root, mode => '0600', path => $public_key_local, - source => $gpgkey + source => 'https://yum.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public' } exec { 'install-gpg-key': command => "/bin/rpm --import ${public_key_local}", onlyif => "/usr/bin/gpg --dry-run --quiet --with-fingerprint -n ${public_key_local} | grep 'A4C0 B90D 7443 CF6E 4E8A A341 F106 8E14 E094 22B3' || gpg --dry-run --import --import-options import-show ${public_key_local} | grep 'A4C0B90D7443CF6E4E8AA341F1068E14E09422B3'", unless => '/bin/rpm -q gpg-pubkey-e09422b3', - require => File['DATADOG_RPM_KEY.public'], + require => File['DATADOG_RPM_KEY_E09422B3.public'], } - yumrepo {'datadog': - ensure => absent, + yumrepo { 'datadog-beta': + ensure => absent, } yumrepo {'datadog5': @@ -44,9 +63,13 @@ } yumrepo {'datadog6': + ensure => absent, + } + + yumrepo {'datadog': enabled => 1, gpgcheck => 1, - gpgkey => 'https://yum.datadoghq.com/DATADOG_RPM_KEY.public', + gpgkey => $gpgkey, descr => 'Datadog, Inc.', baseurl => $baseurl, require => Exec['install-gpg-key'], @@ -55,11 +78,6 @@ Package { require => Yumrepo['datadog6']} } - package { 'datadog-agent-base': - ensure => absent, - before => Package[$datadog_agent::params::package_name], - } - package { $datadog_agent::params::package_name: ensure => $agent_version, } diff --git a/manifests/redhat/agent5.pp b/manifests/redhat/agent5.pp deleted file mode 100644 index 3dd979e0..00000000 --- a/manifests/redhat/agent5.pp +++ /dev/null @@ -1,112 +0,0 @@ -# Class: datadog_agent::redhat -# -# This class contains the DataDog agent installation mechanism for Red Hat derivatives -# -# Parameters: -# $baseurl: -# Baseurl for the datadog yum repo -# Defaults to http://yum.datadoghq.com/rpm/${::architecture}/ -# -# Actions: -# -# Requires: -# -# Sample Usage: -# -# -class datadog_agent::redhat::agent5( - String $baseurl = $datadog_agent::params::agent5_default_repo, - String $gpgkey = 'https://yum.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public', - Boolean $manage_repo = true, - String $agent_version = $datadog_agent::params::agent_version, - String $service_ensure = 'running', - Boolean $service_enable = true, - Optional[String] $service_provider = undef, -) inherits datadog_agent::params { - - validate_legacy('Boolean', 'validate_bool', $manage_repo) - validate_legacy('Boolean', 'validate_bool', $service_enable) - if $manage_repo { - $public_key_local = '/etc/pki/rpm-gpg/DATADOG_RPM_KEY.public' - - validate_legacy('String', 'validate_string', $baseurl) - - file { 'DATADOG_RPM_KEY.public': - owner => root, - group => root, - mode => '0600', - path => $public_key_local, - source => $gpgkey - } - - exec { 'install-gpg-key': - 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 => 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', - descr => 'Datadog, Inc.', - baseurl => $baseurl, - require => Exec['install-gpg-key'], - } - - Package { require => Yumrepo['datadog5']} - } - - package { 'datadog-agent-base': - ensure => absent, - before => Package[$datadog_agent::params::package_name], - } - - package { $datadog_agent::params::package_name: - ensure => $agent_version, - } - - if $service_provider { - service { $datadog_agent::params::service_name: - ensure => $service_ensure, - enable => $service_enable, - provider => $service_provider, - hasstatus => false, - pattern => 'dd-agent', - require => Package[$datadog_agent::params::package_name], - } - } else { - 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.pp similarity index 73% rename from manifests/ubuntu/agent6.pp rename to manifests/ubuntu.pp index 2e4d4381..292da881 100644 --- a/manifests/ubuntu/agent6.pp +++ b/manifests/ubuntu.pp @@ -1,14 +1,14 @@ -# Class: datadog_agent::ubuntu::agent6 +# Class: datadog_agent::ubuntu # # This class contains the DataDog agent installation mechanism for Debian derivatives # -class datadog_agent::ubuntu::agent6( +class datadog_agent::ubuntu( + Integer $agent_major_version = $datadog_agent::params::default_agent_major_version, String $apt_key = 'A2923DFF56EDA6E76E55E492D3A80E30382E94DE', String $agent_version = $datadog_agent::params::agent_version, - String $location = $datadog_agent::params::agent6_default_repo, + Optional[String] $agent_repo_uri = undef, String $release = $datadog_agent::params::apt_default_release, - String $repos = '6', Boolean $skip_apt_key_trusting = false, String $service_ensure = 'running', Boolean $service_enable = true, @@ -16,6 +16,13 @@ Optional[String] $apt_keyserver = undef, ) inherits datadog_agent::params { + case $agent_major_version { + 5 : { $repos = 'main' } + 6 : { $repos = '6' } + 7 : { $repos = '7' } + default: { fail('invalid agent_major_version') } + } + if !$skip_apt_key_trusting { $key = { 'id' => $apt_key, @@ -25,12 +32,26 @@ $key = {} } - apt::source { 'datadog': + if ($agent_repo_uri != undef) { + $location = $agent_repo_uri + } else { + $location = 'https://apt.datadoghq.com/' + } + + apt::source { 'datadog-beta': + ensure => absent, + } + + apt::source { 'datadog5': ensure => absent, } apt::source { 'datadog6': - comment => 'Datadog Agent 6 Repository', + ensure => absent, + } + + apt::source { 'datadog': + comment => 'Datadog Agent Repository', location => $location, release => $release, repos => $repos, diff --git a/manifests/ubuntu/agent5.pp b/manifests/ubuntu/agent5.pp deleted file mode 100644 index 8b68d2b6..00000000 --- a/manifests/ubuntu/agent5.pp +++ /dev/null @@ -1,104 +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::agent5( - String $apt_key = 'A2923DFF56EDA6E76E55E492D3A80E30382E94DE', - String $agent_version = $datadog_agent::params::agent_version, - String $location = $datadog_agent::params::agent5_default_repo, - String $release = $datadog_agent::params::apt_default_release, - String $repos = 'main', - Boolean $skip_apt_key_trusting = false, - String $service_ensure = 'running', - Boolean $service_enable = true, - Optional[String] $service_provider = undef, - Optional[String] $apt_keyserver = undef, -) inherits datadog_agent::params{ - - if !$skip_apt_key_trusting { - $key = { - 'id' => $apt_key, - 'server' => $apt_keyserver, - } - } else { - $key = {} - } - - # 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 => Class['apt'], - key => $key, - notify => Exec['datadog_apt-get_remove_agent6'], - } - - 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'], - Class['apt::update']], - } - - if $service_provider { - service { $datadog_agent::params::service_name: - ensure => $service_ensure, - enable => $service_enable, - provider => $service_provider, - hasstatus => false, - pattern => 'dd-agent', - require => Package[$datadog_agent::params::package_name], - } - } else { - 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/windows/agent6.pp b/manifests/windows.pp similarity index 84% rename from manifests/windows/agent6.pp rename to manifests/windows.pp index 1546cb54..7714d0d7 100644 --- a/manifests/windows/agent6.pp +++ b/manifests/windows.pp @@ -1,12 +1,13 @@ -# Class: datadog_agent::windows::agent6 +# Class: datadog_agent::windows # # This class contains the DataDog agent installation mechanism for Windows # -class datadog_agent::windows::agent6( +class datadog_agent::windows( + Integer $agent_major_version = $datadog_agent::params::default_agent_major_version, String $agent_version = $datadog_agent::params::agent_version, String $service_ensure = 'running', - String $baseurl = $datadog_agent::params::agent6_default_repo, + Optional[String] $agent_repo_uri = undef, String $msi_location = 'C:/Windows/temp', String $api_key = $datadog_agent::api_key, String $hostname = $datadog_agent::host, @@ -16,10 +17,16 @@ Enum['present', 'absent'] $ensure = 'present', ) inherits datadog_agent::params { - $msi_full_path = "${msi_location}/datadog-agent-6-${agent_version}.amd64.msi" + $msi_full_path = "${msi_location}/datadog-agent-${agent_major_version}-${agent_version}.amd64.msi" + + if ($agent_repo_uri != undef) { + $baseurl = $agent_repo_uri + } else { + $baseurl = 'https://s3.amazonaws.com/ddagent-windows-stable/' + } if $agent_version == 'latest' { - $msi_source = "${baseurl}datadog-agent-6-latest.amd64.msi" + $msi_source = "${baseurl}datadog-agent-${agent_major_version}-latest.amd64.msi" } else { $msi_source = "${baseurl}ddagent-cli-${agent_version}.msi" } diff --git a/metadata.json b/metadata.json index 332303e3..dd8fe641 100644 --- a/metadata.json +++ b/metadata.json @@ -1,7 +1,7 @@ { "name": "datadog-datadog_agent", - "version": "2.10.0", - "author": "James Turnbull () and Rob Terhaar () for Datadog Inc.", + "version": "3.0.0", + "author": "James Turnbull , Rob Terhaar , Jaime Fullaondo , Albert Vaca ", "summary": "Install the Datadog monitoring agent and report Puppet runs to Datadog", "license": "Apache-2.0", "source": "git://github.com/DataDog/puppet-datadog-agent.git", diff --git a/spec/classes/datadog_agent_integrations_activemq_xml_spec.rb b/spec/classes/datadog_agent_integrations_activemq_xml_spec.rb index c6ea7cc2..4876f226 100644 --- a/spec/classes/datadog_agent_integrations_activemq_xml_spec.rb +++ b/spec/classes/datadog_agent_integrations_activemq_xml_spec.rb @@ -2,12 +2,12 @@ describe 'datadog_agent::integrations::activemq_xml' do context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/activemq_xml.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/activemq_xml.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/activemq_xml.d/conf.yaml" } end context 'with default parameters' do diff --git a/spec/classes/datadog_agent_integrations_apache_spec.rb b/spec/classes/datadog_agent_integrations_apache_spec.rb index 9d261d9f..a15f6853 100644 --- a/spec/classes/datadog_agent_integrations_apache_spec.rb +++ b/spec/classes/datadog_agent_integrations_apache_spec.rb @@ -1,16 +1,16 @@ require 'spec_helper' describe 'datadog_agent::integrations::apache' do - + context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/apache.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/apache.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/apache.d/conf.yaml" } end - + it { should compile.with_all_deps } it { should contain_class('datadog_agent') } @@ -21,14 +21,14 @@ )} it { should contain_file(conf_file).that_requires("Package[#{PACKAGE_NAME}]") } it { should contain_file(conf_file).that_notifies("Service[#{SERVICE_NAME}]") } - + context 'with default parameters' do it { should contain_file(conf_file).with_content(%r{apache_status_url: http://localhost/server-status\?auto}) } it { should contain_file(conf_file).without_content(/tags:/) } it { should contain_file(conf_file).without_content(/apache_user:/) } it { should contain_file(conf_file).without_content(/apache_password:/) } end - + context 'with parameters set' do let(:params) {{ url: 'http://foobar', @@ -40,47 +40,47 @@ it { should contain_file(conf_file).with_content(/apache_user: userfoo/) } it { should contain_file(conf_file).with_content(/apache_password: passfoo/) } end - + context 'with tags parameter single value' do let(:params) {{ tags: 'foo', }} it { should_not compile } - + skip "this is currently unimplemented behavior" do it { should contain_file(conf_file).with_content(/tags:\s+- foo\s*?[^-]/m) } end end - + context 'with tags parameter array' do let(:params) {{ tags: %w{ foo bar baz }, }} it { should contain_file(conf_file).with_content(/tags:\s+- foo\s+- bar\s+- baz\s*?[^-]/m) } end - + context 'with tags parameter empty values' do context 'mixed in with other tags' do let(:params) {{ tags: [ 'foo', '', 'baz' ] }} - + it { should contain_file(conf_file).with_content(/tags:\s+- foo\s+- baz\s*?[^-]/m) } end - + context 'single element array of an empty string' do let(:params) {{ tags: [''], }} - + skip("undefined behavior") end - + context 'single value empty string' do let(:params) {{ tags: '', }} - + skip("doubly undefined behavior") end end diff --git a/spec/classes/datadog_agent_integrations_cacti_spec.rb b/spec/classes/datadog_agent_integrations_cacti_spec.rb index ec5c51e1..e4526b37 100644 --- a/spec/classes/datadog_agent_integrations_cacti_spec.rb +++ b/spec/classes/datadog_agent_integrations_cacti_spec.rb @@ -2,12 +2,12 @@ describe 'datadog_agent::integrations::cacti' do context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/cacti.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/cacti.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/cacti.d/conf.yaml" } end 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 a78e1ab9..a242665e 100644 --- a/spec/classes/datadog_agent_integrations_cassandra_spec.rb +++ b/spec/classes/datadog_agent_integrations_cassandra_spec.rb @@ -2,12 +2,12 @@ describe 'datadog_agent::integrations::cassandra' do context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/cassandra.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/cassandra.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/cassandra.d/conf.yaml" } end it { should compile.with_all_deps } diff --git a/spec/classes/datadog_agent_integrations_ceph_spec.rb b/spec/classes/datadog_agent_integrations_ceph_spec.rb index 03c4e5d9..e7aa3d99 100644 --- a/spec/classes/datadog_agent_integrations_ceph_spec.rb +++ b/spec/classes/datadog_agent_integrations_ceph_spec.rb @@ -1,19 +1,19 @@ require 'spec_helper' describe 'datadog_agent::integrations::ceph' do - + if RSpec::Support::OS.windows? # Check not supported on Windows return end context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/ceph.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/ceph.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/ceph.d/conf.yaml" } end let(:sudo_conf_file) { '/etc/sudoers.d/datadog_ceph' } diff --git a/spec/classes/datadog_agent_integrations_consul_spec.rb b/spec/classes/datadog_agent_integrations_consul_spec.rb index 2bc6faa5..fb93cb6e 100644 --- a/spec/classes/datadog_agent_integrations_consul_spec.rb +++ b/spec/classes/datadog_agent_integrations_consul_spec.rb @@ -2,12 +2,12 @@ describe 'datadog_agent::integrations::consul' do context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/consul.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/consul.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/consul.d/conf.yaml" } end it { should compile.with_all_deps } diff --git a/spec/classes/datadog_agent_integrations_directory_spec.rb b/spec/classes/datadog_agent_integrations_directory_spec.rb index ec16acf1..96bb37e6 100644 --- a/spec/classes/datadog_agent_integrations_directory_spec.rb +++ b/spec/classes/datadog_agent_integrations_directory_spec.rb @@ -2,12 +2,12 @@ describe 'datadog_agent::integrations::directory' do context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/directory.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/directory.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/directory.d/conf.yaml" } end context 'with default parameters' do @@ -18,7 +18,7 @@ let(:params) {{ directory: '/var/log/datadog', }} - + it { should compile.with_all_deps } it { should contain_file(conf_file).with( owner: DD_USER, diff --git a/spec/classes/datadog_agent_integrations_disk_spec.rb b/spec/classes/datadog_agent_integrations_disk_spec.rb index 041868ac..ec63c999 100644 --- a/spec/classes/datadog_agent_integrations_disk_spec.rb +++ b/spec/classes/datadog_agent_integrations_disk_spec.rb @@ -2,12 +2,12 @@ describe 'datadog_agent::integrations::disk' do context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/disk.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/disk.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/disk.d/conf.yaml" } end it { is_expected.to compile.with_all_deps } @@ -57,11 +57,11 @@ tag_by_filesystem: no HEREDOC } - it { + it { if RSpec::Support::OS.windows? yaml_conf.gsub!(/\n/, "\r\n") - end - is_expected.to contain_file(conf_file).with_content(yaml_conf) + end + is_expected.to contain_file(conf_file).with_content(yaml_conf) } end @@ -111,7 +111,7 @@ if RSpec::Support::OS.windows? yaml_conf.gsub!(/\n/, "\r\n") end - is_expected.to contain_file(conf_file).with_content(yaml_conf) + is_expected.to contain_file(conf_file).with_content(yaml_conf) } end end diff --git a/spec/classes/datadog_agent_integrations_dns_check_spec.rb b/spec/classes/datadog_agent_integrations_dns_check_spec.rb index 4c149107..c53aa39a 100644 --- a/spec/classes/datadog_agent_integrations_dns_check_spec.rb +++ b/spec/classes/datadog_agent_integrations_dns_check_spec.rb @@ -2,12 +2,12 @@ describe 'datadog_agent::integrations::dns_check' do context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/dns_check.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/dns_check.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/dns_check.d/conf.yaml" } end it { should compile.with_all_deps } diff --git a/spec/classes/datadog_agent_integrations_docker_daemon_spec.rb b/spec/classes/datadog_agent_integrations_docker_daemon_spec.rb index 43e5443e..6efe7fc5 100644 --- a/spec/classes/datadog_agent_integrations_docker_daemon_spec.rb +++ b/spec/classes/datadog_agent_integrations_docker_daemon_spec.rb @@ -8,12 +8,12 @@ end context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/docker.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/docker.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/docker.d/conf.yaml" } end it { should compile.with_all_deps } diff --git a/spec/classes/datadog_agent_integrations_elasticsearch_spec.rb b/spec/classes/datadog_agent_integrations_elasticsearch_spec.rb index d656330e..51f77d5b 100644 --- a/spec/classes/datadog_agent_integrations_elasticsearch_spec.rb +++ b/spec/classes/datadog_agent_integrations_elasticsearch_spec.rb @@ -2,12 +2,12 @@ describe 'datadog_agent::integrations::elasticsearch' do context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/elastic.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/elastic.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/elastic.d/conf.yaml" } end it { should compile.with_all_deps } diff --git a/spec/classes/datadog_agent_integrations_fluentd_spec.rb b/spec/classes/datadog_agent_integrations_fluentd_spec.rb index a476a642..04682613 100644 --- a/spec/classes/datadog_agent_integrations_fluentd_spec.rb +++ b/spec/classes/datadog_agent_integrations_fluentd_spec.rb @@ -2,12 +2,12 @@ describe 'datadog_agent::integrations::fluentd' do context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/fluentd.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/fluentd.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/fluentd.d/conf.yaml" } end context 'with default parameters' do diff --git a/spec/classes/datadog_agent_integrations_haproxy_spec.rb b/spec/classes/datadog_agent_integrations_haproxy_spec.rb index a418fa58..d80e4936 100644 --- a/spec/classes/datadog_agent_integrations_haproxy_spec.rb +++ b/spec/classes/datadog_agent_integrations_haproxy_spec.rb @@ -2,15 +2,15 @@ describe 'datadog_agent::integrations::haproxy' do context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } let(:facts) {{ ipaddress: '1.2.3.4' }} - if is_agent5 + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/haproxy.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/haproxy.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/haproxy.d/conf.yaml" } end it { should compile.with_all_deps } diff --git a/spec/classes/datadog_agent_integrations_http_check_spec.rb b/spec/classes/datadog_agent_integrations_http_check_spec.rb index 4c4a6505..510b9e96 100644 --- a/spec/classes/datadog_agent_integrations_http_check_spec.rb +++ b/spec/classes/datadog_agent_integrations_http_check_spec.rb @@ -2,12 +2,12 @@ describe 'datadog_agent::integrations::http_check' do context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/http_check.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/http_check.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/http_check.d/conf.yaml" } end it { should compile.with_all_deps } diff --git a/spec/classes/datadog_agent_integrations_jenkins_spec.rb b/spec/classes/datadog_agent_integrations_jenkins_spec.rb index c54e1243..622b97a6 100644 --- a/spec/classes/datadog_agent_integrations_jenkins_spec.rb +++ b/spec/classes/datadog_agent_integrations_jenkins_spec.rb @@ -2,12 +2,12 @@ describe 'datadog_agent::integrations::jenkins' do context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/jenkins.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/jenkins.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/jenkins.d/conf.yaml" } end it { should compile.with_all_deps } diff --git a/spec/classes/datadog_agent_integrations_jmx_spec.rb b/spec/classes/datadog_agent_integrations_jmx_spec.rb index 0bd991c2..c4e5afcf 100644 --- a/spec/classes/datadog_agent_integrations_jmx_spec.rb +++ b/spec/classes/datadog_agent_integrations_jmx_spec.rb @@ -2,12 +2,12 @@ describe 'datadog_agent::integrations::jmx' do context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/jmx.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/jmx.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/jmx.d/conf.yaml" } end it { should compile.with_all_deps } diff --git a/spec/classes/datadog_agent_integrations_kafka_spec.rb b/spec/classes/datadog_agent_integrations_kafka_spec.rb index f2e8ec14..909df17c 100644 --- a/spec/classes/datadog_agent_integrations_kafka_spec.rb +++ b/spec/classes/datadog_agent_integrations_kafka_spec.rb @@ -2,12 +2,12 @@ describe 'datadog_agent::integrations::kafka' do context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/kafka.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/kafka.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/kafka.d/conf.yaml" } end it { should compile.with_all_deps } diff --git a/spec/classes/datadog_agent_integrations_kong_spec.rb b/spec/classes/datadog_agent_integrations_kong_spec.rb index edaf8d94..bb64f405 100644 --- a/spec/classes/datadog_agent_integrations_kong_spec.rb +++ b/spec/classes/datadog_agent_integrations_kong_spec.rb @@ -2,12 +2,12 @@ describe 'datadog_agent::integrations::kong' do context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/kong.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/kong.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/kong.d/conf.yaml" } end it { should compile.with_all_deps } diff --git a/spec/classes/datadog_agent_integrations_kubernetes_spec.rb b/spec/classes/datadog_agent_integrations_kubernetes_spec.rb index b6a1da9f..f3fd3263 100644 --- a/spec/classes/datadog_agent_integrations_kubernetes_spec.rb +++ b/spec/classes/datadog_agent_integrations_kubernetes_spec.rb @@ -2,12 +2,12 @@ describe 'datadog_agent::integrations::kubernetes' do context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/kubernetes.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/kubernetes.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/kubernetes.d/conf.yaml" } end it { should compile.with_all_deps } diff --git a/spec/classes/datadog_agent_integrations_kubernetes_state_spec.rb b/spec/classes/datadog_agent_integrations_kubernetes_state_spec.rb index 6223333d..4a93f067 100644 --- a/spec/classes/datadog_agent_integrations_kubernetes_state_spec.rb +++ b/spec/classes/datadog_agent_integrations_kubernetes_state_spec.rb @@ -2,12 +2,12 @@ describe 'datadog_agent::integrations::kubernetes_state' do context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/kubernetes_state.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/kubernetes_state.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/kubernetes_state.d/conf.yaml" } end it { should compile.with_all_deps } diff --git a/spec/classes/datadog_agent_integrations_logs_spec.rb b/spec/classes/datadog_agent_integrations_logs_spec.rb index 213a3c1d..6da7cdae 100644 --- a/spec/classes/datadog_agent_integrations_logs_spec.rb +++ b/spec/classes/datadog_agent_integrations_logs_spec.rb @@ -1,9 +1,9 @@ require 'spec_helper' describe 'datadog_agent::integrations::logs' do - context 'supported agents - v6' do - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => false}" } - let(:conf_file) { "#{CONF_DIR6}/logs.yaml" } + context 'supported agents - v6' do + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => 6}" } + let(:conf_file) { "#{CONF_DIR}/logs.yaml" } context 'with default parameters' do it { should compile } diff --git a/spec/classes/datadog_agent_integrations_marathon_spec.rb b/spec/classes/datadog_agent_integrations_marathon_spec.rb index 07f25496..d82f8a4f 100644 --- a/spec/classes/datadog_agent_integrations_marathon_spec.rb +++ b/spec/classes/datadog_agent_integrations_marathon_spec.rb @@ -2,12 +2,12 @@ describe 'datadog_agent::integrations::marathon' do context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/marathon.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/marathon.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/marathon.d/conf.yaml" } end it { should compile.with_all_deps } diff --git a/spec/classes/datadog_agent_integrations_memcache_spec.rb b/spec/classes/datadog_agent_integrations_memcache_spec.rb index c61f3ff8..17da1d15 100644 --- a/spec/classes/datadog_agent_integrations_memcache_spec.rb +++ b/spec/classes/datadog_agent_integrations_memcache_spec.rb @@ -2,12 +2,12 @@ describe 'datadog_agent::integrations::memcache' do context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/mcache.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/mcache.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/mcache.d/conf.yaml" } end it { should compile.with_all_deps } diff --git a/spec/classes/datadog_agent_integrations_mesos_master_spec.rb b/spec/classes/datadog_agent_integrations_mesos_master_spec.rb index a221db90..cfe0fef5 100644 --- a/spec/classes/datadog_agent_integrations_mesos_master_spec.rb +++ b/spec/classes/datadog_agent_integrations_mesos_master_spec.rb @@ -2,12 +2,12 @@ describe 'datadog_agent::integrations::mesos_master' do context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/mesos_master.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/mesos_master.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/mesos_master.d/conf.yaml" } end it { should compile.with_all_deps } diff --git a/spec/classes/datadog_agent_integrations_mongo_spec.rb b/spec/classes/datadog_agent_integrations_mongo_spec.rb index 6891a5b1..53e2f6bc 100644 --- a/spec/classes/datadog_agent_integrations_mongo_spec.rb +++ b/spec/classes/datadog_agent_integrations_mongo_spec.rb @@ -2,12 +2,12 @@ describe 'datadog_agent::integrations::mongo' do context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/mongo.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/mongo.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/mongo.d/conf.yaml" } end it { should compile.with_all_deps } diff --git a/spec/classes/datadog_agent_integrations_mysql_spec.rb b/spec/classes/datadog_agent_integrations_mysql_spec.rb index 639f2266..eae257ba 100644 --- a/spec/classes/datadog_agent_integrations_mysql_spec.rb +++ b/spec/classes/datadog_agent_integrations_mysql_spec.rb @@ -2,12 +2,12 @@ describe 'datadog_agent::integrations::mysql' do context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/mysql.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/mysql.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/mysql.d/conf.yaml" } end context 'with default parameters' do diff --git a/spec/classes/datadog_agent_integrations_network_spec.rb b/spec/classes/datadog_agent_integrations_network_spec.rb index 47705031..47a206a2 100644 --- a/spec/classes/datadog_agent_integrations_network_spec.rb +++ b/spec/classes/datadog_agent_integrations_network_spec.rb @@ -2,12 +2,12 @@ describe 'datadog_agent::integrations::network' do context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/network.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/network.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/network.d/conf.yaml" } end context 'with default parameters' do diff --git a/spec/classes/datadog_agent_integrations_nginx_spec.rb b/spec/classes/datadog_agent_integrations_nginx_spec.rb index 3dee0ad5..093ceb2b 100644 --- a/spec/classes/datadog_agent_integrations_nginx_spec.rb +++ b/spec/classes/datadog_agent_integrations_nginx_spec.rb @@ -2,12 +2,12 @@ describe 'datadog_agent::integrations::nginx' do context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/nginx.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/nginx.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/nginx.d/conf.yaml" } end it { should compile.with_all_deps } diff --git a/spec/classes/datadog_agent_integrations_ntp_spec.rb b/spec/classes/datadog_agent_integrations_ntp_spec.rb index eead5d89..47e58a7a 100644 --- a/spec/classes/datadog_agent_integrations_ntp_spec.rb +++ b/spec/classes/datadog_agent_integrations_ntp_spec.rb @@ -2,12 +2,12 @@ describe 'datadog_agent::integrations::ntp' do context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/ntp.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/ntp.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/ntp.d/conf.yaml" } end it { should compile.with_all_deps } diff --git a/spec/classes/datadog_agent_integrations_pgbouncer_spec.rb b/spec/classes/datadog_agent_integrations_pgbouncer_spec.rb index 390f10ad..c3b33129 100644 --- a/spec/classes/datadog_agent_integrations_pgbouncer_spec.rb +++ b/spec/classes/datadog_agent_integrations_pgbouncer_spec.rb @@ -2,12 +2,12 @@ describe 'datadog_agent::integrations::pgbouncer' do context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/pgbouncer.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/pgbouncer.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/pgbouncer.d/conf.yaml" } end context 'with default parameters' do diff --git a/spec/classes/datadog_agent_integrations_php_fpm_spec.rb b/spec/classes/datadog_agent_integrations_php_fpm_spec.rb index 8d639da1..9725cfd3 100644 --- a/spec/classes/datadog_agent_integrations_php_fpm_spec.rb +++ b/spec/classes/datadog_agent_integrations_php_fpm_spec.rb @@ -2,12 +2,12 @@ describe 'datadog_agent::integrations::php_fpm' do context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/php_fpm.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/php_fpm.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/php_fpm.d/conf.yaml" } end it { should compile.with_all_deps } diff --git a/spec/classes/datadog_agent_integrations_postfix_spec.rb b/spec/classes/datadog_agent_integrations_postfix_spec.rb index 5f7d37c4..8aaeedb6 100644 --- a/spec/classes/datadog_agent_integrations_postfix_spec.rb +++ b/spec/classes/datadog_agent_integrations_postfix_spec.rb @@ -2,12 +2,12 @@ describe 'datadog_agent::integrations::postfix' do context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/postfix.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/postfix.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/postfix.d/conf.yaml" } end it { should compile.with_all_deps } @@ -55,7 +55,7 @@ 'queues' => 'incoming', 'tags' => ['tag3:value3'], }, - + ] } } diff --git a/spec/classes/datadog_agent_integrations_postgres_spec.rb b/spec/classes/datadog_agent_integrations_postgres_spec.rb index 854ec162..b96d9e2f 100644 --- a/spec/classes/datadog_agent_integrations_postgres_spec.rb +++ b/spec/classes/datadog_agent_integrations_postgres_spec.rb @@ -2,12 +2,12 @@ describe 'datadog_agent::integrations::postgres' do context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/postgres.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/postgres.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/postgres.d/conf.yaml" } end context 'with default parameters' do @@ -44,7 +44,7 @@ it { should contain_file(conf_file).without_content(%r{^[^#]*relations: }) } end - context 'with extra metrics collection is_agent5' do + context 'with extra metrics collection' do let(:params) {{ password: 'abc123', collect_function_metrics: true, @@ -63,7 +63,7 @@ } end - context 'with use_psycopg2 is_agent5' do + context 'with use_psycopg2' do let(:params) {{ use_psycopg2: true, password: 'abc123', diff --git a/spec/classes/datadog_agent_integrations_process_spec.rb b/spec/classes/datadog_agent_integrations_process_spec.rb index 12c88b77..d9d16e76 100644 --- a/spec/classes/datadog_agent_integrations_process_spec.rb +++ b/spec/classes/datadog_agent_integrations_process_spec.rb @@ -2,12 +2,12 @@ describe 'datadog_agent::integrations::process' do context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/process.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/process.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/process.d/conf.yaml" } end it { should compile.with_all_deps } diff --git a/spec/classes/datadog_agent_integrations_rabbitmq_spec.rb b/spec/classes/datadog_agent_integrations_rabbitmq_spec.rb index f0c559e6..12184e14 100644 --- a/spec/classes/datadog_agent_integrations_rabbitmq_spec.rb +++ b/spec/classes/datadog_agent_integrations_rabbitmq_spec.rb @@ -2,12 +2,12 @@ describe 'datadog_agent::integrations::rabbitmq' do context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/rabbitmq.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/rabbitmq.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/rabbitmq.d/conf.yaml" } end it { should compile.with_all_deps } diff --git a/spec/classes/datadog_agent_integrations_redis_spec.rb b/spec/classes/datadog_agent_integrations_redis_spec.rb index 713d24a3..08f76536 100644 --- a/spec/classes/datadog_agent_integrations_redis_spec.rb +++ b/spec/classes/datadog_agent_integrations_redis_spec.rb @@ -2,12 +2,12 @@ describe 'datadog_agent::integrations::redis' do context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/redisdb.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/redisdb.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/redisdb.d/conf.yaml" } end it { should compile.with_all_deps } diff --git a/spec/classes/datadog_agent_integrations_riak_spec.rb b/spec/classes/datadog_agent_integrations_riak_spec.rb index 65613fbc..b1d516cb 100644 --- a/spec/classes/datadog_agent_integrations_riak_spec.rb +++ b/spec/classes/datadog_agent_integrations_riak_spec.rb @@ -2,12 +2,12 @@ describe 'datadog_agent::integrations::riak' do context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/riak.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/riak.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/riak.d/conf.yaml" } end it { should compile.with_all_deps } diff --git a/spec/classes/datadog_agent_integrations_snmp_spec.rb b/spec/classes/datadog_agent_integrations_snmp_spec.rb index a10ae1e5..a052914e 100644 --- a/spec/classes/datadog_agent_integrations_snmp_spec.rb +++ b/spec/classes/datadog_agent_integrations_snmp_spec.rb @@ -2,12 +2,12 @@ describe 'datadog_agent::integrations::snmp' do context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/snmp.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/snmp.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/snmp.d/conf.yaml" } end it { should compile.with_all_deps } diff --git a/spec/classes/datadog_agent_integrations_solr_spec.rb b/spec/classes/datadog_agent_integrations_solr_spec.rb index 4da3ea9b..07847a40 100644 --- a/spec/classes/datadog_agent_integrations_solr_spec.rb +++ b/spec/classes/datadog_agent_integrations_solr_spec.rb @@ -2,12 +2,12 @@ describe 'datadog_agent::integrations::solr' do context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/solr.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/solr.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/solr.d/conf.yaml" } end it { should compile.with_all_deps } diff --git a/spec/classes/datadog_agent_integrations_ssh_spec.rb b/spec/classes/datadog_agent_integrations_ssh_spec.rb index dff97d8e..6cfa1137 100644 --- a/spec/classes/datadog_agent_integrations_ssh_spec.rb +++ b/spec/classes/datadog_agent_integrations_ssh_spec.rb @@ -2,12 +2,12 @@ describe 'datadog_agent::integrations::ssh' do context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/ssh.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/ssh_check.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/ssh_check.d/conf.yaml" } end context 'with default parameters' do diff --git a/spec/classes/datadog_agent_integrations_supervisrd_spec.rb b/spec/classes/datadog_agent_integrations_supervisrd_spec.rb index f21120b5..b9da29c4 100644 --- a/spec/classes/datadog_agent_integrations_supervisrd_spec.rb +++ b/spec/classes/datadog_agent_integrations_supervisrd_spec.rb @@ -2,12 +2,12 @@ describe 'datadog_agent::integrations::supervisord' do context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/supervisord.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/supervisord.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/supervisord.d/conf.yaml" } end it { should compile.with_all_deps } diff --git a/spec/classes/datadog_agent_integrations_system_core_spec.rb b/spec/classes/datadog_agent_integrations_system_core_spec.rb index a9943565..1cb3a8fc 100644 --- a/spec/classes/datadog_agent_integrations_system_core_spec.rb +++ b/spec/classes/datadog_agent_integrations_system_core_spec.rb @@ -2,12 +2,12 @@ describe 'datadog_agent::integrations::system_core' do context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/system_core.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/system_core.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/system_core.d/conf.yaml" } end it { should compile.with_all_deps } diff --git a/spec/classes/datadog_agent_integrations_tcp_check_spec.rb b/spec/classes/datadog_agent_integrations_tcp_check_spec.rb index a8acaa08..0c90328d 100644 --- a/spec/classes/datadog_agent_integrations_tcp_check_spec.rb +++ b/spec/classes/datadog_agent_integrations_tcp_check_spec.rb @@ -2,12 +2,12 @@ describe 'datadog_agent::integrations::tcp_check' do context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/tcp_check.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/tcp_check.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/tcp_check.d/conf.yaml" } end it { should compile.with_all_deps } diff --git a/spec/classes/datadog_agent_integrations_tomcat_spec.rb b/spec/classes/datadog_agent_integrations_tomcat_spec.rb index c5943cda..8e1ab334 100644 --- a/spec/classes/datadog_agent_integrations_tomcat_spec.rb +++ b/spec/classes/datadog_agent_integrations_tomcat_spec.rb @@ -2,12 +2,12 @@ describe 'datadog_agent::integrations::tomcat' do context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/tomcat.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/tomcat.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/tomcat.d/conf.yaml" } end it { should compile.with_all_deps } diff --git a/spec/classes/datadog_agent_integrations_twemproxy_spec.rb b/spec/classes/datadog_agent_integrations_twemproxy_spec.rb index 4b6355f9..80127591 100644 --- a/spec/classes/datadog_agent_integrations_twemproxy_spec.rb +++ b/spec/classes/datadog_agent_integrations_twemproxy_spec.rb @@ -2,12 +2,12 @@ describe 'datadog_agent::integrations::twemproxy' do context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/twemproxy.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/twemproxy.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/twemproxy.d/conf.yaml" } end it { should compile.with_all_deps } diff --git a/spec/classes/datadog_agent_integrations_varnish_spec.rb b/spec/classes/datadog_agent_integrations_varnish_spec.rb index 55b17d69..9dc1b0b6 100644 --- a/spec/classes/datadog_agent_integrations_varnish_spec.rb +++ b/spec/classes/datadog_agent_integrations_varnish_spec.rb @@ -2,12 +2,12 @@ describe 'datadog_agent::integrations::varnish' do context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/varnish.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/varnish.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/varnish.d/conf.yaml" } end it { should compile.with_all_deps } diff --git a/spec/classes/datadog_agent_integrations_zk_spec.rb b/spec/classes/datadog_agent_integrations_zk_spec.rb index fb2e7d7b..a8e4faab 100644 --- a/spec/classes/datadog_agent_integrations_zk_spec.rb +++ b/spec/classes/datadog_agent_integrations_zk_spec.rb @@ -2,12 +2,12 @@ describe 'datadog_agent::integrations::zk' do context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { "/etc/dd-agent/conf.d/zk.yaml" } else - let(:conf_file) { "#{CONF_DIR6}/zk.d/conf.yaml" } + let(:conf_file) { "#{CONF_DIR}/zk.d/conf.yaml" } end it { should compile.with_all_deps } diff --git a/spec/classes/datadog_agent_redhat_spec.rb b/spec/classes/datadog_agent_redhat_spec.rb index 074ca84d..f4c97977 100644 --- a/spec/classes/datadog_agent_redhat_spec.rb +++ b/spec/classes/datadog_agent_redhat_spec.rb @@ -1,132 +1,182 @@ require 'spec_helper' -describe 'datadog_agent::redhat::agent5' do +describe 'datadog_agent::redhat' do - if RSpec::Support::OS.windows? - return - end + context 'agent 5' do + if RSpec::Support::OS.windows? + return + end - let(:facts) do - { - osfamily: 'redhat', - operatingsystem: 'Fedora', - architecture: 'x86_64' - } - end + let(:facts) do + { + osfamily: 'redhat', + operatingsystem: 'Fedora', + architecture: 'x86_64' + } + end - # it should install the mirror - context 'with manage_repo => true' do - let(:params){ {:manage_repo => true} } - it do - should contain_yumrepo('datadog5') - .with_enabled(1)\ - .with_gpgcheck(1)\ - .with_gpgkey('https://yum.datadoghq.com/DATADOG_RPM_KEY.public')\ - .with_baseurl('https://yum.datadoghq.com/rpm/x86_64/') + # it should install the mirror + context 'with manage_repo => true' do + let(:params){ {:manage_repo => true, :agent_major_version => 5} } + it do + should contain_yumrepo('datadog') + .with_enabled(1)\ + .with_gpgcheck(1)\ + .with_gpgkey('https://yum.datadoghq.com/DATADOG_RPM_KEY.public')\ + .with_baseurl('https://yum.datadoghq.com/rpm/x86_64/') + end end - 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') + context 'with manage_repo => false' do + let(:params){ {:manage_repo => false, :agent_major_version => 5} } + it do + should_not contain_yumrepo('datadog') + should_not contain_yumrepo('datadog5') + should_not contain_yumrepo('datadog6') + end end - end - context 'overriding provider' do - let(:params) {{ - service_provider: 'upstart', - }} - it do - should contain_service('datadog-agent')\ - .that_requires('package[datadog-agent]') + context 'overriding provider' do + let(:params) {{ + service_provider: 'upstart', + agent_major_version: 5 + }} + it do + should contain_service('datadog-agent')\ + .that_requires('package[datadog-agent]') + end + it do + should contain_service('datadog-agent').with( + 'provider' => 'upstart', + 'ensure' => 'running', + ) + end end + + # it should install the packages it do - should contain_service('datadog-agent').with( - 'provider' => 'upstart', - 'ensure' => 'running', - ) + should contain_package('datadog-agent')\ + .with_ensure('latest') end - end - - - # it should install the packages - it do - should contain_package('datadog-agent-base')\ - .with_ensure('absent')\ - .that_comes_before('Package[datadog-agent]') - end - it do - should contain_package('datadog-agent')\ - .with_ensure('latest') - end - # it should be able to start the service and enable the service by default - it do - should contain_service('datadog-agent')\ - .that_requires('Package[datadog-agent]') + # it should be able to start the service and enable the service by default + it do + should contain_service('datadog-agent')\ + .that_requires('Package[datadog-agent]') + end end -end -describe 'datadog_agent::redhat::agent6' do - let(:facts) do - { - osfamily: 'redhat', - operatingsystem: 'Fedora', - architecture: 'x86_64' - } - end + context 'agent 6' do + let(:facts) do + { + osfamily: 'redhat', + operatingsystem: 'Fedora', + architecture: 'x86_64' + } + end - # it should install the mirror - context 'with manage_repo => true' do - let(:params){ {:manage_repo => true} } - it do - 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/stable/6/x86_64/') + # it should install the mirror + context 'with manage_repo => true' do + let(:params){ {:manage_repo => true, :agent_major_version => 6} } + it do + should contain_yumrepo('datadog') + .with_enabled(1)\ + .with_gpgcheck(1)\ + .with_gpgkey('https://yum.datadoghq.com/DATADOG_RPM_KEY.public')\ + .with_baseurl('https://yum.datadoghq.com/stable/6/x86_64/') + end 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') + context 'with manage_repo => false' do + let(:params){ {:manage_repo => false, :agent_major_version => 6} } + it do + should_not contain_yumrepo('datadog') + should_not contain_yumrepo('datadog5') + should_not contain_yumrepo('datadog6') + end end - end - context 'overriding provider' do - let(:params) {{ - service_provider: 'upstart', - }} + context 'overriding provider' do + let(:params) {{ + service_provider: 'upstart', + agent_major_version: 6 + }} + it do + should contain_service('datadog-agent')\ + .that_requires('package[datadog-agent]') + end + it do + should contain_service('datadog-agent').with( + 'provider' => 'upstart', + 'ensure' => 'running', + ) + end + end + + # it should install the packages it do - should contain_service('datadog-agent')\ - .that_requires('package[datadog-agent]') + should contain_package('datadog-agent')\ + .with_ensure('latest') end + + # it should be able to start the service and enable the service by default it do - should contain_service('datadog-agent').with( - 'provider' => 'upstart', - 'ensure' => 'running', - ) + should contain_service('datadog-agent')\ + .that_requires('Package[datadog-agent]') end end + context 'agent 7' do + let(:facts) do + { + osfamily: 'redhat', + operatingsystem: 'Fedora', + architecture: 'x86_64' + } + end - # it should install the packages - it do - should contain_package('datadog-agent-base')\ - .with_ensure('absent')\ - .that_comes_before('Package[datadog-agent]') - end - it do - should contain_package('datadog-agent')\ - .with_ensure('latest') - end + # it should install the mirror + context 'with manage_repo => true' do + let(:params){ {:manage_repo => true, :agent_major_version => 7} } + it do + should contain_yumrepo('datadog') + .with_enabled(1)\ + .with_gpgcheck(1)\ + .with_gpgkey('https://yum.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public')\ + .with_baseurl('https://yum.datadoghq.com/stable/7/x86_64/') + end + end + context 'with manage_repo => false' do + let(:params){ {:manage_repo => false, :agent_major_version => 7} } + it do + should_not contain_yumrepo('datadog') + should_not contain_yumrepo('datadog5') + should_not contain_yumrepo('datadog6') + end + end + context 'overriding provider' do + let(:params) {{ + service_provider: 'upstart', + agent_major_version: 7 + }} + it do + should contain_service('datadog-agent')\ + .that_requires('package[datadog-agent]') + end + it do + should contain_service('datadog-agent').with( + 'provider' => 'upstart', + 'ensure' => 'running', + ) + end + end + + # it should install the packages + it do + should contain_package('datadog-agent')\ + .with_ensure('latest') + end - # it should be able to start the service and enable the service by default - it do - should contain_service('datadog-agent')\ - .that_requires('Package[datadog-agent]') + # it should be able to start the service and enable the service by default + it do + should contain_service('datadog-agent')\ + .that_requires('Package[datadog-agent]') + end end end diff --git a/spec/classes/datadog_agent_spec.rb b/spec/classes/datadog_agent_spec.rb index 2809f86e..1c9c996a 100644 --- a/spec/classes/datadog_agent_spec.rb +++ b/spec/classes/datadog_agent_spec.rb @@ -19,6 +19,61 @@ end end end + + context 'autodetect major version agent 5' do + let(:params){ {:agent_version => '5.15.1'} } + let(:facts){ { osfamily: 'debian', operatingsystem: 'Ubuntu' } } + it do + should contain_file('/etc/apt/sources.list.d/datadog.list')\ + .with_content(%r{deb\s+https://apt.datadoghq.com/\s+stable\s+main}) + end + end + + context 'autodetect major version agent 6' do + let(:params){ {:agent_version => '6.15.1'} } + let(:facts){ { osfamily: 'debian', operatingsystem: 'Ubuntu' } } + it do + should contain_file('/etc/apt/sources.list.d/datadog.list')\ + .with_content(%r{deb\s+https://apt.datadoghq.com/\s+stable\s+6}) + end + end + + context 'autodetect major version agent 7' do + let(:params){ {:agent_version => '7.15.1'} } + let(:facts){ { osfamily: 'debian', operatingsystem: 'Ubuntu' } } + it do + should contain_file('/etc/apt/sources.list.d/datadog.list')\ + .with_content(%r{deb\s+https://apt.datadoghq.com/\s+stable\s+7}) + end + end + + + context 'autodetect major version agent with suffix and release' do + let(:params){ {:agent_version => '1:6.15.1~rc.1-1'} } + let(:facts){ { osfamily: 'debian', operatingsystem: 'Ubuntu' } } + it do + should contain_file('/etc/apt/sources.list.d/datadog.list')\ + .with_content(%r{deb\s+https://apt.datadoghq.com/\s+stable\s+6}) + end + end + + context 'autodetect major version agent with windows suffix and release' do + let(:params){ {:agent_version => '1:6.15.1-rc.1-1'} } + let(:facts){ { osfamily: 'debian', operatingsystem: 'Ubuntu' } } + it do + should contain_file('/etc/apt/sources.list.d/datadog.list')\ + .with_content(%r{deb\s+https://apt.datadoghq.com/\s+stable\s+6}) + end + end + + context 'autodetect major version agent with release' do + let(:params){ {:agent_version => '1:6.15.1-1'} } + let(:facts){ { osfamily: 'debian', operatingsystem: 'Ubuntu' } } + it do + should contain_file('/etc/apt/sources.list.d/datadog.list')\ + .with_content(%r{deb\s+https://apt.datadoghq.com/\s+stable\s+6}) + end + end end # Test all supported OSes @@ -26,7 +81,7 @@ ALL_OS.each do |operatingsystem| describe "datadog_agent 5 class common actions on #{operatingsystem}" do let(:params) { { puppet_run_reports: true, - agent5_enable: true, + agent_major_version: 5, } } let(:facts) do { @@ -227,7 +282,7 @@ context 'with user provided paramaters' do context 'with a custom dd_url' do let(:params) {{ :dd_url => 'https://notaurl.datadoghq.com', - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog header').with( 'content' => /^dd_url: https:\/\/notaurl.datadoghq.com\n/, @@ -235,7 +290,7 @@ end context 'with a custom proxy_host' do let(:params) {{ :proxy_host => 'localhost', - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog header').with( 'content' => /^proxy_host: localhost\n/, @@ -243,7 +298,7 @@ end context 'with a custom proxy_port' do let(:params) {{ :proxy_port => '1234', - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog header').with( 'content' => /^proxy_port: 1234\n/, @@ -251,7 +306,7 @@ end context 'with a custom proxy_port, specified as an integer' do let(:params) {{ :proxy_port => 1234, - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog header').with( 'content' => /^proxy_port: 1234\n/, @@ -259,7 +314,7 @@ end context 'with a custom proxy_user' do let(:params) {{ :proxy_user => 'notauser', - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog header').with( 'content' => /^proxy_user: notauser\n/, @@ -267,7 +322,7 @@ end context 'with a custom api_key' do let(:params) {{ :api_key => 'notakey', - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog header').with( 'content' => /^api_key: notakey\n/, @@ -275,7 +330,7 @@ end context 'with a custom hostname' do let(:params) {{ :host => 'notahost', - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog header').with( @@ -284,7 +339,7 @@ end context 'with non_local_traffic set to true' do let(:params) {{ :non_local_traffic => true, - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^non_local_traffic: true\n/, @@ -293,7 +348,7 @@ #Should expand testing to cover changes to the case upcase context 'with log level set to critical' do let(:params) {{ :log_level => 'critical', - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^log_level: CRITICAL\n/, @@ -301,7 +356,7 @@ end context 'with a custom hostname' do let(:params) {{ :host => 'notahost', - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog header').with( 'content' => /^hostname: notahost\n/, @@ -309,7 +364,7 @@ end context 'with log_to_syslog set to false' do let(:params) {{ :log_to_syslog => false, - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^log_to_syslog: no\n/, @@ -317,7 +372,7 @@ end context 'with skip_ssl_validation set to true' do let(:params) {{ :skip_ssl_validation => true, - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog header').with( 'content' => /^skip_ssl_validation: true\n/, @@ -325,7 +380,7 @@ end context 'with collect_ec2_tags set to yes' do let(:params) {{ :collect_ec2_tags => true, - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^collect_ec2_tags: true\n/, @@ -333,7 +388,7 @@ end context 'with collect_instance_metadata set to no' do let(:params) {{ :collect_instance_metadata => false, - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^collect_instance_metadata: false\n/, @@ -341,7 +396,7 @@ end context 'with recent_point_threshold set to 60' do let(:params) {{ :recent_point_threshold => '60', - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^recent_point_threshold: 60\n/, @@ -349,7 +404,7 @@ end context 'with a custom port set to 17125' do let(:params) {{ :listen_port => '17125', - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^listen_port: 17125\n/, @@ -357,7 +412,7 @@ end context 'with a custom port set to 17125, specified as an integer' do let(:params) {{ :listen_port => 17125, - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^listen_port: 17125\n/, @@ -365,7 +420,7 @@ end context 'listening for graphite data on port 17124' do let(:params) {{ :graphite_listen_port => '17124', - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^graphite_listen_port: 17124\n/, @@ -373,7 +428,7 @@ end context 'listening for graphite data on port 17124, port specified as an integer' do let(:params) {{ :graphite_listen_port => 17124, - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^graphite_listen_port: 17124\n/, @@ -381,7 +436,7 @@ end context 'with configuration for a custom checks.d' do let(:params) {{ :additional_checksd => '/etc/dd-agent/checks_custom.d', - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^additional_checksd: \/etc\/dd-agent\/checks_custom.d\n/, @@ -389,7 +444,7 @@ end context 'with configuration for a custom checks.d' do let(:params) {{ :additional_checksd => '/etc/dd-agent/checks_custom.d', - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^additional_checksd: \/etc\/dd-agent\/checks_custom.d\n/, @@ -397,7 +452,7 @@ end context 'with configuration for a custom checks.d' do let(:params) {{ :additional_checksd => '/etc/dd-agent/checks_custom.d', - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^additional_checksd: \/etc\/dd-agent\/checks_custom.d\n/, @@ -405,7 +460,7 @@ end context 'with using the Tornado HTTP client' do let(:params) {{ :use_curl_http_client => true, - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^use_curl_http_client: true\n/, @@ -413,7 +468,7 @@ end context 'with a custom bind_host' do let(:params) {{ :bind_host => 'test', - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^bind_host: test\n/, @@ -421,7 +476,7 @@ end context 'with pup enabled' do let(:params) {{ :use_pup => true, - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^use_pup: yes\n/, @@ -429,7 +484,7 @@ end context 'with a custom pup_port' do let(:params) {{ :pup_port => '17126', - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^pup_port: 17126\n/, @@ -437,7 +492,7 @@ end context 'with a custom pup_port, specified as an integer' do let(:params) {{ :pup_port => 17126, - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^pup_port: 17126\n/, @@ -445,7 +500,7 @@ end context 'with a custom pup_interface' do let(:params) {{ :pup_interface => 'notalocalhost', - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^pup_interface: notalocalhost\n/, @@ -453,7 +508,7 @@ end context 'with a custom pup_url' do let(:params) {{ :pup_url => 'http://localhost:17126', - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^pup_url: http:\/\/localhost:17126\n/, @@ -461,7 +516,7 @@ end context 'with use_dogstatsd set to no' do let(:params) {{ :use_dogstatsd => false, - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^use_dogstatsd: no\n/, @@ -469,7 +524,7 @@ end context 'with use_dogstatsd set to yes' do let(:params) {{ :use_dogstatsd => true, - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^use_dogstatsd: yes\n/, @@ -477,7 +532,7 @@ end context 'with dogstatsd_port set to 8126 - must be specified as an integer!' do let(:params) {{ :dogstatsd_port => 8126, - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^dogstatsd_port: 8126\n/, @@ -485,7 +540,7 @@ end context 'with dogstatsd_port set to 8126' do let(:params) {{ :dogstatsd_port => 8126, - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^dogstatsd_port: 8126\n/, @@ -493,7 +548,7 @@ end context 'with dogstatsd_target set to localhost:17124' do let(:params) {{ :dogstatsd_target => 'http://localhost:17124', - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^dogstatsd_target: http:\/\/localhost:17124\n/, @@ -501,7 +556,7 @@ end context 'with dogstatsd_interval set to 5' do let(:params) {{ :dogstatsd_interval => '5', - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^dogstatsd_interval: 5\n/, @@ -509,7 +564,7 @@ end context 'with dogstatsd_interval set to 5' do let(:params) {{ :dogstatsd_interval => '5', - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^dogstatsd_interval: 5\n/, @@ -517,7 +572,7 @@ end context 'with dogstatsd_normalize set to false' do let(:params) {{ :dogstatsd_normalize => false, - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^dogstatsd_normalize: no\n/, @@ -525,7 +580,7 @@ end context 'with statsd_forward_host set to localhost:3958' do let(:params) {{ :statsd_forward_host => 'localhost:3958', - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^statsd_forward_host: localhost:3958\n/, @@ -533,7 +588,7 @@ end context 'with statsd_forward_port set to 8126' do let(:params) {{ :statsd_forward_port => '8126', - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^statsd_forward_port: 8126\n/, @@ -541,7 +596,7 @@ end context 'with statsd_forward_port set to 8126, specified as an integer' do let(:params) {{ :statsd_forward_port => 8126, - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^statsd_forward_port: 8126\n/, @@ -549,7 +604,7 @@ end context 'with device_blacklist_re set to test' do let(:params) {{ :device_blacklist_re => 'test', - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^device_blacklist_re: test\n/, @@ -557,7 +612,7 @@ end context 'with device_blacklist_re set to test' do let(:params) {{ :device_blacklist_re => 'test', - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^device_blacklist_re: test\n/, @@ -566,7 +621,7 @@ context 'with ganglia_host set to localhost and ganglia_port set to 12345' do let(:params) {{ :ganglia_host => 'testhost', :ganglia_port => '12345', - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^ganglia_port: 12345\n/, @@ -578,7 +633,7 @@ 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, - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^ganglia_port: 12345\n/, @@ -586,7 +641,7 @@ end context 'with dogstreams set to /path/to/log1:/path/to/parser' do let(:params) {{ :dogstreams => ['/path/to/log1:/path/to/parser'], - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^dogstreams: \/path\/to\/log1:\/path\/to\/parser\n/, @@ -594,7 +649,7 @@ end context 'with custom_emitters set to /test/emitter' do let(:params) {{ :custom_emitters => '/test/emitter/', - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^custom_emitters: \/test\/emitter\/\n/, @@ -602,7 +657,7 @@ end context 'with custom_emitters set to /test/emitter' do let(:params) {{ :custom_emitters => '/test/emitter/', - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^custom_emitters: \/test\/emitter\/\n/, @@ -610,7 +665,7 @@ end context 'with collector_log_file set to /test/log' do let(:params) {{ :collector_log_file => '/test/log', - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^collector_log_file: \/test\/log\n/, @@ -618,7 +673,7 @@ end context 'with forwarder_log_file set to /test/log' do let(:params) {{ :forwarder_log_file => '/test/log', - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^forwarder_log_file: \/test\/log\n/, @@ -626,7 +681,7 @@ end context 'with forwarder_log_file set to /test/log' do let(:params) {{ :forwarder_log_file => '/test/log', - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^forwarder_log_file: \/test\/log\n/, @@ -634,7 +689,7 @@ end context 'with dogstatsd_log_file set to /test/log' do let(:params) {{ :dogstatsd_log_file => '/test/log', - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^dogstatsd_log_file: \/test\/log\n/, @@ -642,7 +697,7 @@ end context 'with pup_log_file set to /test/log' do let(:params) {{ :pup_log_file => '/test/log', - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^pup_log_file: \/test\/log\n/, @@ -650,7 +705,7 @@ end context 'with syslog location set to localhost' do let(:params) {{ :syslog_host => 'localhost', - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^syslog_host: localhost\n/, @@ -658,7 +713,7 @@ end context 'with syslog port set to 8080' do let(:params) {{ :syslog_port => '8080', - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^syslog_port: 8080\n/, @@ -666,7 +721,7 @@ end context 'with syslog port set to 8080, specified as an integer' do let(:params) {{ :syslog_port => 8080, - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^syslog_port: 8080\n/, @@ -674,7 +729,7 @@ end context 'with apm_enabled set to true' do let(:params) {{ :apm_enabled => true, - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^apm_enabled: true\n/, @@ -683,7 +738,7 @@ context 'with apm_enabled set to true and env specified' do let(:params) {{ :apm_enabled => true, :apm_env => 'foo', - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^apm_enabled: true\n/, @@ -700,7 +755,7 @@ end context 'with apm_enabled and apm_analyzed_spans set' do let(:params) {{ :apm_enabled => true, - :agent5_enable => true, + :agent_major_version => 5, :apm_analyzed_spans => { 'foo|bar' => 0.5, 'haz|qux' => 0.1 @@ -723,9 +778,9 @@ let(:params) {{ :service_discovery_backend => 'docker', :sd_config_backend => 'etcd', :sd_backend_host => 'localhost', - :sd_backend_port => '8080', + :sd_backend_port => 8080, :sd_jmx_enable => true, - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^service_discovery_backend: docker\n/, @@ -745,7 +800,7 @@ end context 'with extra_template enabled' do let(:params) {{ :extra_template => 'custom_datadog/extra_template_test.erb', - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog extra_template footer').with( 'order' => '06', @@ -761,7 +816,7 @@ let(:params) {{ :apm_enabled => true, :apm_env => 'foo', - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog apm footer').with( 'order' => '07', @@ -770,7 +825,7 @@ context 'with APM enabled but no APM env' do let(:params) {{ :apm_enabled => true, - :agent5_enable => true, + :agent_major_version => 5, }} it { should_not contain_concat__fragment('datadog apm footer').with( 'order' => '07', @@ -781,7 +836,7 @@ :extra_template => 'custom_datadog/extra_template_test.erb', :apm_enabled => true, :apm_env => 'foo', - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog extra_template footer').with( 'order' => '06', @@ -795,7 +850,7 @@ end context 'with process_agent enabled' do let(:params) {{ :process_enabled => true, - :agent5_enable => true, + :agent_major_version => 5, }} it { should contain_concat__fragment('datadog footer').with( 'content' => /^process_agent_enabled: true\n/, @@ -805,7 +860,7 @@ context 'with data scrubbing disabled' do let(:params) {{ :process_enabled => true, - :agent5_enable => true, + :agent_major_version => 5, :scrub_args => false }} it { should contain_concat__fragment('datadog footer').with( @@ -825,7 +880,7 @@ context 'with data scrubbing enabled with custom sensitive_words' do let(:params) {{ :process_enabled => true, - :agent5_enable => true, + :agent_major_version => 5, :custom_sensitive_words => ['consul_token','dd_key'] }} it { should contain_concat__fragment('datadog footer').with( @@ -863,21 +918,21 @@ if DEBIAN_OS.include?(operatingsystem) it do - should contain_class('datadog_agent::ubuntu::agent5')\ + should contain_class('datadog_agent::ubuntu')\ .with_apt_keyserver('hkp://keyserver.ubuntu.com:80') end context 'use backup keyserver' do let(:params) {{ :use_apt_backup_keyserver => true, - :agent5_enable => true, + :agent_major_version => 5, }} it do - should contain_class('datadog_agent::ubuntu::agent5')\ + should contain_class('datadog_agent::ubuntu')\ .with_apt_keyserver('hkp://pool.sks-keyservers.net:80') end end elsif REDHAT_OS.include?(operatingsystem) - it { should contain_class('datadog_agent::redhat::agent5') } + it { should contain_class('datadog_agent::redhat') } end end end @@ -1048,16 +1103,16 @@ :proxy_password => 'abcd1234', }} it { is_expected.to contain_notify( - 'Setting proxy_host will have no effect on agent6 please use agent6_extra_options to set your proxy') + 'Setting proxy_host is only used with Agent 5. Please use agent_extra_options to set your proxy') } it { is_expected.to contain_notify( - 'Setting proxy_port will have no effect on agent6 please use agent6_extra_options to set your proxy') + 'Setting proxy_port is only used with Agent 5. Please use agent_extra_options to set your proxy') } it { is_expected.to contain_notify( - 'Setting proxy_user will have no effect on agent6 please use agent6_extra_options to set your proxy') + 'Setting proxy_user is only used with Agent 5. Please use agent_extra_options to set your proxy') } it { is_expected.to contain_notify( - 'Setting proxy_password will have no effect on agent6 please use agent6_extra_options to set your proxy') + 'Setting proxy_password is only used with Agent 5. Please use agent_extra_options to set your proxy') } end context 'deprecated proxy settings with default values' do @@ -1068,16 +1123,16 @@ :proxy_password => '', }} it { is_expected.not_to contain_notify( - 'Setting proxy_host will have no effect on agent6 please use agent6_extra_options to set your proxy') + 'Setting proxy_host is only used with Agent 5. Please use agent_extra_options to set your proxy') } it { is_expected.not_to contain_notify( - 'Setting proxy_port will have no effect on agent6 please use agent6_extra_options to set your proxy') + 'Setting proxy_port is only used with Agent 5. Please use agent_extra_options to set your proxy') } it { is_expected.not_to contain_notify( - 'Setting proxy_user will have no effect on agent6 please use agent6_extra_options to set your proxy') + 'Setting proxy_user is only used with Agent 5. Please use agent_extra_options to set your proxy') } it { is_expected.not_to contain_notify( - 'Setting proxy_password will have no effect on agent6 please use agent6_extra_options to set your proxy') + 'Setting proxy_password is only used with Agent 5. Please use agent_extra_options to set your proxy') } end end @@ -1087,7 +1142,7 @@ let(:params) {{ :apm_enabled => true, :apm_env => 'foo', - :agent6_extra_options => { + :agent_extra_options => { 'apm_config' => { 'foo' => 'bar', 'bar' => 'haz', @@ -1147,7 +1202,7 @@ let(:params) {{ :apm_enabled => false, :process_enabled => true, - :agent6_extra_options => { + :agent_extra_options => { 'process_config' => { 'foo' => 'bar', 'bar' => 'haz', @@ -1176,7 +1231,7 @@ context 'with extra_options and process options overriden' do let(:params) {{ :process_enabled => true, - :agent6_extra_options => { + :agent_extra_options => { 'process_config' => { 'enabled' => 'disabled', 'foo' => 'bar', diff --git a/spec/classes/datadog_agent_ubuntu_spec.rb b/spec/classes/datadog_agent_ubuntu_spec.rb index 372fa548..1d44fbf5 100644 --- a/spec/classes/datadog_agent_ubuntu_spec.rb +++ b/spec/classes/datadog_agent_ubuntu_spec.rb @@ -1,137 +1,213 @@ require 'spec_helper' -describe 'datadog_agent::ubuntu::agent5' do +describe 'datadog_agent::ubuntu' do - if RSpec::Support::OS.windows? - return - end + context 'agent 5' do + let(:params){ {:agent_major_version => 5} } - let(:facts) do - { - osfamily: 'debian', - operatingsystem: 'Ubuntu' - } - end + if RSpec::Support::OS.windows? + return + end - it do - 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}) - end + let(:facts) do + { + osfamily: 'debian', + operatingsystem: 'Ubuntu' + } + end - # it should install the mirror - it { should_not contain_apt__key('Add key: 935F5A436A5A6E8788F0765B226AE980C7A7DA52 from Apt::Source datadog') } - it do - should contain_apt__key('Add key: A2923DFF56EDA6E76E55E492D3A80E30382E94DE from Apt::Source datadog') - end - context 'overriding keyserver' do - let(:params) {{ - apt_keyserver: 'hkp://pool.sks-keyservers.net:80', - }} it do - should contain_apt__key('Add key: A2923DFF56EDA6E76E55E492D3A80E30382E94DE from Apt::Source datadog')\ - .with_server('hkp://pool.sks-keyservers.net:80') + should contain_file('/etc/apt/sources.list.d/datadog5.list') + .with_ensure('absent') + should contain_file('/etc/apt/sources.list.d/datadog6.list') + .with_ensure('absent') + should contain_file('/etc/apt/sources.list.d/datadog.list')\ + .with_content(%r{deb\s+https://apt.datadoghq.com/\s+stable\s+main}) end - end - it do - should contain_file('/etc/apt/sources.list.d/datadog.list')\ - .that_notifies('exec[apt_update]') - end - it { should contain_exec('apt_update') } + # it should install the mirror + it { should_not contain_apt__key('Add key: 935F5A436A5A6E8788F0765B226AE980C7A7DA52 from Apt::Source datadog') } + it do + should contain_apt__key('Add key: A2923DFF56EDA6E76E55E492D3A80E30382E94DE from Apt::Source datadog') + end + context 'overriding keyserver' do + let(:params) {{ + apt_keyserver: 'hkp://pool.sks-keyservers.net:80', + }} + it do + should contain_apt__key('Add key: A2923DFF56EDA6E76E55E492D3A80E30382E94DE from Apt::Source datadog')\ + .with_server('hkp://pool.sks-keyservers.net:80') + end + end - # it should install the packages - it do - should contain_package('datadog-agent-base')\ - .with_ensure('absent')\ - .that_comes_before('package[datadog-agent]') - end - it do - should contain_package('datadog-agent')\ - .that_requires('file[/etc/apt/sources.list.d/datadog.list]')\ - .that_requires('exec[apt_update]') - end + it do + should contain_file('/etc/apt/sources.list.d/datadog.list')\ + .that_notifies('exec[apt_update]') + end + it { should contain_exec('apt_update') } - # it should be able to start the service and enable the service by default - it do - should contain_service('datadog-agent')\ - .that_requires('package[datadog-agent]') - end + # it should install the packages + it do + should contain_package('datadog-agent-base')\ + .with_ensure('absent')\ + .that_comes_before('package[datadog-agent]') + end + it do + should contain_package('datadog-agent')\ + .that_requires('file[/etc/apt/sources.list.d/datadog.list]')\ + .that_requires('exec[apt_update]') + end - context 'overriding provider' do - let(:params) {{ - service_provider: 'upstart', - }} + # it should be able to start the service and enable the service by default it do should contain_service('datadog-agent')\ .that_requires('package[datadog-agent]') end - it do - should contain_service('datadog-agent').with( - 'provider' => 'upstart', - 'ensure' => 'running', - ) + + context 'overriding provider' do + let(:params) {{ + service_provider: 'upstart', + }} + it do + should contain_service('datadog-agent')\ + .that_requires('package[datadog-agent]') + end + it do + should contain_service('datadog-agent').with( + 'provider' => 'upstart', + 'ensure' => 'running', + ) + end end end -end -describe 'datadog_agent::ubuntu::agent6' do - let(:facts) do - { - osfamily: 'debian', - operatingsystem: 'Ubuntu' - } - end + context 'agent 6' do - it do - contain_file('/etc/apt/sources.list.d/datadog.list') - .with_ensure('absent') - contain_file('/etc/apt/sources.list.d/datadog6.list')\ - .with_content(%r{deb\s+https://apt.datadoghq.com/\s+beta\s+main}) - end + let(:params){ {:agent_major_version => 6} } - # it should install the mirror - it { should_not contain_apt__key('Add key: 935F5A436A5A6E8788F0765B226AE980C7A7DA52 from Apt::Source datadog6') } - it { should contain_apt__key('Add key: A2923DFF56EDA6E76E55E492D3A80E30382E94DE from Apt::Source datadog6') } + let(:facts) do + { + osfamily: 'debian', + operatingsystem: 'Ubuntu' + } + end - it do - should contain_file('/etc/apt/sources.list.d/datadog6.list')\ - .that_notifies('exec[apt_update]') - end - it { should contain_exec('apt_update') } + it do + should contain_file('/etc/apt/sources.list.d/datadog5.list') + .with_ensure('absent') + should contain_file('/etc/apt/sources.list.d/datadog6.list') + .with_ensure('absent') + should contain_file('/etc/apt/sources.list.d/datadog.list')\ + .with_content(%r{deb\s+https://apt.datadoghq.com/\s+stable\s+6}) + end - # it should install the packages - it do - should contain_package('datadog-agent-base')\ - .with_ensure('absent')\ - .that_comes_before('package[datadog-agent]') - end - it do - should contain_package('datadog-agent')\ - .that_requires('file[/etc/apt/sources.list.d/datadog6.list]')\ - .that_requires('exec[apt_update]') - end + # it should install the mirror + it { should_not contain_apt__key('Add key: 935F5A436A5A6E8788F0765B226AE980C7A7DA52 from Apt::Source datadog') } + it { should contain_apt__key('Add key: A2923DFF56EDA6E76E55E492D3A80E30382E94DE from Apt::Source datadog') } - # it should be able to start the service and enable the service by default - it do - should contain_service('datadog-agent')\ - .that_requires('package[datadog-agent]') - end + it do + should contain_file('/etc/apt/sources.list.d/datadog6.list')\ + .that_notifies('exec[apt_update]') + end + it { should contain_exec('apt_update') } + + # it should install the packages + it do + should contain_package('datadog-agent-base')\ + .with_ensure('absent')\ + .that_comes_before('package[datadog-agent]') + end + it do + should contain_package('datadog-agent')\ + .that_requires('file[/etc/apt/sources.list.d/datadog6.list]')\ + .that_requires('exec[apt_update]') + end - context 'overriding provider' do - let(:params) {{ - service_provider: 'upstart', - }} + # it should be able to start the service and enable the service by default it do should contain_service('datadog-agent')\ .that_requires('package[datadog-agent]') end + + context 'overriding provider' do + let(:params) {{ + service_provider: 'upstart', + }} + it do + should contain_service('datadog-agent')\ + .that_requires('package[datadog-agent]') + end + it do + should contain_service('datadog-agent').with( + 'provider' => 'upstart', + 'ensure' => 'running', + ) + end + end + end + + context 'agent 7' do + + let(:params){ {:agent_major_version => 7} } + + let(:facts) do + { + osfamily: 'debian', + operatingsystem: 'Ubuntu' + } + end + it do - should contain_service('datadog-agent').with( - 'provider' => 'upstart', - 'ensure' => 'running', - ) + should contain_file('/etc/apt/sources.list.d/datadog5.list') + .with_ensure('absent') + should contain_file('/etc/apt/sources.list.d/datadog6.list') + .with_ensure('absent') + should contain_file('/etc/apt/sources.list.d/datadog.list')\ + .with_content(%r{deb\s+https://apt.datadoghq.com/\s+stable\s+7}) + end + + # it should install the mirror + it { should_not contain_apt__key('Add key: 935F5A436A5A6E8788F0765B226AE980C7A7DA52 from Apt::Source datadog') } + it { should contain_apt__key('Add key: A2923DFF56EDA6E76E55E492D3A80E30382E94DE from Apt::Source datadog') } + + it do + should contain_file('/etc/apt/sources.list.d/datadog6.list')\ + .that_notifies('exec[apt_update]') + end + it { should contain_exec('apt_update') } + + # it should install the packages + it do + should contain_package('datadog-agent-base')\ + .with_ensure('absent')\ + .that_comes_before('package[datadog-agent]') + end + it do + should contain_package('datadog-agent')\ + .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 + it do + should contain_service('datadog-agent')\ + .that_requires('package[datadog-agent]') + end + + context 'overriding provider' do + let(:params) {{ + service_provider: 'upstart', + }} + it do + should contain_service('datadog-agent')\ + .that_requires('package[datadog-agent]') + end + it do + should contain_service('datadog-agent').with( + 'provider' => 'upstart', + 'ensure' => 'running', + ) + end end end end diff --git a/spec/defines/datadog_agent__integration_spec.rb b/spec/defines/datadog_agent__integration_spec.rb index 87e03e24..4aba27db 100644 --- a/spec/defines/datadog_agent__integration_spec.rb +++ b/spec/defines/datadog_agent__integration_spec.rb @@ -2,12 +2,12 @@ describe "datadog_agent::integration" do context 'supported agents' do - ALL_SUPPORTED_AGENTS.each do |_, is_agent5| - let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" } - if is_agent5 + ALL_SUPPORTED_AGENTS.each do |agent_major_version| + let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + if agent_major_version == 5 let(:conf_file) { '/etc/dd-agent/conf.d/test.yaml' } else - let(:conf_dir) { "#{CONF_DIR6}/test.d" } + let(:conf_dir) { "#{CONF_DIR}/test.d" } let(:conf_file) { "#{conf_dir}/conf.yaml" } end @@ -19,7 +19,7 @@ }} it { should compile } - if is_agent5 + if agent_major_version == 5 it { should contain_file("#{conf_dir}").that_comes_before("File[#{conf_file}]") } end it { should contain_file("#{conf_file}").with_content(/init_config: /) } diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index dd8bd262..89e93279 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -9,8 +9,8 @@ if RSpec::Support::OS.windows? ALL_OS = WINDOWS_OS - ALL_SUPPORTED_AGENTS = { '6' => false } # Boolean means "is agent 5". TODO: Refactor this. - CONF_DIR6 = 'C:/ProgramData/Datadog/conf.d' + ALL_SUPPORTED_AGENTS = [ 6, 7 ] + CONF_DIR = 'C:/ProgramData/Datadog/conf.d' DD_USER = 'ddagentuser' DD_GROUP = 'S-1-5-32-544' SERVICE_NAME = 'datadogagent' @@ -19,10 +19,10 @@ PERMISSIONS_PROTECTED_FILE = '0660' else ALL_OS = DEBIAN_OS + REDHAT_OS - ALL_SUPPORTED_AGENTS = { '5' => true, '6' => false } # Boolean means "is agent 5". TODO: Refactor this. - CONF_DIR6 = '/etc/datadog-agent/conf.d' + ALL_SUPPORTED_AGENTS = [ 5, 6, 7 ] + CONF_DIR = '/etc/datadog-agent/conf.d' DD_USER = 'dd-agent' - DD_GROUP = 'root' + DD_GROUP = 'dd-agent' SERVICE_NAME = 'datadog-agent' PACKAGE_NAME = 'datadog-agent' PERMISSIONS_FILE = '0644' diff --git a/templates/datadog6.yaml.erb b/templates/datadog.yaml.erb similarity index 100% rename from templates/datadog6.yaml.erb rename to templates/datadog.yaml.erb