diff --git a/Gemfile.lock b/Gemfile.lock index 49ac4af6..17714d01 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -485,11 +485,12 @@ PLATFORMS ruby DEPENDENCIES + concurrent-ruby (= 1.1.10) fast_gettext kitchen-docker kitchen-puppet kitchen-verifier-serverspec - librarian-puppet + librarian-puppet (<= 4.0.1) mixlib-shellout (~> 2.2.7) puppet (~> 7.0.0) puppet-module-posix-default-r2.7 @@ -500,6 +501,7 @@ DEPENDENCIES rubocop-i18n (~> 1.2.0) rubocop-rspec (~> 1.16.0) ruby-pwsh (~> 0.3.0) + semantic_puppet (= 1.0.4) test-kitchen (~> 2.5.4) xmlrpc diff --git a/environments/etc/manifests/site.pp b/environments/etc/manifests/site.pp index 78fde18d..dc594938 100644 --- a/environments/etc/manifests/site.pp +++ b/environments/etc/manifests/site.pp @@ -1,9 +1,8 @@ node default { - class { 'datadog_agent': api_key => 'somenonnullapikeythats32charlong', agent_extra_options => { - use_http => true, + use_http => true, }, # Hostname is necessary for Agent to start up properly in container since 7.40.0 # https://github.com/DataDog/datadog-agent/issues/14152#issuecomment-1301842615 @@ -24,5 +23,4 @@ username => 'status', password => 'hunter1', } - } diff --git a/functions/tag6.pp b/functions/tag6.pp index 8e63a1c1..8c02abbf 100644 --- a/functions/tag6.pp +++ b/functions/tag6.pp @@ -9,7 +9,7 @@ function datadog_agent::tag6( ) { if $tag_names =~ Array { $tags = $tag_names.reduce([]) |$_tags , $tag| { - concat($_tags, datadog_agent::tag6($tag, $lookup_fact, $lookup_table)) + concat($_tags, datadog_agent::tag6($tag, $lookup_fact, $lookup_table)) } } else { if $lookup_fact =~ String { diff --git a/manifests/init.pp b/manifests/init.pp index d52a9111..be0d2dac 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -3,243 +3,297 @@ # This class contains the agent installation mechanism for the Datadog module # # Parameters: -# $dd_url: +# @param dd_url # The host of the Datadog intake server to send agent data to. # Defaults to https://app.datadoghq.com. -# $datadog_site: +# @param datadog_site # The site of the Datadog intake to send Agent data to. Defaults to 'datadoghq.com', # can be set to 'datadoghq.eu' to send data to the EU site or 'us3.datadoghq.com'. # This option is only available with agent version >= 6.6.0. -# $host: +# @param host # Force the hostname to whatever you want. (default: auto-detected) -# $api_key: +# @param api_key # Your DataDog API Key. Please replace with your key value. -# $agent_flavor: +# @param agent_flavor # Linux-only. The Agent flavor to install, eg: "datadog-agent" or "datadog-iot-agent". -# $collect_ec2_tags +# @param collect_ec2_tags # Collect AWS EC2 custom tags as agent tags. # Boolean. Default: false -# $collect_gce_tags +# @param collect_gce_tags # Collect Google Cloud Engine metadata as agent tags. # Boolean. Default: false -# $collect_instance_metadata +# @param collect_instance_metadata # The Agent will try to collect instance metadata for EC2 and GCE instances. # Boolean. Default: true -# $tags +# @param tags # Optional array of tags. -# $hiera_tags +# @param hiera_tags # Boolean to grab tags from hiera to allow merging -# $facts_to_tags +# @param facts_to_tags # Optional array of facts' names that you can use to define tags following the scheme: "fact_name:fact_value". # See also trusted_facts_to_tags. # Note: this is not for Puppet Report Tags. See report_fact_tags -# $trusted_facts_to_tags +# @param trusted_facts_to_tags # Optional array of trusted facts' names that you can use to define tags following # the scheme: "fact_name:fact_value". # Note: this is not for Puppet Report Tags. See report_trusted_fact_tags -# $puppet_run_reports +# @param puppet_run_reports # Will send results from your puppet agent runs back to the datadog service. -# $reports_url +# @param reports_url # The URL to use when sending puppet run reports. Default: https://api.${datadog_site} -# $manage_dogapi_gem +# @param manage_dogapi_gem # When reports are enabled, ensure the dogapi gem (required) is installed. -# $puppetmaster_user +# @param puppetmaster_user # Will chown the api key used by the report processor to this user. # Defaults to the user the puppetmaster is configured to run as. -# $non_local_traffic +# @param non_local_traffic # Enable you to use the agent as a proxy. Defaults to false. # See https://github.com/DataDog/dd-agent/wiki/Proxy-Configuration -# $dogstreams -# Optional array of logs to parse and custom parsers to use. -# See https://github.com/DataDog/dd-agent/blob/ed5e698/datadog.conf.example#L149-L178 -# $log_level +# @param log_level # Set value of 'log_level' variable. Default is 'info' as in dd-agent. # Valid values here are: critical, debug, error, fatal, info, warn and warning. -# $hostname_extraction_regex +# @param hostname_extraction_regex # Completely optional. # Instead of reporting the puppet nodename, use this regex to extract the named # 'hostname' captured group to report the run in Datadog. # ex.: '^(?.*\.datadoghq\.com)(\.i-\w{8}\..*)?$' -# $hostname_fqdn +# @param hostname_fqdn # Make the agent use "hostname -f" on unix-based systems as a last resort # way of determining the hostname instead of Golang "os.Hostname()" # This will be enabled by default in version 6.6 # More information at https://dtdg.co/flag-hostname-fqdn # Optional: Valid values here are: true or false. -# $log_to_syslog +# @param log_to_syslog # Set value of 'log_to_syslog' variable. Default is true -> yes as in dd-agent. # Valid values here are: true or false. -# $report_fact_tags +# @param report_fact_tags # Sets tags for report events sent to Datadog from specified facts -# $report_trusted_fact_tags +# @param report_trusted_fact_tags # Sets tags for report events sent to Datadog from specified trusted facts -# $statsd_forward_host +# @param statsd_forward_host # Set the value of the statsd_forward_host varable. Used to forward all # statsd metrics to another host. -# $manage_repo +# @param manage_repo # Deprecated. Only works for RPM. Install datadog-agent manually and then set # manage_install=false to achieve the same behaviour as setting this to false. -# $manage_install +# @param manage_install # Boolean to indicate whether this module should attempt to install the # Agent, or assume it will be installed by other means. Default true. -# $graphite_listen_port +# @param graphite_listen_port # Set graphite listener port -# $extra_template +# @param extra_template # Optional, append this extra template file at the end of # the default datadog.conf template -# $skip_apt_key_trusting +# @param skip_apt_key_trusting # Skip trusting the apt key. Default is false. Useful if you have a # separate way of adding keys. -# $skip_ssl_validation +# @param skip_ssl_validation # Skip SSL validation. -# $use_curl_http_client +# @param use_curl_http_client # Uses the curl HTTP client for the forwarder -# $recent_point_threshold +# @param recent_point_threshold # Sets the threshold for accepting points. # String. Default: empty (30 second intervals) -# $listen_port +# @param listen_port # Change the port that the agent listens on # String. Default: empty (port 17123 in dd-agent) -# $additional_checksd +# @param additional_checksd # Additional directory to look for datadog checks in # String. Default: undef -# $bind_host +# @param bind_host # The loopback address the forwarder and Dogstatsd will bind. # String. Default: empty -# $use_pup +# @param use_pup # Enables the local pup dashboard # Boolean. Default: false -# $pup_port +# @param pup_port # Specifies the port to be used by pup. Must have use_pup set # String. Default: empty -# $pup_interface +# @param pup_interface # Specifies which interface pup will use. Must have use_pup set # String. Default: empty -# $pup_url +# @param pup_url # Specifies the URL used to access pup. Must have use_pup set # String. Default: empty -# $use_dogstatsd +# @param use_dogstatsd # Enables the dogstatsd server # Boolean. Default: true -# $dogstatsd_socket +# @param dogstatsd_socket # Specifies the socket file to be used by dogstatsd. Must have use_dogstatsd set # String. Default: empty -# $dogstatsd_port +# @param dogstatsd_port # Specifies the port to be used by dogstatsd. Must have use_dogstatsd set # String. Default: 8125 -# $dogstatsd_target +# @param dogstatsd_target # Change the target to be used by dogstatsd. Must have use_dogstatsd set # set # String. Default: empty -# $dogstatsd_interval +# @param dogstatsd_interval # Change the dogstatsd flush period. Must have use_dogstatsd set # String. Default: empty ( 10 second interval) -# $dogstatsd_normalize +# @param dogstatsd_normalize # Enables 1 second nomralization. Must have use_dogstatsd set # Boolean. Default: true -# $statsd_forward_host -# Enables forwarding of statsd packetsto host. Must have use_dogstatsd set -# String. Default: empty -# $statsd_forward_port +# @param statsd_forward_port # Specifies port for $statsd_forward_host. Must have use_dogstatsd set String. # Used to forward all statsd metrics to another host. # Default: empty -# $device_blacklist_re +# @param device_blacklist_re # Specifies pattern for device blacklisting. # String. Default: empty -# $ganglia_host +# @param ganglia_host # Specifies host where gmetad is running # String. Default: empty -# $ganglia_port +# @param ganglia_port # Specifies port for $ganglia_host # String. Default: empty -# $dogstreams +# @param dogstreams # Specifies port for list of logstreams/modules to be used. # String. Default: empty -# $custom_emitters -# Specifies a comma seperated list of non standard emitters to be used -# String. Default: empty -# $custom_emitters +# @param custom_emitters # Specifies a comma seperated list of non standard emitters to be used # String. Default: empty -# $agent_log_file +# @param agent_log_file # Specifies the log file location (Agent 6 and 7 only). # String. Default: empty -# $collector_log_file +# @param collector_log_file # Specifies the log file location for the collector system # String. Default: empty -# $forwarder_log_file +# @param forwarder_log_file # Specifies the log file location for the forwarder system # String. Default: empty -# $dogstatsd -# Specifies the log file location for the dogstatsd system -# String. Default: empty -# $pup_log_file +# @param pup_log_file # Specifies the log file location for the pup system # String. Default: empty -# $apm_enabled +# @param apm_enabled # Boolean to enable or disable the trace agent # Boolean. Default: false -# $apm_env +# @param apm_env # String defining the environment for the APM traces # String. Default: non -# $apm_non_local_traffic +# @param apm_non_local_traffic # Accept non local apm traffic. Defaults to false. # Boolean. Default: false -# $apm_analyzed_spans +# @param apm_analyzed_spans # Hash defining the APM spans to analyze and their rates. # Optional Hash. Default: undef. -# $apm_obfuscation +# @param apm_obfuscation # Hash defining obfuscation rules for sensitive data. (Agent 6 and 7 only). # Optional Hash. Default: undef -# $process_enabled +# @param process_enabled # String to enable the process/container agent # Boolean. Default: false -# $scrub_args +# @param scrub_args # Boolean to enable or disable the process cmdline scrubbing by the process-agent # Boolean. Default: true -# $custom_sensitive_words +# @param custom_sensitive_words # Array to add more words to be used on the process cdmline scrubbing by the process-agent # Array. Default: [] -# $logs_enabled +# @param logs_enabled # Boolean to enable or disable the logs agent # Boolean. Default: false -# $logs_open_files_limit +# @param logs_open_files_limit # Integer set the max number of open files for the logs agent # Integer. Default: 100 if undef -# $container_collect_all +# @param container_collect_all # Boolean to enable logs collection for all containers # Boolean. Default: false -# $cmd_port +# @param cmd_port # The port on which the IPC api listens # Integer. Default: 5001 -# $agent_repo_uri +# @param 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 -# $rpm_repo_gpgcheck +# @param rpm_repo_gpgcheck # Whether or not to perform repodata signature check for RPM repositories. # Applies to Red Hat and SUSE platforms. When set to `undef`, this is activated # for all Agent versions other than 5 when `agent_repo_uri` is also undefinded. # The `undef` value also translates to `false` on RHEL/CentOS 8.1 because # of a bug in libdnf: https://bugzilla.redhat.com/show_bug.cgi?id=1792506 # Boolean. Default: undef -# $apt_release +# @param apt_release # The distribution channel to be used for the APT repo. Eg: 'stable' or 'beta'. # String. Default: stable -# $windows_npm_install +# @param windows_npm_install # (Windows only) Boolean to install the Windows NPM driver. # To use NPM features it is necessary to enable install through this flag, as well as # configuring NPM through the datadog::system_probe class. # Boolean. Default: false -# $windows_ddagentuser_name +# @param windows_ddagentuser_name # (Windows only) The name of Windows user to use, in the format `\`. # -# $windows_ddagentuser_password +# @param windows_ddagentuser_password # (Windows only) The password used to register the service`. # +# @param integrations +# +# @param hiera_integrations +# +# @param puppet_gem_provider +# +# @param service_ensure +# +# @param service_enable +# +# @param statsd_histogram_percentiles +# +# @param proxy_host +# +# @param proxy_port +# +# @param proxy_user +# +# @param proxy_password +# +# @param dogstatsd_log_file +# +# @param syslog_host +# +# @param syslog_port +# +# @param service_discovery_backend +# +# @param sd_config_backend +# +# @param sd_backend_host +# +# @param sd_backend_port +# +# @param sd_template_dir +# +# @param sd_jmx_enable +# +# @param consul_token +# +# @param agent_major_version +# +# @param conf_dir +# +# @param conf_dir_purge +# +# @param dd_group +# +# @param dd_groups +# +# @param agent_extra_options +# +# @param use_apt_backup_keyserver +# +# @param apt_backup_keyserver +# +# @param apt_keyserver +# +# @param win_msi_location +# +# @param win_ensure +# +# @param service_provider +# +# @param agent_version +# # Sample Usage: # # include datadog_agent @@ -254,18 +308,18 @@ # } # # -class datadog_agent( - String $dd_url = '', +class datadog_agent ( + Optional[String] $dd_url = undef, String $datadog_site = $datadog_agent::params::datadog_site, - String $host = '', + Optional[String] $host = undef, String $api_key = 'your_API_key', Enum['datadog-agent', 'Datadog Agent', 'datadog-iot-agent'] $agent_flavor = $datadog_agent::params::package_name, Boolean $collect_ec2_tags = false, Boolean $collect_gce_tags = false, Boolean $collect_instance_metadata = true, Array $tags = [], - $integrations = {}, - $hiera_integrations = false, + Hash $integrations = {}, + Boolean $hiera_integrations = false, Boolean $hiera_tags = false, Array $facts_to_tags = [], Array $trusted_facts_to_tags = [], @@ -277,65 +331,65 @@ Array $dogstreams = [], String $log_level = 'info', Boolean $log_to_syslog = true, - $service_ensure = 'running', - $service_enable = true, + String $service_ensure = 'running', + Boolean $service_enable = true, Boolean $manage_repo = true, Boolean $manage_dogapi_gem = true, Boolean $manage_install = true, - $hostname_extraction_regex = undef, + Optional[String] $hostname_extraction_regex = undef, Boolean $hostname_fqdn = false, Variant[Stdlib::Port, Pattern[/^\d*$/]] $dogstatsd_port = 8125, - $dogstatsd_socket = '', + Optional[String] $dogstatsd_socket = undef, Array $report_fact_tags = [], Array $report_trusted_fact_tags = [], - String $statsd_forward_host = '', - Variant[Stdlib::Port, Pattern[/^\d*$/]] $statsd_forward_port = '', + Optional[String] $statsd_forward_host = undef, + Optional[Variant[Stdlib::Port, Pattern[/^\d*$/]]] $statsd_forward_port = undef, 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, - Variant[Stdlib::Port, Pattern[/^\d*$/]] $graphite_listen_port = '', - String $extra_template = '', - String $ganglia_host = '', - $ganglia_port = 8651, + Optional[Variant[Stdlib::Port, Pattern[/^\d*$/]]] $graphite_listen_port = undef, + Optional[String] $extra_template = undef, + Optional[String] $ganglia_host = undef, + Variant[Stdlib::Port, Pattern[/^\d*$/]] $ganglia_port = 8651, Boolean $skip_ssl_validation = false, Boolean $skip_apt_key_trusting = false, Boolean $use_curl_http_client = false, - String $recent_point_threshold = '', - Variant[Stdlib::Port, Pattern[/^\d*$/]] $listen_port = '', + Optional[String] $recent_point_threshold = undef, + Optional[Variant[Stdlib::Port, Pattern[/^\d*$/]]] $listen_port = undef, Optional[String] $additional_checksd = undef, - String $bind_host = '', + Optional[String] $bind_host = undef, Boolean $use_pup = false, - Variant[Stdlib::Port, Pattern[/^\d*$/]] $pup_port = '', - String $pup_interface = '', - String $pup_url = '', + Optional[Variant[Stdlib::Port, Pattern[/^\d*$/]]] $pup_port = undef, + Optional[String] $pup_interface = undef, + Optional[String] $pup_url = undef, Boolean $use_dogstatsd = true, - String $dogstatsd_target = '', - String $dogstatsd_interval = '', + Optional[String] $dogstatsd_target = undef, + Optional[String] $dogstatsd_interval = undef, Boolean $dogstatsd_normalize = true, - String $device_blacklist_re = '', - String $custom_emitters = '', + Optional[String] $device_blacklist_re = undef, + Optional[String] $custom_emitters = undef, 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 = '', - Variant[Stdlib::Port, Pattern[/^\d*$/]] $syslog_port = '', - String $service_discovery_backend = '', - String $sd_config_backend = '', - String $sd_backend_host = '', + Optional[String] $collector_log_file = undef, + Optional[String] $forwarder_log_file = undef, + Optional[String] $dogstatsd_log_file = undef, + Optional[String] $pup_log_file = undef, + Optional[String] $syslog_host = undef, + Optional[Variant[Stdlib::Port, Pattern[/^\d*$/]]] $syslog_port = undef, + Optional[String] $service_discovery_backend = undef, + Optional[String] $sd_config_backend = undef, + Optional[String] $sd_backend_host = undef, Integer $sd_backend_port = 0, - String $sd_template_dir = '', + Optional[String] $sd_template_dir = undef, Boolean $sd_jmx_enable = false, - String $consul_token = '', + Optional[String] $consul_token = undef, Integer $cmd_port = 5001, - Optional[Integer] $agent_major_version = undef, + Optional[Variant[Integer, String]] $agent_major_version = undef, Optional[String] $conf_dir = undef, Boolean $conf_dir_purge = $datadog_agent::params::conf_dir_purge, - $dd_group = $datadog_agent::params::dd_group, - $dd_groups = $datadog_agent::params::dd_groups, + String $dd_group = $datadog_agent::params::dd_group, + Optional[String] $dd_groups = $datadog_agent::params::dd_groups, Boolean $apm_enabled = $datadog_agent::params::apm_default_enabled, String $apm_env = 'none', Boolean $apm_non_local_traffic = false, @@ -345,7 +399,7 @@ 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, + Optional[Integer] $logs_open_files_limit = $datadog_agent::params::logs_open_files_limit, Boolean $container_collect_all = $datadog_agent::params::container_collect_all, Hash[String[1], Data] $agent_extra_options = {}, Optional[String] $agent_repo_uri = undef, @@ -364,7 +418,6 @@ Optional[String] $windows_ddagentuser_name = undef, Optional[String] $windows_ddagentuser_password = undef, ) 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 @@ -377,7 +430,7 @@ $_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 { + if versioncmp($_agent_major_version, '5') < 0 or versioncmp($_agent_major_version, '7') > 0 { fail("agent_major_version must be either 5, 6 or 7, not ${_agent_major_version}") } @@ -388,7 +441,7 @@ } if $conf_dir == undef { - if $_agent_major_version == 5 { + if versioncmp($_agent_major_version, '5') == 0 { $_conf_dir = $datadog_agent::params::legacy_conf_dir } else { $_conf_dir = $datadog_agent::params::conf_dir @@ -398,13 +451,13 @@ } if $hiera_tags { - $local_tags = lookup({ 'name' => 'datadog_agent::tags', 'merge' => 'unique', 'default_value' => []}) + $local_tags = lookup({ 'name' => 'datadog_agent::tags', 'merge' => 'unique', 'default_value' => [] }) } else { $local_tags = $tags } if $hiera_integrations { - $local_integrations = lookup({ 'name' => 'datadog_agent::integrations', 'default_value' => {}}) + $local_integrations = lookup({ 'name' => 'datadog_agent::integrations', 'default_value' => {} }) } else { $local_integrations = $integrations } @@ -514,14 +567,13 @@ } } - if $_agent_major_version == 5 { - + if versioncmp($_agent_major_version, '5') == 0 { if ($facts['os']['name'] == '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': } + notify { 'Setting agent_extra_options has no effect with Agent 5': } } file { '/etc/dd-agent': @@ -539,10 +591,10 @@ force => $conf_dir_purge, owner => $dd_user, group => $dd_group, - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } - concat {'/etc/dd-agent/datadog.conf': + concat { '/etc/dd-agent/datadog.conf': owner => $dd_user, group => $dd_group, mode => '0640', @@ -555,31 +607,31 @@ } else { $_dd_url = $dd_url } - concat::fragment{ 'datadog header': + concat::fragment { 'datadog header': target => '/etc/dd-agent/datadog.conf', content => template('datadog_agent/datadog_header.conf.erb'), order => '01', } - concat::fragment{ 'datadog tags': + concat::fragment { 'datadog tags': target => '/etc/dd-agent/datadog.conf', content => 'tags: ', order => '02', } - datadog_agent::tag5{$local_tags: } - datadog_agent::tag5{$facts_to_tags: + datadog_agent::tag5 { $local_tags: } + datadog_agent::tag5 { $facts_to_tags: lookup_fact => true, } - concat::fragment{ 'datadog footer': + concat::fragment { 'datadog footer': target => '/etc/dd-agent/datadog.conf', content => template('datadog_agent/datadog_footer.conf.erb'), order => '05', } unless $extra_template.empty { - concat::fragment{ 'datadog extra_template footer': + concat::fragment { 'datadog extra_template footer': target => '/etc/dd-agent/datadog.conf', content => template($extra_template), order => '06', @@ -587,7 +639,7 @@ } if ($apm_enabled == true) and (($apm_env != 'none') or $apm_analyzed_spans or $apm_obfuscation) { - concat::fragment{ 'datadog apm footer': + concat::fragment { 'datadog apm footer': target => '/etc/dd-agent/datadog.conf', content => template('datadog_agent/datadog_apm_footer.conf.erb'), order => '07', @@ -595,58 +647,57 @@ } if ($process_enabled == true) { - concat::fragment{ 'datadog process agent footer': + concat::fragment { 'datadog process agent footer': target => '/etc/dd-agent/datadog.conf', content => template('datadog_agent/datadog_process_footer.conf.erb'), order => '08', } } - file {'/etc/dd-agent/install_info': + file { '/etc/dd-agent/install_info': owner => $dd_user, group => $dd_group, mode => '0640', content => template('datadog_agent/install_info.erb'), require => File['/etc/dd-agent'], } - } else { #Agent 6/7 # notify of broken params on agent6/7 if !empty($proxy_host) { - notify { 'Setting proxy_host is only used with Agent 5. Please use agent_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 is only used with Agent 5. Please use agent_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 is only used with Agent 5. Please use agent_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 is only used with Agent 5. Please use agent_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 $process_enabled_str = $process_enabled ? { true => 'true' , default => 'disabled' } # lint:endignore $base_extra_config = { - 'apm_config' => { - 'enabled' => $apm_enabled, - 'env' => $apm_env, - 'apm_non_local_traffic' => $apm_non_local_traffic - }, - 'process_config' => { - 'enabled' => $process_enabled_str, - 'scrub_args' => $scrub_args, - 'custom_sensitive_words' => $custom_sensitive_words, - }, - 'logs_enabled' => $logs_enabled, + 'apm_config' => { + 'enabled' => $apm_enabled, + 'env' => $apm_env, + 'apm_non_local_traffic' => $apm_non_local_traffic, + }, + 'process_config' => { + 'enabled' => $process_enabled_str, + 'scrub_args' => $scrub_args, + 'custom_sensitive_words' => $custom_sensitive_words, + }, + 'logs_enabled' => $logs_enabled, } if $logs_open_files_limit { $logs_base_config = { 'logs_config' => { 'container_collect_all' => $container_collect_all, - 'open_files_limit' => $logs_open_files_limit + 'open_files_limit' => $logs_open_files_limit, }, } } else { @@ -657,65 +708,65 @@ } } if $host.empty { - $host_config = {} + $host_config = {} } else { - $host_config = { - 'hostname' => $host, - } + $host_config = { + 'hostname' => $host, + } } if $apm_analyzed_spans { - $apm_analyzed_span_config = { - 'apm_config' => { - 'analyzed_spans' => $apm_analyzed_spans - } - } + $apm_analyzed_span_config = { + 'apm_config' => { + 'analyzed_spans' => $apm_analyzed_spans, + }, + } } else { - $apm_analyzed_span_config = {} + $apm_analyzed_span_config = {} } if $apm_obfuscation { - $apm_obfuscation_config = { - 'apm_config' => { - 'obfuscation' => $apm_obfuscation - } - } + $apm_obfuscation_config = { + 'apm_config' => { + 'obfuscation' => $apm_obfuscation, + }, + } } else { - $apm_obfuscation_config = {} + $apm_obfuscation_config = {} } if $statsd_forward_host.empty { - $statsd_forward_config = {} + $statsd_forward_config = {} } else { - if String($statsd_forward_port).empty { - $statsd_forward_config = { - 'statsd_forward_host' => $statsd_forward_host, - } - } else { - $statsd_forward_config = { - 'statsd_forward_host' => $statsd_forward_host, - 'statsd_forward_port' => $statsd_forward_port, - } + if String($statsd_forward_port).empty { + $statsd_forward_config = { + 'statsd_forward_host' => $statsd_forward_host, + } + } else { + $statsd_forward_config = { + 'statsd_forward_host' => $statsd_forward_host, + 'statsd_forward_port' => $statsd_forward_port, } + } } if $additional_checksd { - $additional_checksd_config = { - 'additional_checksd' => $additional_checksd, - } + $additional_checksd_config = { + 'additional_checksd' => $additional_checksd, + } } else { - $additional_checksd_config = {} + $additional_checksd_config = {} } $extra_config = deep_merge( - $base_extra_config, - $logs_base_config, - $agent_extra_options, - $apm_analyzed_span_config, - $apm_obfuscation_config, - $statsd_forward_config, - $host_config, - $additional_checksd_config) + $base_extra_config, + $logs_base_config, + $agent_extra_options, + $apm_analyzed_span_config, + $apm_obfuscation_config, + $statsd_forward_config, + $host_config, + $additional_checksd_config) file { $_conf_dir: ensure => directory, @@ -724,7 +775,7 @@ force => $conf_dir_purge, owner => $dd_user, group => $dd_group, - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $_local_tags = datadog_agent::tag6($local_tags, false, undef) @@ -751,12 +802,9 @@ $agent_config = deep_merge($_agent_config, $extra_config) - if ($facts['os']['name'] == 'Windows') { - - file { 'C:/ProgramData/Datadog': - ensure => directory + ensure => directory, } file { 'C:/ProgramData/Datadog/datadog.yaml': @@ -776,9 +824,7 @@ content => template('datadog_agent/install_info.erb'), require => File['C:/ProgramData/Datadog'], } - } else { - file { '/etc/datadog-agent/datadog.yaml': owner => $dd_user, group => $dd_group, @@ -796,9 +842,7 @@ content => template('datadog_agent/install_info.erb'), require => File['/etc/datadog-agent'], } - } - } if $puppet_run_reports { @@ -827,5 +871,4 @@ } create_resources('datadog_agent::integration', $local_integrations) - } diff --git a/manifests/install_integration.pp b/manifests/install_integration.pp index ab661f10..42165136 100644 --- a/manifests/install_integration.pp +++ b/manifests/install_integration.pp @@ -1,14 +1,22 @@ +# Define datadog_agent::install_integration +# +# @param ensure +# +# @param integration_name +# +# @param version +# +# @param third_party +# define datadog_agent::install_integration ( Enum['present', 'absent'] $ensure = 'present', String $integration_name = undef, String $version = undef, Boolean $third_party = false, -){ - - require ::datadog_agent +) { + require datadog_agent if $ensure == 'present' { - if $third_party { $install_cmd = 'install --third-party' } else { @@ -31,5 +39,4 @@ notify => Service[$datadog_agent::params::service_name], } } - } diff --git a/manifests/integration.pp b/manifests/integration.pp index 7824c94c..db952c64 100644 --- a/manifests/integration.pp +++ b/manifests/integration.pp @@ -1,3 +1,17 @@ +# Define datadog_agent::integration +# +# @param instances +# +# @param init_config +# +# @param logs +# +# @param integration +# +# @param conf_file +# +# @param ensure +# define datadog_agent::integration ( Array $instances = [], Optional[Hash] $init_config = undef, @@ -5,13 +19,12 @@ String $integration = $title, String $conf_file = 'conf', Enum['present', 'absent'] $ensure = 'present', -){ - +) { # We can't `require ::datadog_agent` from here since this class is used by the # datadog_agent class, causing a dependency cycle. If using this class # directly, you should define datadog_agent before datadog_agent::integration. - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/${integration}.d" $dst = "${dst_dir}/${$conf_file}.yaml" if (! defined(File[$dst_dir])) { @@ -20,14 +33,14 @@ owner => $datadog_agent::dd_user, group => $datadog_agent::dd_group, mode => $datadog_agent::params::permissions_directory, - before => File[$dst] + before => File[$dst], } } } else { $dst = "${datadog_agent::params::legacy_conf_dir}/${integration}.yaml" } - $file_ensure = $ensure ? { default => file, 'absent' => absent } + $file_ensure = $ensure ? { 'default' => 'file', 'absent' => 'absent' } file { $dst: ensure => $file_ensure, @@ -35,7 +48,6 @@ group => $datadog_agent::dd_group, mode => $datadog_agent::params::permissions_file, content => to_instances_yaml($init_config, $instances, $logs), - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } - } diff --git a/manifests/integrations/activemq_xml.pp b/manifests/integrations/activemq_xml.pp index ac1ecbb1..47565532 100644 --- a/manifests/integrations/activemq_xml.pp +++ b/manifests/integrations/activemq_xml.pp @@ -3,20 +3,21 @@ # This class will install the necessary configuration for the activemq_xml integration # # Parameters: -# $url +# @param url # ActiveMQ administration web URL to gather the activemq_xml stats from. -# $username +# @param username # Username to use for authentication - optional -# $password +# @param password # Password to use for authentication - optional -# $supress_errors +# @param supress_errors # Supress connection errors if URL is expected to be offline at times (eg. standby host) - optional -# $detailed_queues +# @param detailed_queues # List of queues to monitor, required if you have more than 300 queues you wish to track, otherwise optional. -# $detailed_topics +# @param detailed_topics # List of topics to monitor, required if you have more than 300 topics you wish to track, otherwise optional. -# $detailed_subscribers +# @param detailed_subscribers # List of subscribers to monitor, required if you have more than 300 subscribers you wish to track, otherwise optional. +# @param instances # # Sample Usage: # @@ -42,23 +43,23 @@ # detailed_subscribers: ['subscriber1', 'subscriber2', 'subscriber3'] # # -class datadog_agent::integrations::activemq_xml( +class datadog_agent::integrations::activemq_xml ( String $url = 'http://localhost:8161', Boolean $supress_errors = false, Optional[String] $username = undef, Optional[String] $password = undef, - Optional[Array[String]] $detailed_queues = [], - Optional[Array[String]] $detailed_topics = [], - Optional[Array[String]] $detailed_subscribers = [], + Optional[Array[String]] $detailed_queues = undef, + Optional[Array[String]] $detailed_topics = undef, + Optional[Array[String]] $detailed_subscribers = undef, Optional[Array] $instances = undef, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/activemq_xml.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/activemq_xml.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -67,7 +68,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -76,15 +77,15 @@ if !$instances and $url { $_instances = [{ - 'url' => $url, - 'username' => $username, - 'password' => $password, - 'supress_errors' => $supress_errors, - 'detailed_queues' => $detailed_queues, - 'detailed_topics' => $detailed_topics, - 'detailed_subscribers' => $detailed_subscribers, + 'url' => $url, + 'username' => $username, + 'password' => $password, + 'supress_errors' => $supress_errors, + 'detailed_queues' => $detailed_queues, + 'detailed_topics' => $detailed_topics, + 'detailed_subscribers' => $detailed_subscribers, }] - } elsif !$instances{ + } elsif !$instances { $_instances = [] } else { $_instances = $instances diff --git a/manifests/integrations/apache.pp b/manifests/integrations/apache.pp index b6de7fc1..0c8e136f 100644 --- a/manifests/integrations/apache.pp +++ b/manifests/integrations/apache.pp @@ -3,16 +3,17 @@ # This class will install the necessary configuration for the apache integration # # Parameters: -# $url: +# @param url # The URL for apache status URL handled by mod-status. # Defaults to http://localhost/server-status?auto -# $username: -# $password: +# @param username +# @param password # If your service uses basic authentication, you can optionally # specify a username and password that will be used in the check. # Optional. -# $tags +# @param tags # Optional array of tags +# @param disable_ssl_validation # # Sample Usage: # @@ -33,13 +34,13 @@ Array $tags = [], Boolean $disable_ssl_validation = false ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/apache.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/apache.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -48,7 +49,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -62,6 +63,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/apache.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/cacti.pp b/manifests/integrations/cacti.pp index 2f1ee0d4..1c9de3e8 100644 --- a/manifests/integrations/cacti.pp +++ b/manifests/integrations/cacti.pp @@ -3,28 +3,28 @@ # This class will install the necessary configuration for the cacti integration # # Parameters: -# $host: +# @param mysql_host # The host cacti MySQL db is running on -# $user +# @param mysql_user # The cacti MySQL password -# $password +# @param mysql_password # The cacti MySQL sb port. -# $path +# @param rrd_path # The path to the cacti rrd directory e.g. /var/lib/cacti/rra/ # -class datadog_agent::integrations::cacti( - $mysql_host = 'localhost', - $mysql_user = 'cacti', - $mysql_password = undef, - $rrd_path = '/var/lib/cacti/rra/', +class datadog_agent::integrations::cacti ( + String $mysql_host = 'localhost', + String $mysql_user = 'cacti', + Optional[String] $mysql_password = undef, + String $rrd_path = '/var/lib/cacti/rra/', ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/cacti.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/cacti.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -33,7 +33,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -47,6 +47,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/cacti.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/cassandra.pp b/manifests/integrations/cassandra.pp index 8f5e17a4..3bb73560 100644 --- a/manifests/integrations/cassandra.pp +++ b/manifests/integrations/cassandra.pp @@ -7,16 +7,17 @@ # additional metrics, contact Datadog Support at https://docs.datadoghq.com/help/ # # Parameters: -# $host: +# @param host # The hostname Cassandra is running on -# $port: +# @param port # The port to connect on -# $user +# @param user # The user for the datadog user -# $password +# @param password # The password for the datadog user -# $tags +# @param tags # Optional array of tags +# @param max_returned_metrics # # Sample Usage: # @@ -28,22 +29,22 @@ # } # # -class datadog_agent::integrations::cassandra( +class datadog_agent::integrations::cassandra ( String $host = 'localhost', Integer $port = 7199, Optional[String] $user = undef, Optional[String] $password = undef, - Optional[Hash] $tags = {}, + Optional[Hash] $tags = undef, Optional[Integer] $max_returned_metrics = undef, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/cassandra.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/cassandra.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: ensure => directory, @@ -51,7 +52,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { diff --git a/manifests/integrations/ceph.pp b/manifests/integrations/ceph.pp index 174c8ba3..47ea9676 100644 --- a/manifests/integrations/ceph.pp +++ b/manifests/integrations/ceph.pp @@ -3,9 +3,9 @@ # This class will install the necessary configuration for the ceph integration # # Parameters: -# $tags +# @param tags # Optional array of tags -# $ceph_cmd +# @param ceph_cmd # Optional ceph cmd # Sample Usage: @@ -13,21 +13,21 @@ # class { 'datadog_agent::integrations::ceph' : # } # -class datadog_agent::integrations::ceph( - Array $tags = [ 'name:ceph_cluster' ], +class datadog_agent::integrations::ceph ( + Array $tags = ['name:ceph_cluster'], String $ceph_cmd = '/usr/bin/ceph', ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent file { '/etc/sudoers.d/datadog_ceph': - content => "# This file is required for dd ceph \ndd-agent ALL=(ALL) NOPASSWD:/usr/bin/ceph\n" + content => "# This file is required for dd ceph \ndd-agent ALL=(ALL) NOPASSWD:/usr/bin/ceph\n", } $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/ceph.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/ceph.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -36,7 +36,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -50,6 +50,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/ceph.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/consul.pp b/manifests/integrations/consul.pp index d999d0e8..57bb304e 100644 --- a/manifests/integrations/consul.pp +++ b/manifests/integrations/consul.pp @@ -3,20 +3,21 @@ # This class will install the necessary configuration for the consul integration # # Parameters: -# $url: +# @param url # The URL for consul -# $catalog_checks: +# @param catalog_checks # Whether to perform checks against the Consul service Catalog # Optional. -# $new_leader_checks: +# @param new_leader_checks # Whether to enable new leader checks from this agent # Note: if this is set on multiple agents in the same cluster # you will receive one event per leader change per agent -# $service_whitelist +# @param service_whitelist # Services to restrict catalog querying to # The default settings query up to 50 services. So if you have more than # this many in your Consul service catalog, you will want to fill in the # whitelist +# @param network_latency_checks # # Sample Usage: # @@ -26,20 +27,20 @@ # new_leader_checks => false, # } # -class datadog_agent::integrations::consul( +class datadog_agent::integrations::consul ( String $url = 'http://localhost:8500', Boolean $catalog_checks = true, Boolean $network_latency_checks = true, Boolean $new_leader_checks = true, - Optional[Array] $service_whitelist = [] + Optional[Array] $service_whitelist = undef, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/consul.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/consul.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -48,7 +49,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -62,6 +63,6 @@ mode => $datadog_agent::params::permissions_file, content => template('datadog_agent/agent-conf.d/consul.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/directory.pp b/manifests/integrations/directory.pp index ca1b20cf..3f64c21f 100644 --- a/manifests/integrations/directory.pp +++ b/manifests/integrations/directory.pp @@ -3,31 +3,32 @@ # This class will install the necessary config to hook the directory in the agent # # Parameters: -# directory +# @param directory # (Required) - string, the directory path to monitor # This will be included as a tag: name:. # -# name -# (Optional) - string, tag metrics with specified name. defaults to the "directory" -# -# dirtagname +# @param dirtagname # (Optional) - string, the name of the key for the tag used for the directory, the value will be the value of "name" (see above). The resulting tag will be ":". defaults to "name" # -# filetagname +# @param filetagname # (Optional) - string, the name of the key for the tag used for each file, the value will be the filename. The resulting tag will be ":". defaults to "filename" # -# filegauges +# @param filegauges # (Optional) - boolean, when true stats will be an individual gauge per file (max. 20 files!) and not a histogram of the whole directory. default False # -# pattern +# @param pattern # (Optional) - string, the `fnmatch` pattern to use when reading the "directory"'s files. The pattern will be matched against the files' absolute paths and relative paths in "directory". default "*" # -# recursive +# @param recursive # (Optional) - boolean, when true the stats will recurse into directories. default False # -# countonly +# @param countonly # (Optional) - boolean, when true the stats will only count the number of files matching the pattern. Useful for very large directories. # +# @param nametag +# +# @param instances +# # # Sample Usage: # @@ -55,17 +56,17 @@ # } class datadog_agent::integrations::directory ( - String $directory = '', - Boolean $filegauges = false, - Boolean $recursive = true, - Boolean $countonly = false, - String $nametag = '', - String $dirtagname = '', - String $filetagname = '', - String $pattern = '', - Optional[Array] $instances = undef, + Optional[String] $directory = undef, + Boolean $filegauges = false, + Boolean $recursive = true, + Boolean $countonly = false, + Optional[String] $nametag = undef, + Optional[String] $dirtagname = undef, + Optional[String] $filetagname = undef, + Optional[String] $pattern = undef, + Optional[Array] $instances = undef, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent if !$instances and $directory == '' { fail('bad directory argument and no instances hash provided') @@ -73,26 +74,26 @@ if !$instances and $directory { $_instances = [{ - 'directory' => $directory, - 'filegauges' => $filegauges, - 'recursive' => $recursive, - 'countonly' => $countonly, - 'name' => $nametag, - 'dirtagname' => $dirtagname, - 'filetagname' => $filetagname, - 'pattern' => $pattern, + 'directory' => $directory, + 'filegauges' => $filegauges, + 'recursive' => $recursive, + 'countonly' => $countonly, + 'name' => $nametag, + 'dirtagname' => $dirtagname, + 'filetagname' => $filetagname, + 'pattern' => $pattern, }] - } elsif !$instances{ + } elsif !$instances { $_instances = [] } else { $_instances = $instances } $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/directory.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/directory.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -101,7 +102,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -115,6 +116,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/directory.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/disk.pp b/manifests/integrations/disk.pp index 30565739..ab7269ab 100644 --- a/manifests/integrations/disk.pp +++ b/manifests/integrations/disk.pp @@ -3,53 +3,53 @@ # This class will install the necessary config to hook the disk check # # Parameters: -# $use_mount +# @param use_mount # The use_mount parameter will instruct the check to collect disk # and fs metrics using mount points instead of volumes. # (values: yes, no) -# $all_partitions +# @param all_partitions # The (optional) all_partitions parameter will instruct the check to # get metrics for all partitions. use_mount should be set to yes (to avoid # collecting empty device names) when using this option. (values: yes, no) -# $tag_by_filesystem +# @param tag_by_filesystem # The (optional) tag_by_filesystem parameter will instruct the check to # tag all disks with their filesystem (for ex: filesystem:nfs) # (values: yes, no) -# $filesystem_exclude +# @param filesystem_exclude # The (optional) filesystems you wish to exclude, example: tmpfs, run, # dev (string or array) -# $device_exclude +# @param device_exclude # The (optional) devices you wish to exclude, example: /dev/sda (string or array) -# $mountpoint_exclude +# @param mountpoint_exclude # The (optional) mountpoints you wish to exclude, example: /tmp, # /mnt/somebody-elses-problem (string or array) -# $filesystem_include +# @param filesystem_include # Specify (optional) filesystems, to only collect from them (string or array) -# $device_include +# @param device_include # Specify (optional) devices, to only collect from them (string or array) -# $mountpoint_include +# @param mountpoint_include # Specify (optional) mountpoints, to only collect from them (string or array) -# $filesystem_blacklist (DEPRECATED in agent version>7.24, use $filesystem_exclude instead) +# @param filesystem_blacklist (DEPRECATED in agent version>7.24, use $filesystem_exclude instead) # The (optional) filesystems you wish to exclude, example: tmpfs, run, # dev (string or array) -# $device_blacklist (DEPRECATED in agent version>7.24, use $device_exclude instead) +# @param device_blacklist (DEPRECATED in agent version>7.24, use $device_exclude instead) # The (optional) devices you wish to exclude, example: /dev/sda (string or array) -# $mountpoint_blacklist (DEPRECATED in agent version>7.24, use $mountpoint_exclude instead) +# @param mountpoint_blacklist (DEPRECATED in agent version>7.24, use $mountpoint_exclude instead) # The (optional) mountpoints you wish to exclude, example: /tmp, # /mnt/somebody-elses-problem (string or array) -# $filesystem_whitelist DEPRECATED in agent version>7.24, use $device_include instead) +# @param filesystem_whitelist DEPRECATED in agent version>7.24, use $device_include instead) # Specify (optional) filesystems, to only collect from them (string or array) -# $device_whitelist (DEPRECATED in agent version>7.24, use $device_include instead) +# @param device_whitelist (DEPRECATED in agent version>7.24, use $device_include instead) # Specify (optional) devices, to only collect from them (string or array) -# $mountpoint_whitelist (DEPRECATED in agent version>7.24, use $mountpoint_include instead) +# @param mountpoint_whitelist (DEPRECATED in agent version>7.24, use $mountpoint_include instead) # Specify (optional) mountpoints, to only collect from them (string or array) -# $excluded_filesystems (DEPRECATED in agent version>6.9, use $filesystem_exclude instead) +# @param excluded_filesystems (DEPRECATED in agent version>6.9, use $filesystem_exclude instead) # The filesystems you wish to exclude, example: tmpfs, run (string or array) -# $excluded_disks (DEPRECATED in agent version>6.9, use $device_exclude instead) +# @param excluded_disks (DEPRECATED in agent version>6.9, use $device_exclude instead) # The disks you (optional) -# $excluded_disk_re (DEPRECATED in agent version>6.9, use $device_exclude instead) +# @param excluded_disk_re (DEPRECATED in agent version>6.9, use $device_exclude instead) # Regular expression (optional) to exclude disks, eg: /dev/sde.* -# $excluded_mountpoint_re (DEPRECATED in agent version>6.9, use $mountpoint_exclude instead) +# @param excluded_mountpoint_re (DEPRECATED in agent version>6.9, use $mountpoint_exclude instead) # Regular expression (optional) to exclude , eg: /mnt/somebody-elses-problem.* # @@ -62,8 +62,8 @@ # } class datadog_agent::integrations::disk ( String $use_mount = 'no', - $all_partitions = undef, - $tag_by_filesystem = undef, + Optional[String] $all_partitions = undef, + Optional[String] $tag_by_filesystem = undef, Optional[Array[String]] $filesystem_exclude = undef, Optional[Array[String]] $device_exclude = undef, Optional[Array[String]] $mountpoint_exclude = undef, @@ -81,7 +81,7 @@ Optional[String] $excluded_disk_re = undef, # deprecated in agent versions >6.9 Optional[String] $excluded_mountpoint_re = undef, # deprecated in agent versions >6.9 ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent validate_legacy('Optional[String]', 'validate_re', $all_partitions, '^(no|yes)$') @@ -90,10 +90,10 @@ } $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/disk.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/disk.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -102,7 +102,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -116,6 +116,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/disk.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/dns_check.pp b/manifests/integrations/dns_check.pp index 6b6bc7de..e08a36c4 100644 --- a/manifests/integrations/dns_check.pp +++ b/manifests/integrations/dns_check.pp @@ -4,13 +4,8 @@ # integration. # # Parameters: -# $hostname: -# Domain or IP you wish to check the availability of. -# $nameserver -# The nameserver you wish to use to check the hostname -# availability. -# $timeout -# Time in seconds to wait before terminating the request. +# @param checks +# # # Sample Usage: # @@ -30,16 +25,16 @@ 'hostname' => 'google.com', 'nameserver' => '8.8.8.8', 'timeout' => 5, - } + }, ] ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/dns_check.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/dns_check.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -48,7 +43,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { diff --git a/manifests/integrations/docker_daemon.pp b/manifests/integrations/docker_daemon.pp index 3852b319..7a8bd01f 100644 --- a/manifests/integrations/docker_daemon.pp +++ b/manifests/integrations/docker_daemon.pp @@ -3,14 +3,37 @@ # This class will install the necessary configuration for the docker integration # # Parameters: -# $url: -# The URL for docker API -# -# $tags: -# optional array of tags -# -# $group: -# optional name of docker group to add dd-agent user too +# @param group +# @param docker_root +# @param timeout +# @param api_version +# @param tls +# @param tls_client_cert +# @param tls_client_key +# @param tls_cacert +# @param tls_verify +# @param init_retry_interval +# @param init_retries +# @param url +# @param collect_events +# @param filtered_event_types +# @param collect_container_size +# @param custom_cgroups +# @param health_service_check_whitelist +# @param collect_container_count +# @param collect_volume_count +# @param collect_images_stats +# @param collect_image_size +# @param collect_disk_stats +# @param collect_exit_codes +# @param exclude +# @param include +# @param tags +# @param ecs_tags +# @param performance_tags +# @param container_tags +# @param collect_labels_as_tags +# @param event_attributes_as_tags # # # Sample Usage: @@ -19,52 +42,52 @@ # url => 'unix://var/run/docker.sock', # } # -class datadog_agent::integrations::docker_daemon( - $group = 'docker', - $docker_root = '/', - $timeout = 10, - $api_version = 'auto', - $tls = false, - $tls_client_cert = '/path/to/client-cert.pem', - $tls_client_key = '/path/to/client-key.pem', - $tls_cacert = '/path/to/ca.pem', - $tls_verify = true, - $init_retry_interval = 0, - $init_retries = 0, - $url = 'unix://var/run/docker.sock', - $collect_events = true, - $filtered_event_types = [], - $collect_container_size = false, - $custom_cgroups = false, - $health_service_check_whitelist = [], - $collect_container_count = false, - $collect_volume_count = false, - $collect_images_stats = false, - $collect_image_size = false, - $collect_disk_stats = false, - $collect_exit_codes = false, - $exclude = [], - $include = [], - $tags = [], - $ecs_tags = true, +class datadog_agent::integrations::docker_daemon ( + String $group = 'docker', + String $docker_root = '/', + Integer $timeout = 10, + String $api_version = 'auto', + Boolean $tls = false, + String $tls_client_cert = '/path/to/client-cert.pem', + String $tls_client_key = '/path/to/client-key.pem', + String $tls_cacert = '/path/to/ca.pem', + Boolean $tls_verify = true, + Integer $init_retry_interval = 0, + Integer $init_retries = 0, + String $url = 'unix://var/run/docker.sock', + Boolean $collect_events = true, + Array $filtered_event_types = [], + Boolean $collect_container_size = false, + Boolean $custom_cgroups = false, + Array $health_service_check_whitelist = [], + Boolean $collect_container_count = false, + Boolean $collect_volume_count = false, + Boolean $collect_images_stats = false, + Boolean $collect_image_size = false, + Boolean $collect_disk_stats = false, + Boolean $collect_exit_codes = false, + Array $exclude = [], + Array $include = [], + Array $tags = [], + Boolean $ecs_tags = true, # Possible values: "container_name", "image_name", "image_tag", "docker_image" - $performance_tags = [], + Array $performance_tags = [], # Possible values: "image_name", "image_tag", "docker_image" - $container_tags = [], + Array $container_tags = [], # Ex. "com.docker.compose.service", "com.docker.compose.project" - $collect_labels_as_tags = [], - $event_attributes_as_tags = [], + Array $collect_labels_as_tags = [], + Array $event_attributes_as_tags = [], ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent exec { 'dd-agent-should-be-in-docker-group': command => "/usr/sbin/usermod -aG ${group} ${datadog_agent::dd_user}", unless => "/bin/cat /etc/group | grep '^${group}:' | grep -qw ${datadog_agent::dd_user}", require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $legacy_dir = "${datadog_agent::params::conf_dir}/docker_daemon.d" file { $legacy_dir: @@ -73,7 +96,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $legacy_conf = "${legacy_dir}/conf.yaml" } else { @@ -81,10 +104,10 @@ } file { $legacy_conf: - ensure => 'absent' + ensure => 'absent', } - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/docker.d" file { $dst_dir: @@ -93,7 +116,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -107,6 +130,6 @@ mode => $datadog_agent::params::permissions_file, content => template('datadog_agent/agent-conf.d/docker_daemon.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/elasticsearch.pp b/manifests/integrations/elasticsearch.pp index 05383f7b..948c8219 100644 --- a/manifests/integrations/elasticsearch.pp +++ b/manifests/integrations/elasticsearch.pp @@ -3,8 +3,19 @@ # This class will install the necessary configuration for the elasticsearch integration # # Parameters: -# $url: -# The URL for Elasticsearch +# @param cluster_stats +# @param index_stats +# @param password +# @param pending_task_stats +# @param pshard_stats +# @param ssl_cert +# @param ssl_key +# @param ssl_verify +# @param tags +# @param url +# @param username +# @param instances +# # # Sample Usage: # @@ -23,7 +34,7 @@ # url => "http://localhost:9201" # } # -class datadog_agent::integrations::elasticsearch( +class datadog_agent::integrations::elasticsearch ( Boolean $cluster_stats = false, Boolean $index_stats = false, Optional[String] $password = undef, @@ -37,27 +48,27 @@ Optional[String] $username = undef, Optional[Array] $instances = undef ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent # $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){ + if validate_legacy('Variant[Boolean, String]', 'is_string', $ssl_verify) { validate_absolute_path($ssl_verify) } if !$instances and $url { $_instances = [{ - 'cluster_stats' => $cluster_stats, - 'index_stats' => $index_stats, - 'password' => $password, - 'pending_task_stats' => $pending_task_stats, - 'pshard_stats' => $pshard_stats, - 'ssl_cert' => $ssl_cert, - 'ssl_key' => $ssl_key, - 'ssl_verify' => $ssl_verify, - 'tags' => $tags, - 'url' => $url, - 'username' => $username + 'cluster_stats' => $cluster_stats, + 'index_stats' => $index_stats, + 'password' => $password, + 'pending_task_stats' => $pending_task_stats, + 'pshard_stats' => $pshard_stats, + 'ssl_cert' => $ssl_cert, + 'ssl_key' => $ssl_key, + 'ssl_verify' => $ssl_verify, + 'tags' => $tags, + 'url' => $url, + 'username' => $username }] } elsif !$instances { $_instances = [] @@ -66,10 +77,10 @@ } $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/elastic.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/elastic.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -78,7 +89,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -92,6 +103,6 @@ mode => $datadog_agent::params::permissions_file, content => template('datadog_agent/agent-conf.d/elastic.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/fluentd.pp b/manifests/integrations/fluentd.pp index bcbf3c21..67f20c5a 100644 --- a/manifests/integrations/fluentd.pp +++ b/manifests/integrations/fluentd.pp @@ -3,8 +3,9 @@ # This class will install the fluentd integration # # Parameters: -# $monitor_agent_url +# @param monitor_agent_url # The url fluentd lists it's plugins on +# @param plugin_ids # # Sample Usage: # @@ -17,17 +18,17 @@ # } # # -class datadog_agent::integrations::fluentd( - $monitor_agent_url = 'http://localhost:24220/api/plugins.json', - Optional[Array] $plugin_ids = [], +class datadog_agent::integrations::fluentd ( + String $monitor_agent_url = 'http://localhost:24220/api/plugins.json', + Optional[Array] $plugin_ids = undef, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/fluentd.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/fluentd.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -36,7 +37,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { diff --git a/manifests/integrations/generic.pp b/manifests/integrations/generic.pp index c5e23d19..685b80a4 100644 --- a/manifests/integrations/generic.pp +++ b/manifests/integrations/generic.pp @@ -3,11 +3,11 @@ # This class will install a configuration file for an integration # # Parameters: -# $integration_name: +# @param integration_name # This will be used to build the filename. It must correspond to an # integration that is supported by dd-agent, see the dd-agent for # a current list. -# $integration_contents: +# @param integration_contents # String containing a rendered template. # # Sample Usage: @@ -17,17 +17,17 @@ # integration_contents => template(my_custom_template), # } # -class datadog_agent::integrations::generic( +class datadog_agent::integrations::generic ( Optional[String] $integration_name = undef, Optional[String] $integration_contents = undef, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/${integration_name}.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/${integration_name}.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -36,7 +36,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -50,6 +50,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => $integration_contents, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/haproxy.pp b/manifests/integrations/haproxy.pp index ee8728b2..031c240a 100644 --- a/manifests/integrations/haproxy.pp +++ b/manifests/integrations/haproxy.pp @@ -3,8 +3,11 @@ # This class will install the necessary configuration for the haproxy integration # # Parameters: -# $url: +# @param url # The URL for haproxy +# @param creds +# @param options +# @param instances # # Sample Usage: # @@ -16,19 +19,19 @@ # options => { collect_aggregates_only => 'False' }, # } # -class datadog_agent::integrations::haproxy( - $creds = {}, - $url = "http://${facts['networking']['ip']}:8080", - $options = {}, +class datadog_agent::integrations::haproxy ( + Hash $creds = {}, + String $url = "http://${facts['networking']['ip']}:8080", + Hash $options = {}, Optional[Array] $instances = undef ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent if !$instances and $url { $_instances = [{ - 'creds' => $creds, - 'url' => $url, - 'options' => $options, + 'creds' => $creds, + 'url' => $url, + 'options' => $options, }] } elsif !$instances { $_instances = [] @@ -37,10 +40,10 @@ } $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/haproxy.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/haproxy.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -49,7 +52,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -57,12 +60,12 @@ } file { $dst: - ensure => file, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_file, - content => template('datadog_agent/agent-conf.d/haproxy.yaml.erb'), - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + ensure => file, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_file, + content => template('datadog_agent/agent-conf.d/haproxy.yaml.erb'), + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/http_check.pp b/manifests/integrations/http_check.pp index a5964bb4..9ef51f40 100644 --- a/manifests/integrations/http_check.pp +++ b/manifests/integrations/http_check.pp @@ -3,43 +3,43 @@ # This class will install the necessary config to hook the http_check in the agent # # Parameters: -# sitename +# @param sitename # (Required) The name of the instance. # -# url +# @param url # (Required) The url to check. # -# timeout +# @param timeout # The (optional) timeout in seconds. # -# method +# @param method # The (optional) HTTP method. This setting defaults to GET, though many # other HTTP methods are supported, including POST and PUT. -# min_collection_interval +# @param min_collection_interval # The (optional) collection interval of the check. # default: 15 # https://docs.datadoghq.com/developers/write_agent_check/#collection-interval -# data +# @param data # The (optional) data option. Data should be a string or an array of # 'key: value' pairs and will be sent in the body of the request. # -# username -# password +# @param username +# @param password # If your service uses basic authentication, you can optionally # specify a username and password that will be used in the check. # -# threshold -# window +# @param threshold +# @param window # The (optional) window and threshold parameters allow you to trigger # alerts only if the check fails x times within the last y attempts # where x is the threshold and y is the window. # -# reverse_content_match +# @param reverse_content_match # When (optional) true, reverses the behavior of the content_match option, # i.e. the HTTP check will report as DOWN if the string or expression # in content_match IS found. (default is false) # -# content_match +# @param content_match # The (optional) content_match parameter will allow the check # to look for a particular string within the response. The check # will report as DOWN if the string is not found. @@ -48,50 +48,50 @@ # a backslash (\) if you're trying to match them in your content: # . ^ $ * + ? { } [ ] \ | ( ) # -# include_content +# @param include_content # When (optional) true, includes the first 200 characters of the HTTP # response body in notifications. (default is false) # -# http_response_status_code +# @param http_response_status_code # The (optional) http_response_status_code parameter will instruct the check # to look for a particular HTTP response status code or a Regex identifying # a set of possible status codes. # The check will report as DOWN if status code returned differs. # This defaults to 1xx, 2xx and 3xx HTTP status code: (1|2|3)\d\d. # -# collect_response_time +# @param collect_response_time # The (optional) collect_response_time parameter will instruct the # check to create a metric 'network.http.response_time', tagged with # the url, reporting the response time in seconds. # -# ca_certs +# @param ca_certs # An optional string representing the path to CA certificates. # -# disable_ssl_validation +# @param disable_ssl_validation # The setting disable_ssl_validation parameter to true will instruct # the http client to accept self signed, expired and otherwise # problematic SSL server certificates. To maintain backwards # compatibility this defaults to false. # -# ignore_ssl_warning +# @param ignore_ssl_warning # When SSL certificate validation is enabled (see setting above), this # setting will allow you to disable security warnings. # -# skip_event +# @param skip_event # The (optional) skip_event parameter will instruct the check to not # create any event to avoid duplicates with a server side service check. # This defaults to True because this is being deprecated. # (See https://github.com/DataDog/dd-agent/blob/master/checks/network_checks.py#L178-L180) # -# no_proxy +# @param no_proxy # The (optional) no_proxy parameter would bypass any proxy settings enabled # and attempt to reach the the URL directly. # If no proxy is defined at any level, this flag bears no effect. # Defaults to False. # -# check_certificate_expiration -# days_warning -# days_critical +# @param check_certificate_expiration +# @param days_warning +# @param days_critical # The (optional) check_certificate_expiration will instruct the check # to create a service check that checks the expiration of the # ssl certificate. Allow for a warning to occur when x days are @@ -100,7 +100,7 @@ # The SSL certificate will always be validated for this additional # service check regardless of the value of disable_ssl_validation # -# headers +# @param headers # The (optional) headers parameter allows you to send extra headers with # the request. Specify them like 'header-name: content'. This is useful for # explicitly specifying the 'host' header or for authorisation purposes. @@ -110,17 +110,24 @@ # but may be problematic with some HTTP servers # (See: https://code.google.com/p/httplib2/issues/detail?id=169) # -# allow_redirects +# @param allow_redirects # The (optional) allow_redirects parameter can enable redirection. # Defaults to True. # -# contact +# @param contact # For service-specific notifications, you can optionally specify # a list of users to notify within the service configuration. # -# tags +# @param tags # The (optional) tags to add to the check instance. # +# @param check_hostname +# +# @param ssl_server_name +# +# @param instances +# +# # Sample Usage: # # Add a class for each check instance: @@ -166,84 +173,83 @@ # }] # } - class datadog_agent::integrations::http_check ( - $sitename = undef, - $url = undef, - $username = undef, - $password = undef, - $timeout = 1, - $method = 'get', - $min_collection_interval = undef, - $data = undef, - $threshold = undef, - $window = undef, - $content_match = undef, - $reverse_content_match = false, - $include_content = false, - $http_response_status_code = undef, - $collect_response_time = true, - $disable_ssl_validation = false, - $ignore_ssl_warning = false, - $skip_event = true, - $no_proxy = false, - $check_certificate_expiration = true, - $days_warning = undef, - $days_critical = undef, - Optional[Boolean] $check_hostname = undef, - Optional[String] $ssl_server_name = undef, - $headers = [], - $allow_redirects = true, - $tags = [], - $contact = [], - Optional[Array] $instances = undef, - $ca_certs = undef, + Optional[String] $sitename = undef, + Optional[String] $url = undef, + Optional[String] $username = undef, + Optional[String] $password = undef, + Integer $timeout = 1, + String $method = 'get', + Optional[Integer] $min_collection_interval = undef, + Optional[Variant[String, Array]] $data = undef, + Optional[String] $threshold = undef, + Optional[String] $window = undef, + Optional[Boolean] $content_match = undef, + Boolean $reverse_content_match = false, + Boolean $include_content = false, + Optional[String] $http_response_status_code = undef, + Boolean $collect_response_time = true, + Boolean $disable_ssl_validation = false, + Boolean $ignore_ssl_warning = false, + Boolean $skip_event = true, + Boolean $no_proxy = false, + Boolean $check_certificate_expiration = true, + Optional[String] $days_warning = undef, + Optional[String] $days_critical = undef, + Optional[Boolean] $check_hostname = undef, + Optional[String] $ssl_server_name = undef, + Array $headers = [], + Boolean $allow_redirects = true, + Array $tags = [], + Array $contact = [], + Optional[Array] $instances = undef, + Optional[String] $ca_certs = undef, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent if !$instances and $url { $_instances = [{ - 'sitename' => $sitename, - 'url' => $url, - 'username' => $username, - 'password' => $password, - 'timeout' => $timeout, - 'method' => $method, - 'min_collection_interval' => $min_collection_interval, - 'data' => $data, - 'threshold' => $threshold, - 'window' => $window, - 'content_match' => $content_match, - 'reverse_content_match' => $reverse_content_match, - 'include_content' => $include_content, - 'http_response_status_code' => $http_response_status_code, - 'collect_response_time' => $collect_response_time, - 'disable_ssl_validation' => $disable_ssl_validation, - 'ignore_ssl_warning' => $ignore_ssl_warning, - 'skip_event' => $skip_event, - 'no_proxy' => $no_proxy, - 'check_certificate_expiration' => $check_certificate_expiration, - 'days_warning' => $days_warning, - 'days_critical' => $days_critical, - 'check_hostname' => $check_hostname, - 'ssl_server_name' => $ssl_server_name, - 'headers' => $headers, - 'allow_redirects' => $allow_redirects, - 'tags' => $tags, - 'contact' => $contact, - 'ca_certs' => $ca_certs, + 'sitename' => $sitename, + 'url' => $url, + 'username' => $username, + 'password' => $password, + 'timeout' => $timeout, + 'method' => $method, + 'min_collection_interval' => $min_collection_interval, + 'data' => $data, + 'threshold' => $threshold, + 'window' => $window, + 'content_match' => $content_match, + 'reverse_content_match' => $reverse_content_match, + 'include_content' => $include_content, + 'http_response_status_code' => $http_response_status_code, + 'collect_response_time' => $collect_response_time, + 'disable_ssl_validation' => $disable_ssl_validation, + 'ignore_ssl_warning' => $ignore_ssl_warning, + 'skip_event' => $skip_event, + 'no_proxy' => $no_proxy, + 'check_certificate_expiration' => $check_certificate_expiration, + 'days_warning' => $days_warning, + 'days_critical' => $days_critical, + 'check_hostname' => $check_hostname, + 'ssl_server_name' => $ssl_server_name, + 'headers' => $headers, + 'allow_redirects' => $allow_redirects, + 'tags' => $tags, + 'contact' => $contact, + 'ca_certs' => $ca_certs, }] - } elsif !$instances{ + } elsif !$instances { $_instances = [] } else { $_instances = $instances } $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/http_check.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/http_check.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -252,7 +258,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -266,6 +272,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/http_check.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/jenkins.pp b/manifests/integrations/jenkins.pp index c3fe39bc..826a71a6 100644 --- a/manifests/integrations/jenkins.pp +++ b/manifests/integrations/jenkins.pp @@ -3,7 +3,7 @@ # This class will install the necessary configuration for the jenkins integration # # Parameters: -# $path: +# @param path # Jenkins path. Defaults to '/var/lib/jenkins' # # Sample Usage: @@ -13,16 +13,16 @@ # } # # -class datadog_agent::integrations::jenkins( - $path = '/var/lib/jenkins' +class datadog_agent::integrations::jenkins ( + String $path = '/var/lib/jenkins' ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/jenkins.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/jenkins.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -31,7 +31,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -45,6 +45,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/jenkins.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/jmx.pp b/manifests/integrations/jmx.pp index e32f3ec9..331e8c26 100644 --- a/manifests/integrations/jmx.pp +++ b/manifests/integrations/jmx.pp @@ -3,48 +3,12 @@ # This class will install the necessary configuration for the jmx integration # # Parameters: -# $init_config: +# @param init_config # Hash of inital configuration, consisting of the following keys: # -# custom_jar_paths: -# Array of paths to jars. Optional. -# -# $instances: +# @param instances # Array of instance hashes, consisting of the following keys: # -# name: -# Used in conjunction with jmx_url. Optional. -# tags: -# Hash of tags { 'env' => 'prod' }. Optional. -# host: -# The host jmx is running on. -# port: -# The JMX port. -# jmx_url: -# If the agent needs to connect to a non-default JMX URL, specify it here -# instead of a host and a port. If you use this you need to specify a 'name' -# for the instance. Optional. -# user: -# The username for connecting to the running JVM. Optional. -# password: -# The password for connecting to the running JVM. Optional. -# process_name_regex: -# Instead of specifying a host and port or jmx_url, the agent can -# connect using the attach api. This requires the JDK to be installed -# and the path to tools.jar to be set. Optional. -# tools_jar_path: -# To be set when process_name_regex is set. Optional. -# java_bin_path: -# The path to the Java binary. Should be set if the agent cannot find your java executable. Optional. -# java_options: -# Java JVM options. Optional. -# trust_store_path: -# The path to the trust store. Should be set if ssl is enabled. Optional. -# trust_store_password: -# The trust store password. Should be set if ssl is enabled. Optional. -# conf: -# Array of include/exclude hash pairs. Optional. -# Read http://docs.datadoghq.com/integrations/java/ to learn how to customize it. # # Sample Usage: # @@ -61,17 +25,17 @@ # }], # } # -class datadog_agent::integrations::jmx( - $init_config = {}, - $instances = [], +class datadog_agent::integrations::jmx ( + Hash $init_config = {}, + Array $instances = [], ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/jmx.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/jmx.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -80,7 +44,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -94,7 +58,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/jmx.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } - } diff --git a/manifests/integrations/kafka.pp b/manifests/integrations/kafka.pp index 2f575e76..63152aba 100644 --- a/manifests/integrations/kafka.pp +++ b/manifests/integrations/kafka.pp @@ -3,28 +3,27 @@ # This class will install the necessary configuration for the kafka integration # # Parameters: -# $host: +# @param host # The host kafka is running on. Defaults to 'localhost' -# $username +# @param username # Optionally specify username for connection -# $password +# @param password # Optionally specify password for connection -# $port +# @param port # The port kafka is running on. Defaults to 9999 -# $name -# Name given to kafka instance -# $process_name_regex +# @param process_name_regex # Instead of specifying a host, and port. The agent can connect using the attach api. -# $tools_jar_path +# @param tools_jar_path # Path to tools jar needs to be set when process_name_regex is set -# $java_bin_path +# @param java_bin_path # Path to java binary, should be set if agent cant find your java executable -# $trust_store_path +# @param trust_store_path # Path to the trust store, should be set if ssl is enabled -# $trust_store_password +# @param trust_store_password # Password to the trust store -# $tags +# @param tags # Optional array of tags +# @param instances # # # Sample Usage: @@ -52,45 +51,45 @@ # ] # } # -class datadog_agent::integrations::kafka( - $host = 'localhost', - Variant[String[1], Integer] $port = 9999, - Optional[String[1]] $username = undef, - Optional[String[1]] $password = undef, - Optional[String[1]] $process_name_regex = undef, - Optional[String[1]] $tools_jar_path = undef, - Optional[String[1]] $java_bin_path = undef, - Optional[String[1]] $trust_store_path = undef, - Optional[String[1]] $trust_store_password = undef, - Optional[Hash[String[1], String[1]]] $tags = undef, +class datadog_agent::integrations::kafka ( + String $host = 'localhost', + Variant[String[1], Integer] $port = 9999, + Optional[String[1]] $username = undef, + Optional[String[1]] $password = undef, + Optional[String[1]] $process_name_regex = undef, + Optional[String[1]] $tools_jar_path = undef, + Optional[String[1]] $java_bin_path = undef, + Optional[String[1]] $trust_store_path = undef, + Optional[String[1]] $trust_store_password = undef, + Optional[Hash[String[1], String[1]]] $tags = undef, Optional[Array[Hash[String[1], Data]]] $instances = undef, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent if !$instances and $host and $port { $servers = [{ - 'host' => $host, - 'port' => $port, - 'username' => $username, - 'password' => $password, - 'process_name_regex' => $process_name_regex, - 'tools_jar_path' => $tools_jar_path, - 'java_bin_path' => $java_bin_path, - 'trust_store_path' => $trust_store_path, - 'trust_store_password' => $trust_store_password, - 'tags' => $tags, + 'host' => $host, + 'port' => $port, + 'username' => $username, + 'password' => $password, + 'process_name_regex' => $process_name_regex, + 'tools_jar_path' => $tools_jar_path, + 'java_bin_path' => $java_bin_path, + 'trust_store_path' => $trust_store_path, + 'trust_store_password' => $trust_store_password, + 'tags' => $tags, }] - } elsif !$instances{ + } elsif !$instances { $servers = [] } else { $servers = $instances } $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/kafka.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/kafka.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -99,7 +98,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { diff --git a/manifests/integrations/kong.pp b/manifests/integrations/kong.pp index 15a17d92..247ce429 100644 --- a/manifests/integrations/kong.pp +++ b/manifests/integrations/kong.pp @@ -7,7 +7,7 @@ # # # Parameters: -# $instances: +# @param instances # Array of hashes for all Kong instances and associated tags. See example # # Sample Usage: @@ -25,20 +25,20 @@ # } # class datadog_agent::integrations::kong ( - $instances = [ + Array $instances = [ { 'status_url' => 'http://localhost:8001/status/', 'tags' => [] } ] ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/kong.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/kong.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -47,7 +47,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -61,6 +61,6 @@ mode => $datadog_agent::params::permissions_file, content => template('datadog_agent/agent-conf.d/kong.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/kubernetes.pp b/manifests/integrations/kubernetes.pp index b984191c..300aa51e 100644 --- a/manifests/integrations/kubernetes.pp +++ b/manifests/integrations/kubernetes.pp @@ -3,10 +3,12 @@ # This class will install the necessary configuration for the kubernetes integration # # Parameters: -# $url: -# The URL for kubernetes API -# -# $tags: +# @param api_server_url +# @param apiserver_client_crt +# @param apiserver_client_key +# @param kubelet_client_crt +# @param kubelet_client_key +# @param tags # optional array of tags # # @@ -21,22 +23,21 @@ # kubelet_client_key => '/etc/ssl/private/key', # } # -class datadog_agent::integrations::kubernetes( - $api_server_url = 'Enter_Your_API_url', - $apiserver_client_crt = '/path/to/crt', - $apiserver_client_key = '/path/to/key', - $kubelet_client_crt = '/path/to/crt', - $kubelet_client_key = '/path/to/key', - $tags = [], - +class datadog_agent::integrations::kubernetes ( + String $api_server_url = 'Enter_Your_API_url', + String $apiserver_client_crt = '/path/to/crt', + String $apiserver_client_key = '/path/to/key', + String $kubelet_client_crt = '/path/to/crt', + String $kubelet_client_key = '/path/to/key', + Array $tags = [], ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/kubernetes.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/kubernetes.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -45,7 +46,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { diff --git a/manifests/integrations/kubernetes_state.pp b/manifests/integrations/kubernetes_state.pp index 10fe409c..6f899976 100644 --- a/manifests/integrations/kubernetes_state.pp +++ b/manifests/integrations/kubernetes_state.pp @@ -3,10 +3,10 @@ # This class will install the necessary configuration for the kubernetes integration # # Parameters: -# $url: +# @param url # The URL for kubernetes metrics # -# $tags: +# @param tags # optional array of tags # # @@ -17,18 +17,17 @@ # url => 'http://kubernetes.com:8080/metrics', # } # -class datadog_agent::integrations::kubernetes_state( - $url = 'Enter_State_URL', - $tags = [], - +class datadog_agent::integrations::kubernetes_state ( + String $url = 'Enter_State_URL', + Array $tags = [], ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/kubernetes_state.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/kubernetes_state.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -37,7 +36,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { diff --git a/manifests/integrations/linux_proc_extras.pp b/manifests/integrations/linux_proc_extras.pp index 9a93c006..0d917582 100644 --- a/manifests/integrations/linux_proc_extras.pp +++ b/manifests/integrations/linux_proc_extras.pp @@ -4,7 +4,7 @@ # # Parameters: # -# tags +# @param tags # The (optional) tags to add to the check instance. # # Sample Usage: @@ -13,16 +13,16 @@ # tags => [ 'env:production' ], # } -class datadog_agent::integrations::linux_proc_extras( - $tags = [], +class datadog_agent::integrations::linux_proc_extras ( + Array $tags = [], ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/linux_proc_extras.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/linux_proc_extras.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -31,7 +31,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -45,7 +45,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/linux_proc_extras.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } - } diff --git a/manifests/integrations/logs.pp b/manifests/integrations/logs.pp index a71e0e19..f8a57535 100644 --- a/manifests/integrations/logs.pp +++ b/manifests/integrations/logs.pp @@ -3,7 +3,7 @@ # This class will install the necessary configuration for the logs integration. # # Parameters: -# $logs: +# @param logs # array of log sources. # # Log Source: @@ -36,11 +36,11 @@ # https://docs.datadoghq.com/logs/log_collection # -class datadog_agent::integrations::logs( +class datadog_agent::integrations::logs ( Array $logs = [], ) inherits datadog_agent::params { - unless $::datadog_agent::_agent_major_version == 5 { - require ::datadog_agent + unless versioncmp($datadog_agent::_agent_major_version, '5') == 0 { + require datadog_agent file { "${datadog_agent::params::conf_dir}/logs.yaml": ensure => file, @@ -49,7 +49,7 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/logs.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } } diff --git a/manifests/integrations/marathon.pp b/manifests/integrations/marathon.pp index cf147156..aa06b03f 100644 --- a/manifests/integrations/marathon.pp +++ b/manifests/integrations/marathon.pp @@ -3,7 +3,8 @@ # This class will install the necessary configuration for the Marathon integration # # Parameters: -# $url: +# @param marathon_timeout +# @param url # The URL for Marathon # # Sample Usage: @@ -12,17 +13,17 @@ # url => "http://localhost:8080" # } # -class datadog_agent::integrations::marathon( - $marathon_timeout = 5, - $url = 'http://localhost:8080' +class datadog_agent::integrations::marathon ( + Integer $marathon_timeout = 5, + String $url = 'http://localhost:8080' ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/marathon.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/marathon.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -31,7 +32,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -45,6 +46,6 @@ mode => $datadog_agent::params::permissions_file, content => template('datadog_agent/agent-conf.d/marathon.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/memcache.pp b/manifests/integrations/memcache.pp index 985da7c9..50ced57b 100644 --- a/manifests/integrations/memcache.pp +++ b/manifests/integrations/memcache.pp @@ -3,11 +3,14 @@ # This class will install the necessary configuration for the memcache integration # # Parameters: -# $url: +# @param url # url used to connect to the memcached instance -# $port: -# $tags +# @param port +# @param tags # Optional array of tags +# @param items +# @param slabs +# @param instances # # Sample Usage: # @@ -38,27 +41,27 @@ Variant[Boolean, String] $slabs = false, Optional[Array] $instances = undef, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent if !$instances and $url { $_instances = [{ - 'url' => $url, - 'port' => $port, - 'tags' => $tags, - 'items' => $items, - 'slabs' => $slabs, + 'url' => $url, + 'port' => $port, + 'tags' => $tags, + 'items' => $items, + 'slabs' => $slabs, }] - } elsif !$instances{ + } elsif !$instances { $_instances = [] } else { $_instances = $instances } $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/mcache.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/mcache.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -67,7 +70,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -81,6 +84,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/mcache.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/mesos_master.pp b/manifests/integrations/mesos_master.pp index 065fe8d9..6e8b2906 100644 --- a/manifests/integrations/mesos_master.pp +++ b/manifests/integrations/mesos_master.pp @@ -3,7 +3,8 @@ # This class will install the necessary configuration for the mesos integration # # Parameters: -# $url: +# @param mesos_timeout +# @param url # The URL for Mesos master # # Sample Usage: @@ -12,13 +13,13 @@ # url => "http://localhost:5050" # } # -class datadog_agent::integrations::mesos_master( - $mesos_timeout = 10, - $url = 'http://localhost:5050' +class datadog_agent::integrations::mesos_master ( + Integer $mesos_timeout = 10, + String $url = 'http://localhost:5050', ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/mesos.d" file { $dst_dir: @@ -27,7 +28,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -35,14 +36,14 @@ } file { $dst: - ensure => 'absent' + ensure => 'absent', } $legacy_dst_master = "${datadog_agent::params::legacy_conf_dir}/mesos_master.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_master_dir = "${datadog_agent::params::conf_dir}/mesos_master.d" file { $legacy_dst_master: - ensure => 'absent' + ensure => 'absent', } file { $dst_master_dir: @@ -51,7 +52,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst_master = "${dst_master_dir}/conf.yaml" } else { @@ -65,6 +66,6 @@ mode => $datadog_agent::params::permissions_file, content => template('datadog_agent/agent-conf.d/mesos_master.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/mesos_slave.pp b/manifests/integrations/mesos_slave.pp index 9860cf71..57b3b6f0 100644 --- a/manifests/integrations/mesos_slave.pp +++ b/manifests/integrations/mesos_slave.pp @@ -3,7 +3,8 @@ # This class will install the necessary configuration for the mesos slave integration # # Parameters: -# $url: +# @param mesos_timeout +# @param url # The URL for Mesos slave # # Sample Usage: @@ -12,16 +13,15 @@ # url => "http://localhost:5051" # } # -class datadog_agent::integrations::mesos_slave( - $mesos_timeout = 10, - $url = 'http://localhost:5051' +class datadog_agent::integrations::mesos_slave ( + Integer $mesos_timeout = 10, + String $url = 'http://localhost:5051', ) inherits datadog_agent::params { - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/mesos_slave.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/mesos_slave.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -30,7 +30,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -44,6 +44,6 @@ mode => $datadog_agent::params::permissions_file, content => template('datadog_agent/agent-conf.d/mesos_slave.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/mongo.pp b/manifests/integrations/mongo.pp index ff87c3f9..167cab55 100644 --- a/manifests/integrations/mongo.pp +++ b/manifests/integrations/mongo.pp @@ -5,38 +5,8 @@ # NOTE: In newer versions of the Datadog Agent, the ssl parameters will be deprecated in favor the tls variants # # Parameters: -# $additional_metrics -# Optional array of additional metrics -# $database -# Optionally specify database to query. Defaults to 'admin' -# $host: -# The host mongo is running on. Defaults to '127.0.0.1' -# $password -# Optionally specify password for connection -# $port -# The port mongo is running on. Defaults to 27017 -# $ssl -# Optionally enable SSL for connection -# $ssl_ca_certs -# Optionally specify path to SSL Certificate Authority certificates -# $ssl_cert_reqs -# Optionally require SSL client certificate for connection -# $ssl_certfile -# Optionally specify path to SSL certificate for connection -# $ssl_keyfile -# Optionally specify path to SSL private key for connection -# $tls -# Optionally enable TLS for connection -# $tls_ca_file -# Optionally specify path to SSL/TLS Certificate Authority certificates -# $tls_allow_invalid_certificates -# Optionally require SSL/TLS client certificate for connection -# $tls_certificate_key_file -# Optionally specify path to combined SSL/TLS key and certificate for connection -# $tags -# Optional array of tags -# $username -# Optionally specify username for connection +# @param servers +# # # Sample Usage (Older Agent Versions): # @@ -93,16 +63,16 @@ # ] # } # -class datadog_agent::integrations::mongo( - Array $servers = [{'host' => 'localhost', 'port' => '27017'}] +class datadog_agent::integrations::mongo ( + Array $servers = [{ 'host' => 'localhost', 'port' => '27017' }], ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/mongo.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/mongo.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -111,7 +81,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -125,6 +95,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/mongo.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/mysql.pp b/manifests/integrations/mysql.pp index 26106e13..fd553d9f 100644 --- a/manifests/integrations/mysql.pp +++ b/manifests/integrations/mysql.pp @@ -3,34 +3,39 @@ # This class will install the necessary configuration for the mysql integration # # Parameters: -# $password +# @param password # The mysql password for the datadog user -# $host: +# @param host # The host mysql is running on -# $user +# @param user # The mysql user for the datadog user -# $sock +# @param sock # Connect mysql via unix socket -# $tags +# @param tags # Optional array of tags -# $replication +# @param replication # replication option -# $galera_cluster +# @param galera_cluster # galera cluster option -# $extra_status_metrics +# @param extra_status_metrics # extra status metrics -# $extra_innodb_metrics +# @param extra_innodb_metrics # extra innodb metrics -# $extra_performance_metrics +# @param extra_performance_metrics # extra performance metrics, query run time, 95th precentile avg -# $schema_size_metrics +# @param schema_size_metrics # schema size metrics -# $disable_innodb_metrics +# @param disable_innodb_metrics # disable innodb metrics, used with older versions of MySQL without innodb engine support. -# $dbm +# @param dbm # Database Monitoring for Application Performance Monitoring (APM) -# $queries +# @param queries # Custom metrics based on MySQL query +# @param port +# @param instances +# @param logs +# +# # Sample Usage: # # class { 'datadog_agent::integrations::mysql' : @@ -66,61 +71,61 @@ # } # # -class datadog_agent::integrations::mysql( +class datadog_agent::integrations::mysql ( String $host = 'localhost', - Optional[String] $user = 'datadog', - Optional[Variant[String, Integer]] $port = 3306, + Optional[String] $user = undef, + Optional[Variant[String, Integer]] $port = undef, Optional[String] $password = undef, Optional[String] $sock = undef, Array $tags = [], - $replication = '0', - $galera_cluster = '0', + String $replication = '0', + String $galera_cluster = '0', Boolean $extra_status_metrics = false, Boolean $extra_innodb_metrics = false, Boolean $extra_performance_metrics = false, Boolean $schema_size_metrics = false, Boolean $disable_innodb_metrics = false, Optional[Boolean] $dbm = undef, - Optional[Array] $queries = [], + Optional[Array] $queries = undef, Optional[Array] $instances = undef, - Optional[Array] $logs = [], - ) inherits datadog_agent::params { - require ::datadog_agent + Optional[Array] $logs = undef, +) inherits datadog_agent::params { + require datadog_agent if ($host == undef and $sock == undef) or - ($host != undef and $port == undef and $sock == undef) { + ($host != undef and $port == undef and $sock == undef) { fail('invalid MySQL configuration') } if !$instances and $host { $_instances = [{ - 'host' => $host, - 'password' => $password, - 'user' => $user, - 'port' => $port, - 'sock' => $sock, - 'tags' => $tags, - 'replication' => $replication, - 'galera_cluster' => $galera_cluster, - 'extra_status_metrics' => $extra_status_metrics, - 'extra_innodb_metrics' => $extra_innodb_metrics, - 'extra_performance_metrics' => $extra_performance_metrics, - 'schema_size_metrics' => $schema_size_metrics, - 'disable_innodb_metrics' => $disable_innodb_metrics, - 'dbm' => $dbm, - 'queries' => $queries, + 'host' => $host, + 'password' => $password, + 'user' => $user, + 'port' => $port, + 'sock' => $sock, + 'tags' => $tags, + 'replication' => $replication, + 'galera_cluster' => $galera_cluster, + 'extra_status_metrics' => $extra_status_metrics, + 'extra_innodb_metrics' => $extra_innodb_metrics, + 'extra_performance_metrics' => $extra_performance_metrics, + 'schema_size_metrics' => $schema_size_metrics, + 'disable_innodb_metrics' => $disable_innodb_metrics, + 'dbm' => $dbm, + 'queries' => $queries, }] - } elsif !$instances{ + } elsif !$instances { $_instances = [] } else { $_instances = $instances } $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/mysql.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/mysql.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -129,7 +134,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -146,4 +151,3 @@ notify => Service[$datadog_agent::params::service_name], } } - diff --git a/manifests/integrations/network.pp b/manifests/integrations/network.pp index 3b409d63..cf4738d6 100644 --- a/manifests/integrations/network.pp +++ b/manifests/integrations/network.pp @@ -3,8 +3,26 @@ # This class will install the network integration # # Parameters: -# $collect_connection_state +# @param collect_connection_state # Enable TCP connection state counts +# @param collect_connection_queues +# @param excluded_interfaces +# @param excluded_interface_re +# @param collect_rate_metrics +# @param collect_count_metrics +# @param conntrack_path +# @param use_sudo_conntrack +# @param whitelist_conntrack_metrics +# @param blacklist_conntrack_metrics +# @param collect_aws_ena_metrics +# @param tags +# @param service +# @param min_collection_interval +# @param empty_default_hostname +# @param metric_patterns_include +# @param metric_patterns_exclude +# @param combine_connection_states +# # # Sample Usage: # @@ -19,33 +37,33 @@ # } # # -class datadog_agent::integrations::network( +class datadog_agent::integrations::network ( Boolean $collect_connection_state = false, Boolean $collect_connection_queues = false, Array[String] $excluded_interfaces = [], - String $excluded_interface_re = '', + Optional[String] $excluded_interface_re = undef, Boolean $combine_connection_states = true, Boolean $collect_rate_metrics = true, Boolean $collect_count_metrics = false, - String $conntrack_path = '', + Optional[String] $conntrack_path = undef, Boolean $use_sudo_conntrack = true, Array[String] $whitelist_conntrack_metrics = [], Array[String] $blacklist_conntrack_metrics = [], Boolean $collect_aws_ena_metrics = false, Array[String] $tags = [], - String $service = '', + Optional[String] $service = undef, Integer $min_collection_interval = 15, Boolean $empty_default_hostname = false, Array[String] $metric_patterns_include = [], Array[String] $metric_patterns_exclude = [], ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/network.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/network.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -54,7 +72,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { diff --git a/manifests/integrations/nginx.pp b/manifests/integrations/nginx.pp index 20853a77..0c30159d 100644 --- a/manifests/integrations/nginx.pp +++ b/manifests/integrations/nginx.pp @@ -3,9 +3,9 @@ # This class will install the necessary configuration for the nginx integration # # Parameters: -# $instances: +# @param instances # Array of hashes for all nginx urls and associates tags. See example -# $logs: +# @param logs # (optional) log collection configuration, in the format described here: # https://docs.datadoghq.com/integrations/nginx/ # @@ -59,17 +59,17 @@ # sourcecategory: 'http_web_access' # -class datadog_agent::integrations::nginx( +class datadog_agent::integrations::nginx ( Array $instances = [], Optional[Array] $logs = undef, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/nginx.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/nginx.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -78,7 +78,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -92,6 +92,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/nginx.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/ntp.pp b/manifests/integrations/ntp.pp index 14251377..531e746a 100644 --- a/manifests/integrations/ntp.pp +++ b/manifests/integrations/ntp.pp @@ -3,17 +3,17 @@ # This class will enable ntp check # # Parameters: -# $offset_threshold: +# @param offset_threshold # Offset threshold for a critical alert. Defaults to 600. # -# $host: +# @param host # ntp server to use for ntp check # -# $port +# @param port # -# $version +# @param version # -# $timeout +# @param timeout # # Sample Usage: # @@ -23,20 +23,20 @@ # } # -class datadog_agent::integrations::ntp( - $offset_threshold = 60, - $host = undef, - $port = undef, - $version = undef, - $timeout = undef, +class datadog_agent::integrations::ntp ( + Integer $offset_threshold = 60, + Optional[String] $host = undef, + Optional[Variant[String, Integer]] $port = undef, + Optional[String] $version = undef, + Optional[Variant[String, Integer]] $timeout = undef, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/ntp.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/ntp.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -45,7 +45,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -59,6 +59,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/ntp.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/oom_kill.pp b/manifests/integrations/oom_kill.pp index 62bb44a8..7d2b64c9 100644 --- a/manifests/integrations/oom_kill.pp +++ b/manifests/integrations/oom_kill.pp @@ -4,7 +4,7 @@ # For it to work you also need to enable the system-probe with enable_oom_kill set to true. # # Parameters: -# $instances: +# @param instances # Array of hashes for all oom_kill configs and associates tags. See example # # Sample Usage: @@ -19,10 +19,10 @@ # } # -class datadog_agent::integrations::oom_kill( +class datadog_agent::integrations::oom_kill ( Array $instances = [], ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $dst_dir = "${datadog_agent::params::conf_dir}/oom_kill.d" file { $dst_dir: @@ -31,7 +31,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" @@ -42,6 +42,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/oom_kill.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/pgbouncer.pp b/manifests/integrations/pgbouncer.pp index 1d9681d0..c0e9317f 100644 --- a/manifests/integrations/pgbouncer.pp +++ b/manifests/integrations/pgbouncer.pp @@ -3,17 +3,17 @@ # This class will install the necessary configuration for the pgbouncer integration # # Parameters: -# $password: +# @param password # The password for the datadog user -# $host: +# @param host # The host pgbouncer is listening on -# $port: +# @param port # The pgbouncer port number -# $username: +# @param username # The username for the datadog user -# $tags: +# @param tags # Optional array of tags -# $pgbouncers: +# @param pgbouncers # Optional array of pgbouncer hashes. See example # # Sample Usage: @@ -43,21 +43,21 @@ # ], # } # -class datadog_agent::integrations::pgbouncer( - String $password = '', +class datadog_agent::integrations::pgbouncer ( + Optional[String] $password = undef, String $host = 'localhost', Variant[String, Integer] $port = '6432', String $username = 'datadog', - Array $tags = [], - Array $pgbouncers = [], + Array $tags = [], + Array $pgbouncers = [], ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/pgbouncer.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/pgbouncer.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -66,7 +66,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { diff --git a/manifests/integrations/php_fpm.pp b/manifests/integrations/php_fpm.pp index 01fd401d..40e46ac1 100644 --- a/manifests/integrations/php_fpm.pp +++ b/manifests/integrations/php_fpm.pp @@ -3,21 +3,25 @@ # This class will set-up PHP FPM monitoring # # Parameters: -# $status_url +# @param status_url # URL to fetch FPM metrics. Default: http://localhost/status # -# $ping_url +# @param ping_url # URL to get a reliable check of the FPM pool. Default: http://localhost/ping # -# $ping_reply +# @param ping_reply # Expected response from ping_url. Default: pong # -# $tags +# @param tags # Optional array of tags # -# $use_fastcgi +# @param use_fastcgi # Use fastcgi to get stats. Default: false # +# @param http_host +# @param instances +# +# # Sample Usage: # # class { 'datadog_agent::integrations::php_fpm' : @@ -26,35 +30,35 @@ # } # -class datadog_agent::integrations::php_fpm( - $status_url = 'http://localhost/status', - $ping_url = 'http://localhost/ping', - $ping_reply = 'pong', - $http_host = undef, - $tags = [], - $instances = undef, - $use_fastcgi = 'false' +class datadog_agent::integrations::php_fpm ( + String $status_url = 'http://localhost/status', + String $ping_url = 'http://localhost/ping', + String $ping_reply = 'pong', + Optional[String] $http_host = undef, + Array $tags = [], + Optional[Array] $instances = undef, + Variant[String, Boolean] $use_fastcgi = 'false', ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent if !$instances { $_instances = [{ - 'http_host' => $http_host, - 'status_url' => $status_url, - 'ping_url' => $ping_url, - 'ping_reply' => $ping_reply, - 'tags' => $tags, - 'use_fastcgi' => $use_fastcgi, + 'http_host' => $http_host, + 'status_url' => $status_url, + 'ping_url' => $ping_url, + 'ping_reply' => $ping_reply, + 'tags' => $tags, + 'use_fastcgi' => $use_fastcgi, }] } else { $_instances = $instances } $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/php_fpm.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/php_fpm.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -63,7 +67,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -77,6 +81,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/php_fpm.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/postfix.pp b/manifests/integrations/postfix.pp index 1226b8dd..add32d80 100644 --- a/manifests/integrations/postfix.pp +++ b/manifests/integrations/postfix.pp @@ -3,11 +3,12 @@ # This class will install the necessary configuration for the Postfix integration # # Parameters: -# $url: -# url used to connect to the Postfixd instance -# $port: -# $tags +# @param tags # Optional array of tags +# @param directory +# @param queues +# @param instances +# # # Sample Usage: # @@ -30,29 +31,29 @@ # class datadog_agent::integrations::postfix ( String $directory = '/var/spool/postfix', - Array $queues = [ 'active', 'deferred', 'incoming' ], - Optional[Array] $tags = [], + Array $queues = ['active', 'deferred', 'incoming'], + Optional[Array] $tags = undef, Optional[Array] $instances = undef, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent if !$instances and $directory { $_instances = [{ - 'directory' => $directory, - 'queues' => $queues, - 'tags' => $tags + 'directory' => $directory, + 'queues' => $queues, + 'tags' => $tags }] - } elsif !$instances{ + } elsif !$instances { $_instances = [] } else { $_instances = $instances } $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/postfix.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/postfix.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -61,7 +62,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -75,6 +76,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/postfix.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/postgres.pp b/manifests/integrations/postgres.pp index 00f3f22f..c8a76e77 100644 --- a/manifests/integrations/postgres.pp +++ b/manifests/integrations/postgres.pp @@ -3,45 +3,45 @@ # This class will install the necessary configuration for the postgres integration # # Parameters: -# $password +# @param password # The password for the datadog user -# $host +# @param host # The host postgres is running on -# $dbname +# @param dbname # The postgres database name -# $port +# @param port # The postgres port number -# $username +# @param username # The username for the datadog user -# $ssl +# @param ssl # Boolean to enable SSL -# $use_psycopg2 +# @param use_psycopg2 # Boolean to flag connecting to postgres with psycopg2 instead of pg8000. # Warning, psycopg2 doesn't support ssl mode. -# $collect_function_metrics +# @param collect_function_metrics # Boolean to enable collecting metrics regarding PL/pgSQL functions from pg_stat_user_functions. -# $collect_count_metrics +# @param collect_count_metrics # Boolean to enable collecting count metrics, default value is True for backward compatibility but they might be slow, # suggested value is False. -# $collect_activity_metrics +# @param collect_activity_metrics # Boolean to enable collecting metrics regarding transactions from pg_stat_activity, default value is False. # Please make sure the user has sufficient privileges to read from pg_stat_activity before enabling this option. -# $collect_database_size_metrics +# @param collect_database_size_metrics # Boolean to enable collecting database size metrics. Default value is True but they might be slow with large databases -# $collect_default_database +# @param collect_default_database # Boolean to enable collecting statistics from the default database 'postgres' in the check metrics, default to false -# $tags +# @param tags # Optional array of tags -# $tables +# @param tables # Track per relation/table metrics. Array of strings. # Warning: this can collect lots of metrics per relation # (10 + 10 per index) -# $tags -# Optional array of tags -# $custom_metrics +# @param custom_metrics # A hash of custom metrics with the following keys - query, metrics, # relation, descriptors. Refer to this guide for details on those fields: # https://help.datadoghq.com/hc/en-us/articles/208385813-Postgres-custom-metric-collection-explained +# @param instances +# # # Sample Usage: # @@ -82,7 +82,7 @@ # descriptors: # - ["tag_column", "tag_column.datadog.tag"] # -class datadog_agent::integrations::postgres( +class datadog_agent::integrations::postgres ( Optional[String] $password = undef, String $host = 'localhost', String $dbname = 'postgres', @@ -100,13 +100,13 @@ Hash $custom_metrics = {}, Optional[Array] $instances = undef, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/postgres.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/postgres.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -115,7 +115,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -124,23 +124,23 @@ if !$instances and $host { $_instances = [{ - 'host' => $host, - 'password' => $password, - 'dbname' => $dbname, - 'port' => $port, - 'username' => $username, - 'ssl' => $ssl, - 'use_psycopg2' => $use_psycopg2, - 'tags' => $tags, - 'tables' => $tables, - 'custom_metrics' => $custom_metrics, - 'collect_function_metrics' => $collect_function_metrics, - 'collect_count_metrics' => $collect_count_metrics, - 'collect_activity_metrics' => $collect_activity_metrics, - 'collect_database_size_metrics' => $collect_database_size_metrics, - 'collect_default_database' => $collect_default_database, + 'host' => $host, + 'password' => $password, + 'dbname' => $dbname, + 'port' => $port, + 'username' => $username, + 'ssl' => $ssl, + 'use_psycopg2' => $use_psycopg2, + 'tags' => $tags, + 'tables' => $tables, + 'custom_metrics' => $custom_metrics, + 'collect_function_metrics' => $collect_function_metrics, + 'collect_count_metrics' => $collect_count_metrics, + 'collect_activity_metrics' => $collect_activity_metrics, + 'collect_database_size_metrics' => $collect_database_size_metrics, + 'collect_default_database' => $collect_default_database, }] - } elsif !$instances{ + } elsif !$instances { $_instances = [] } else { $_instances = $instances diff --git a/manifests/integrations/postgres_custom_metric.pp b/manifests/integrations/postgres_custom_metric.pp index 91a7b913..09973d0e 100644 --- a/manifests/integrations/postgres_custom_metric.pp +++ b/manifests/integrations/postgres_custom_metric.pp @@ -2,26 +2,25 @@ # The postgres_custom_metric defines a custom sql metric. # https://help.datadoghq.com/hc/en-us/articles/208385813-Postgres-custom-metric-collection-explained # -# $query: +# @param query # The custom metric SQL query. It must contain a '%s' for defining the metrics. # -# $metrics: +# @param metrics # a hash of column name to metric definition. a metric definition is an array # consisting of two columns -- the datadog metric name and the metric type. # -# $relation: -# ? +# @param relation # -# $descriptor: +# @param descriptors # an array that maps an sql column's to a tag. Each descriptor consists of two # fields -- column name, and datadog tag. -define datadog_agent::integrations::postgres_custom_metric( +# +define datadog_agent::integrations::postgres_custom_metric ( String $query, Hash $metrics, Boolean $relation = false, 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 c69a3505..069c9463 100644 --- a/manifests/integrations/process.pp +++ b/manifests/integrations/process.pp @@ -3,10 +3,11 @@ # This class will install the necessary configuration for the process integration # # Parameters: -# $processes: +# @param processes # Array of process hashes. See example -# $hiera_processes: +# @param hiera_processes # Boolean to grab processes from hiera to allow merging +# @param init_config # # Process hash keys: # search_strings @@ -40,12 +41,12 @@ # # -class datadog_agent::integrations::process( +class datadog_agent::integrations::process ( Boolean $hiera_processes = false, - $init_config = {}, - Array $processes = [], - ) inherits datadog_agent::params { - require ::datadog_agent + Hash $init_config = {}, + Array $processes = [], +) inherits datadog_agent::params { + require datadog_agent if $hiera_processes { $local_processes = lookup({ 'name' => 'datadog_agent::integrations::process::processes', 'merge' => 'unique', 'default_value' => $processes }) @@ -54,10 +55,10 @@ } $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/process.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/process.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -66,7 +67,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -74,12 +75,12 @@ } file { $dst: - ensure => $local_processes.length ? { 0 => absent, default => file}, + ensure => $local_processes.length ? { '0' => 'absent', 'default' => 'file' }, owner => $datadog_agent::dd_user, group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/process.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/rabbitmq.pp b/manifests/integrations/rabbitmq.pp index 66313f84..2789fb80 100644 --- a/manifests/integrations/rabbitmq.pp +++ b/manifests/integrations/rabbitmq.pp @@ -3,26 +3,26 @@ # This class will install the necessary config to hook the rabbitmq in the agent # # Parameters: -# $url +# @param url # Required. URL pointing to the RabbitMQ Managment Plugin # (http://www.rabbitmq.com/management.html) -# $username -# $password +# @param username +# @param password # If your service uses basic authentication, you can optionally # specify a username and password that will be used in the check. # (it's set to guest/guest by RabbitMQ on setup) -# $tag_families +# @param tag_families # Tag queues "families" based on regex match -# $ssl_verify +# @param ssl_verify # Skip verification of the RabbitMQ management web endpoint # SSL certificate -# $nodes -# $nodes_regexes +# @param nodes +# @param nodes_regexes # Specify the nodes to collect metrics on (up to 100 nodes). # If you have less than 100 nodes, metrics will be collected on all nodes # by default. -# $queues -# $queues_regexes +# @param queues +# @param queues_regexes # Specify the queues to collect metrics on (up to 200 queues). # # If you have less than 200 queues, metrics will be collected on all queues @@ -32,12 +32,12 @@ # # If `tag families` are enabled, the first capture group in the regex will # be used as the queue_family tag -# $exchanges -# $exchanges_regexes +# @param exchanges +# @param exchanges_regexes # Specify the exchanges to collect metrics on (up to 50 queues). # If you have less than 50 queues, metrics will be collected on all exchanges # by default. -# $vhosts +# @param vhosts # List of vhosts to monitor with service checks. By default, a list of all # vhosts is fetched and each one will be checked using the aliveness API. # @@ -52,8 +52,8 @@ class datadog_agent::integrations::rabbitmq ( Optional[String] $url = undef, - Optional[String] $username = 'guest', - Optional[String] $password = 'guest', + Optional[String] $username = undef, + Optional[String] $password = undef, Boolean $ssl_verify = true, Boolean $tag_families = false, Array $nodes = [], @@ -64,14 +64,13 @@ Array $exchanges = [], Array $exchanges_regexes = [], ) inherits datadog_agent::params { - - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/rabbitmq.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/rabbitmq.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -80,7 +79,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { diff --git a/manifests/integrations/redis.pp b/manifests/integrations/redis.pp index b3c27760..c788a5cf 100644 --- a/manifests/integrations/redis.pp +++ b/manifests/integrations/redis.pp @@ -3,26 +3,28 @@ # This class will install the necessary configuration for the redis integration # # Parameters: -# $host: +# @param host # The host redis is running on -# $password +# @param password # The redis password (optional) -# $port +# @param port # The main redis port. -# $ports +# @param ports # Array of redis ports: overrides port (optional) -# $slowlog_max_len +# @param slowlog_max_len # The max length of the slow-query log (optional) -# $tags +# @param tags # Optional array of tags -# $keys +# @param keys # Optional array of keys to check length -# $command_stats +# @param command_stats # Collect INFO COMMANDSTATS output as metrics -# $instances +# @param instances # Optional array of hashes should you wish to specify multiple instances. # If this option is specified all other parameters will be overriden. # This parameter may also be used to specify instances with hiera. +# @param warn_on_missing_keys +# # # Sample Usage: # @@ -40,23 +42,22 @@ # warn_on_missing_keys: true # command_stats: false # -class datadog_agent::integrations::redis( - String $host = 'localhost', - String $password = '', - Variant[String, Integer] $port = '6379', - Optional[Array] $ports = undef, - Variant[String, Integer] $slowlog_max_len = '', - Array $tags = [], - Array $keys = [], - Boolean $warn_on_missing_keys = true, - Boolean $command_stats = false, - Optional[Array] $instances = undef, - +class datadog_agent::integrations::redis ( + String $host = 'localhost', + Optional[String] $password = undef, + Variant[String, Integer] $port = '6379', + Optional[Array] $ports = undef, + Optional[Variant[String, Integer]] $slowlog_max_len = undef, + Array $tags = [], + Array $keys = [], + Boolean $warn_on_missing_keys = true, + Boolean $command_stats = false, + Optional[Array] $instances = undef, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent if $ports == undef { - $_ports = [ $port ] + $_ports = [$port] } else { $_ports = $ports } @@ -75,10 +76,10 @@ } $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/redisdb.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/redisdb.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -87,7 +88,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -96,7 +97,7 @@ if !$instances and $host { $_instances = $_port_instances - } elsif !$instances{ + } elsif !$instances { $_instances = [] } else { $_instances = $instances @@ -109,6 +110,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/redisdb.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/riak.pp b/manifests/integrations/riak.pp index 5d5ab753..2495529f 100644 --- a/manifests/integrations/riak.pp +++ b/manifests/integrations/riak.pp @@ -3,9 +3,9 @@ # This class will install the necessary configuration for the riak integration # # Parameters: -# $url: +# @param url # The URL for riak -# $tags +# @param tags # Optional array of tags # # Sample Usage: @@ -18,17 +18,17 @@ # url => 'http://localhost:8098/stats', # } # -class datadog_agent::integrations::riak( +class datadog_agent::integrations::riak ( String $url = 'http://localhost:8098/stats', Array $tags = [], ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/riak.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/riak.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -37,7 +37,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -52,6 +52,6 @@ mode => $datadog_agent::params::permissions_file, content => template('datadog_agent/agent-conf.d/riak.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/snmp.pp b/manifests/integrations/snmp.pp index 6527859d..b2c52c2c 100755 --- a/manifests/integrations/snmp.pp +++ b/manifests/integrations/snmp.pp @@ -3,17 +3,17 @@ # This class will enable snmp check # # Parameters: -# $init_config: +# @param init_config # Optional hash (see snmp.yaml.example for reference) # -# $instances: +# @param instances # Array of hashes containing snmp instance configuration (see snmp.yaml.example for reference) # -# $mibs_folder: (Deprecated in favor of $init_config) -# $ignore_nonincreasing_oid: (Deprecated in favor of $init_config) -# $snmp_v1_instances: (Deprecated in favor of $instances) -# $snmp_v2_instances: (Deprecated in favor of $instances) -# $snmp_v3_instances: (Deprecated in favor of $instances) +# @param mibs_folder (Deprecated in favor of $init_config) +# @param ignore_nonincreasing_oid (Deprecated in favor of $init_config) +# @param snmp_v1_instances (Deprecated in favor of $instances) +# @param snmp_v2_instances (Deprecated in favor of $instances) +# @param snmp_v3_instances (Deprecated in favor of $instances) # # Sample Usage: # @@ -49,18 +49,17 @@ # } # ], # } - - +# class datadog_agent::integrations::snmp ( - $mibs_folder = undef, - $ignore_nonincreasing_oid = false, - $init_config = {}, - $instances = [], - $snmp_v1_instances = [], - $snmp_v2_instances = [], - $snmp_v3_instances = [], + Optional[String] $mibs_folder = undef, + Boolean $ignore_nonincreasing_oid = false, + Hash $init_config = {}, + Array $instances = [], + Array $snmp_v1_instances = [], + Array $snmp_v2_instances = [], + Array $snmp_v3_instances = [], ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $versioned_instances = { 1 => $snmp_v1_instances, @@ -69,10 +68,10 @@ } $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/snmp.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/snmp.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -81,7 +80,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -95,6 +94,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/snmp.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/solr.pp b/manifests/integrations/solr.pp index 4c6db020..5070c224 100644 --- a/manifests/integrations/solr.pp +++ b/manifests/integrations/solr.pp @@ -3,21 +3,21 @@ # This class will install the necessary configuration for the solr integration # # Parameters: -# $hostname: +# @param hostname # The host solr is running on. Defaults to 'localhost' -# $port +# @param port # The JMX port. -# $username +# @param username # The username for connecting to the running JVM. Optional. -# $password +# @param password # The password for connecting to the running JVM. Optional. -# $java_bin_path +# @param java_bin_path # The path to the Java binary. Should be set if the agent cannot find your java executable. Optional. -# $trust_store_path +# @param trust_store_path # The path to the trust store. Should be set if ssl is enabled. Optional. -# $trust_store_password +# @param trust_store_password # The trust store password. Should be set if ssl is enabled. Optional. -# $tags +# @param tags # Optional hash of tags { env => 'prod' }. # # Sample Usage: @@ -26,23 +26,23 @@ # port => 8081, # } # -class datadog_agent::integrations::solr( - $hostname = 'localhost', - $port = 7199, - $username = undef, - $password = undef, - $java_bin_path = undef, - $trust_store_path = undef, - $trust_store_password = undef, - $tags = {}, +class datadog_agent::integrations::solr ( + String $hostname = 'localhost', + Variant[String, Integer] $port = 7199, + Optional[String] $username = undef, + Optional[String] $password = undef, + Optional[String] $java_bin_path = undef, + Optional[String] $trust_store_path = undef, + Optional[String] $trust_store_password = undef, + Hash $tags = {}, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/solr.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/solr.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -51,7 +51,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -65,7 +65,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/solr.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } - } diff --git a/manifests/integrations/ssh.pp b/manifests/integrations/ssh.pp index 697497bc..9c786dc1 100644 --- a/manifests/integrations/ssh.pp +++ b/manifests/integrations/ssh.pp @@ -3,20 +3,20 @@ # This class will enable ssh check # # Parameters: -# $host: +# @param host # ssh server to use for ssh check # -# $port +# @param port # -# $username +# @param username # -# $password +# @param password # -# $sftp_check +# @param sftp_check # -# $private_key_file +# @param private_key_file # -# $add_missing_keys +# @param add_missing_keys # # Sample Usage: # @@ -25,23 +25,22 @@ # private_key_file => '/opt/super_secret_key', # } # - -class datadog_agent::integrations::ssh( - $host = $trusted['certname'], - $port = 22, - $username = $datadog_agent::dd_user, - $password = undef, - $sftp_check = true, - $private_key_file = undef, - $add_missing_keys = true, +class datadog_agent::integrations::ssh ( + String $host = $trusted['certname'], + Variant[String, Integer] $port = 22, + String $username = $datadog_agent::dd_user, + Optional[String] $password = undef, + Boolean $sftp_check = true, + Optional[String] $private_key_file = undef, + Boolean $add_missing_keys = true, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/ssh.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/ssh_check.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -50,7 +49,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -64,6 +63,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/ssh.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/supervisord.pp b/manifests/integrations/supervisord.pp index 6ad15166..47a06370 100644 --- a/manifests/integrations/supervisord.pp +++ b/manifests/integrations/supervisord.pp @@ -3,22 +3,7 @@ # This class will install the necessary configuration for the supervisord integration # # Parameters: -# servername -# socket -# Optional. The socket on which supervisor listen for HTTP/XML-RPC requests. -# hostname -# Optional. The host where supervisord server is running. -# port -# Optional. The port number. -# username -# password -# If your service uses basic authentication, you can optionally -# specify a username and password that will be used in the check. -# proc_names -# Optional. The process to monitor within this supervisord instance. -# If not specified, the check will monitor all processes. -# server_check -# Optional. Service check for connections to supervisord server. +# @param instances # # # Sample Usage: @@ -40,17 +25,16 @@ # # # - class datadog_agent::integrations::supervisord ( - $instances = [{'servername' => 'server0', 'hostname' => 'localhost', 'port' => '9001'}], + Array $instances = [{ 'servername' => 'server0', 'hostname' => 'localhost', 'port' => '9001' }], ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/supervisord.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/supervisord.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -59,7 +43,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -73,6 +57,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/supervisord.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/system_core.pp b/manifests/integrations/system_core.pp index 19a0a4e2..0861b5d2 100644 --- a/manifests/integrations/system_core.pp +++ b/manifests/integrations/system_core.pp @@ -7,13 +7,13 @@ # # class datadog_agent::integrations::system_core inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/system_core.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/system_core.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -22,7 +22,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -30,12 +30,12 @@ } file { $dst: - ensure => file, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_file, - content => template('datadog_agent/agent-conf.d/system_core.yaml.erb'), - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + ensure => file, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_file, + content => template('datadog_agent/agent-conf.d/system_core.yaml.erb'), + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/tcp_check.pp b/manifests/integrations/tcp_check.pp index bd5be538..5011e9bb 100644 --- a/manifests/integrations/tcp_check.pp +++ b/manifests/integrations/tcp_check.pp @@ -3,41 +3,44 @@ # This class will install the necessary config to hook the tcp_check in the agent # # Parameters: -# check_name +# @param check_name # (Required) - Name of the service. # This will be included as a tag: instance:. # -# host +# @param host # (Required) - Host to be checked. # This will be included as a tag: url::. # -# port +# @param port # (Required) - Port to be checked. # This will be included as a tag: url::. # -# timeout +# @param timeout # (Optional) - Timeout for the check. Defaults to 10 seconds. # -# threshold +# @param threshold # (Optional) - Used in conjunction with window. An alert will # trigger if the check fails times in attempts. # -# window +# @param window # (Optional) - Refer to threshold. # -# collect_response_time +# @param collect_response_time # (Optional) - Defaults to false. If this is not set to true, no # response time metric will be collected. If it is set to true, the # metric returned is network.tcp.response_time. # -# skip_event +# @param skip_event # The (optional) skip_event parameter will instruct the check to not # create any event to avoid duplicates with a server side service check. # This default to False. # -# tags +# @param tags # The (optional) tags to add to the check instance. # +# @param instances +# +# # Sample Usage: # # Add a class for each check instance: @@ -83,45 +86,44 @@ # 'port' => '443', # }] # } - - +# class datadog_agent::integrations::tcp_check ( - $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, + Optional[String] $check_name = undef, + Optional[String] $host = undef, + Optional[Variant[String, Integer]] $port = undef, + Integer $timeout = 10, + Optional[Integer] $threshold = undef, + Optional[Integer] $window = undef, + Optional[Integer] $collect_response_time = undef, + Optional[Integer] $skip_event = undef, + Array $tags = [], + Optional[Array] $instances = undef, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent if !$instances and $host { $_instances = [{ - 'check_name' => $check_name, - 'host' => $host, - 'port' => $port, - 'timeout' => $timeout, - 'threshold' => $threshold, - 'window' => $window, - 'collect_response_time' => $collect_response_time, - 'skip_event' => $skip_event, - 'tags' => $tags, + 'check_name' => $check_name, + 'host' => $host, + 'port' => $port, + 'timeout' => $timeout, + 'threshold' => $threshold, + 'window' => $window, + 'collect_response_time' => $collect_response_time, + 'skip_event' => $skip_event, + 'tags' => $tags, }] - } elsif !$instances{ + } elsif !$instances { $_instances = [] } else { $_instances = $instances } $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/tcp_check.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/tcp_check.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -130,7 +132,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -144,6 +146,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/tcp_check.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/tomcat.pp b/manifests/integrations/tomcat.pp index 5092603f..15d341ba 100644 --- a/manifests/integrations/tomcat.pp +++ b/manifests/integrations/tomcat.pp @@ -3,23 +3,23 @@ # This class will install the necessary configuration for the tomcat integration # # Parameters: -# $hostname: +# @param hostname # The host tomcat is running on. Defaults to 'localhost' -# $port +# @param port # The JMX port. -# $jmx_url +# @param jmx_url # The JMX URL. -# $username +# @param username # The username for connecting to the running JVM. Optional. -# $password +# @param password # The password for connecting to the running JVM. Optional. -# $java_bin_path +# @param java_bin_path # The path to the Java binary. Should be set if the agent cannot find your java executable. Optional. -# $trust_store_path +# @param trust_store_path # The path to the trust store. Should be set if ssl is enabled. Optional. -# $trust_store_password +# @param trust_store_password # The trust store password. Should be set if ssl is enabled. Optional. -# $tags +# @param tags # Optional hash of tags { env => 'prod' }. # # Sample Usage: @@ -28,25 +28,24 @@ # port => 8081, # } # -class datadog_agent::integrations::tomcat( - $hostname = 'localhost', - $port = 7199, - $jmx_url = undef, - $username = undef, - $password = undef, - $java_bin_path = undef, - $trust_store_path = undef, - $trust_store_password = undef, - $tags = {}, +class datadog_agent::integrations::tomcat ( + String $hostname = 'localhost', + Variant[String, Integer] $port = 7199, + Optional[String] $jmx_url = undef, + Optional[String] $username = undef, + Optional[String] $password = undef, + Optional[String] $java_bin_path = undef, + Optional[String] $trust_store_path = undef, + Optional[String] $trust_store_password = undef, + Hash $tags = {}, ) inherits datadog_agent::params { - require ::datadog_agent - + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/tomcat.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/tomcat.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -55,7 +54,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -69,7 +68,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/tomcat.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } - } diff --git a/manifests/integrations/twemproxy.pp b/manifests/integrations/twemproxy.pp index f5f065c2..e8f3f01e 100644 --- a/manifests/integrations/twemproxy.pp +++ b/manifests/integrations/twemproxy.pp @@ -3,10 +3,12 @@ # This class will install the necessary configuration for the twemproxy aka nutcracker integration # # Parameters: -# $host: +# @param host # The host twemproxy is running on. Defaults to '127.0.0.1' -# $port +# @param port # The twemproxy password for the datadog user. Defaults to 22222 +# @param instances +# # # Sample Usage: # @@ -23,29 +25,29 @@ # ] # } # -class datadog_agent::integrations::twemproxy( - $host = 'localhost', - $port = '22222', - $instances = undef, +class datadog_agent::integrations::twemproxy ( + String $host = 'localhost', + Variant[String, Integer] $port = '22222', + Optional[Array] $instances = undef, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent if !$instances and $host { $_instances = [{ - 'host' => $host, - 'port' => $port, + 'host' => $host, + 'port' => $port, }] - } elsif !$instances{ + } elsif !$instances { $_instances = [] } else { $_instances = $instances } $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/twemproxy.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/twemproxy.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -54,7 +56,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -68,6 +70,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/twemproxy.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/varnish.pp b/manifests/integrations/varnish.pp index 95e31e8a..a3856001 100644 --- a/manifests/integrations/varnish.pp +++ b/manifests/integrations/varnish.pp @@ -3,13 +3,13 @@ # This class will install the necessary configuration for the varnish integration # # Parameters: -# varnishstat +# @param varnishstat # Path to the varnishstat binary # -# instance_name +# @param instance_name # Used in the varnishstat command for the -n argument # -# tags +# @param tags # DataDog tags # # Sample usage: @@ -22,17 +22,17 @@ # } # class datadog_agent::integrations::varnish ( - $varnishstat = '/usr/bin/varnishstat', - $instance_name = undef, - $tags = [], + String $varnishstat = '/usr/bin/varnishstat', + Optional[String] $instance_name = undef, + Array $tags = [], ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/varnish.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/varnish.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -41,7 +41,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -55,6 +55,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/varnish.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/zk.pp b/manifests/integrations/zk.pp index 0e3fad09..28e8890d 100644 --- a/manifests/integrations/zk.pp +++ b/manifests/integrations/zk.pp @@ -3,12 +3,8 @@ # This class will install the necessary configuration for the zk integration # # Parameters: -# $host: -# The host zk is running on. Defaults to '127.0.0.1' -# $port -# The port zk is running on. Defaults to 2181 -# $tags -# Optional array of tags +# @param servers +# # # Sample Usage: # @@ -28,15 +24,15 @@ # } # class datadog_agent::integrations::zk ( - $servers = [{'host' => 'localhost', 'port' => '2181'}] + Array $servers = [{ 'host' => 'localhost', 'port' => '2181' }] ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/zk.yaml" - if $::datadog_agent::_agent_major_version > 5 { + if versioncmp($datadog_agent::_agent_major_version, '5') > 0 { $dst_dir = "${datadog_agent::params::conf_dir}/zk.d" file { $legacy_dst: - ensure => 'absent' + ensure => 'absent', } file { $dst_dir: @@ -45,7 +41,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" } else { @@ -59,6 +55,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/zk.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/params.pp b/manifests/params.pp index 26297f4b..321d02c7 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -6,7 +6,7 @@ class datadog_agent::params { $datadog_site = 'datadoghq.com' $dd_groups = undef - $default_agent_major_version = 7 + $default_agent_major_version = '7' $agent_version = 'latest' $dogapi_version = 'installed' $gem_provider = 'puppetserver_gem' @@ -26,7 +26,7 @@ case $facts['os']['name'] { 'Ubuntu','Debian','Raspbian' : { $rubydev_package = 'ruby-dev' - case $::operatingsystemrelease{ + case $facts['os']['release']['major'] { '14.04': { # Specific ruby/rubygems package name for Ubuntu 14.04 $ruby_package = 'ruby' @@ -85,5 +85,4 @@ } default: { fail("Class[datadog_agent]: Unsupported operatingsystem: ${facts['os']['name']}") } } - } diff --git a/manifests/redhat.pp b/manifests/redhat.pp index 40237990..13f9e207 100644 --- a/manifests/redhat.pp +++ b/manifests/redhat.pp @@ -2,29 +2,33 @@ # # This class contains the DataDog agent installation mechanism for Red Hat derivatives # - -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 $agent_flavor = $datadog_agent::params::package_name, - Optional[Boolean] $rpm_repo_gpgcheck = undef, +# @param agent_major_version +# @param agent_repo_uri +# @param manage_repo +# @param agent_version +# @param agent_flavor +# @param rpm_repo_gpgcheck +# +class datadog_agent::redhat ( + Variant[Integer, String] $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 $agent_flavor = $datadog_agent::params::package_name, + Optional[Boolean] $rpm_repo_gpgcheck = undef, ) inherits datadog_agent::params { - if $manage_repo { - $keys = [ - 'https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public', - 'https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public', - 'https://keys.datadoghq.com/DATADOG_RPM_KEY_FD4BF915.public', - 'https://keys.datadoghq.com/DATADOG_RPM_KEY_B01082D3.public', + 'https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public', + 'https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public', + 'https://keys.datadoghq.com/DATADOG_RPM_KEY_FD4BF915.public', + 'https://keys.datadoghq.com/DATADOG_RPM_KEY_B01082D3.public', ] if ($rpm_repo_gpgcheck != undef) { $repo_gpgcheck = $rpm_repo_gpgcheck } else { - if ($agent_repo_uri == undef) and ($agent_major_version > 5) { + if ($agent_repo_uri == undef) and versioncmp($datadog_agent::_agent_major_version, '5') > 0 { case $facts['os']['name'] { 'RedHat', 'CentOS', 'OracleLinux': { # disable repo_gpgcheck on 8.1 because of https://bugzilla.redhat.com/show_bug.cgi?id=1792506 @@ -41,19 +45,18 @@ } else { $repo_gpgcheck = false } - } case $agent_major_version { - 5 : { + '5' : { $defaulturl = "https://yum.datadoghq.com/rpm/${facts['os']['architecture']}/" $gpgkeys = $keys } - 6 : { + '6' : { $defaulturl = "https://yum.datadoghq.com/stable/6/${facts['os']['architecture']}/" $gpgkeys = $keys } - 7 : { + '7' : { $defaulturl = "https://yum.datadoghq.com/stable/7/${facts['os']['architecture']}/" $gpgkeys = $keys } @@ -75,15 +78,15 @@ ensure => absent, } - yumrepo {'datadog5': + yumrepo { 'datadog5': ensure => absent, } - yumrepo {'datadog6': + yumrepo { 'datadog6': ensure => absent, } - yumrepo {'datadog': + yumrepo { 'datadog': enabled => 1, gpgcheck => 1, gpgkey => join($gpgkeys, "\n "), diff --git a/manifests/reports.pp b/manifests/reports.pp index ad3fb119..4ff44462 100644 --- a/manifests/reports.pp +++ b/manifests/reports.pp @@ -4,9 +4,18 @@ # the datadog service. # # Parameters: -# $api_key: +# @param api_key # Your DataDog API Key. Please replace with your key value -# $datadog_site: +# @param puppetmaster_user +# @param dogapi_version +# @param manage_dogapi_gem +# @param hostname_extraction_regex +# @param proxy_http +# @param proxy_https +# @param report_fact_tags +# @param report_trusted_fact_tags +# @param puppet_gem_provider +# @param datadog_site # URL to use to talk to the Datadog API # # Actions: @@ -15,53 +24,49 @@ # # Sample Usage: # -class datadog_agent::reports( - $api_key, - $puppetmaster_user, - $dogapi_version, - $manage_dogapi_gem = true, - $hostname_extraction_regex = undef, - $proxy_http = undef, - $proxy_https = undef, - $report_fact_tags = [], - $report_trusted_fact_tags = [], - $datadog_site = 'https://api.datadoghq.com', - $puppet_gem_provider = $datadog_agent::params::gem_provider, +class datadog_agent::reports ( + String $api_key, + String $puppetmaster_user, + String $dogapi_version, + Boolean $manage_dogapi_gem = true, + Optional[String] $hostname_extraction_regex = undef, + Optional[String] $proxy_http = undef, + Optional[String] $proxy_https = undef, + Array $report_fact_tags = [], + Array $report_trusted_fact_tags = [], + String $datadog_site = 'https://api.datadoghq.com', + String $puppet_gem_provider = $datadog_agent::params::gem_provider, ) inherits datadog_agent::params { - if ($facts['os']['name'] == 'Windows') { - fail('Reporting is not yet supported from a Windows host') - } else { - - require ::datadog_agent + require datadog_agent if $manage_dogapi_gem { $rubydev_package = $datadog_agent::params::rubydev_package # check to make sure that you're not installing rubydev somewhere else if ! defined(Package[$rubydev_package]) { - package {$rubydev_package: + package { $rubydev_package: ensure => installed, - before => Package['dogapi'] + before => Package['dogapi'], } } if (! defined(Package['rubygems'])) { package { 'ruby': ensure => 'installed', - name => $datadog_agent::params::ruby_package + name => $datadog_agent::params::ruby_package, } package { 'rubygems': ensure => 'installed', name => $datadog_agent::params::rubygems_package, - require => Package['ruby'] + require => Package['ruby'], } } - package{ 'dogapi': + package { 'dogapi': ensure => $dogapi_version, provider => $puppet_gem_provider, } @@ -75,6 +80,5 @@ mode => '0640', require => File['/etc/datadog-agent'], } - } } diff --git a/manifests/security_agent.pp b/manifests/security_agent.pp index eceb1203..8c4a6395 100644 --- a/manifests/security_agent.pp +++ b/manifests/security_agent.pp @@ -1,22 +1,26 @@ -class datadog_agent::security_agent( - Boolean $enabled = false, - Optional[String] $socket = undef, - - Boolean $service_enable = true, - String $service_ensure = 'running', +# Class datadog_agent::security_agent +# +# @param enabled +# @param socket +# @param service_enable +# @param service_ensure +# @param service_provider +# +class datadog_agent::security_agent ( + Boolean $enabled = false, + Optional[String] $socket = undef, + Boolean $service_enable = true, + String $service_ensure = 'running', Optional[String] $service_provider = undef, - ) inherits datadog_agent::params { - $securityagent_config = { 'runtime_security_config' => { 'enabled' => $enabled, - 'socket' => $socket, + 'socket' => $socket, }, } if $facts['os']['name'] == 'Windows' { - file { 'C:/ProgramData/Datadog/security-agent.yaml': owner => $datadog_agent::params::dd_user, group => $datadog_agent::params::dd_group, @@ -24,9 +28,7 @@ content => template('datadog_agent/security-agent.yaml.erb'), require => File['C:/ProgramData/Datadog'], } - } else { - if $service_provider { service { $datadog_agent::params::securityagent_service_name: ensure => $service_ensure, @@ -55,5 +57,4 @@ require => File['/etc/datadog-agent'], } } - } diff --git a/manifests/service.pp b/manifests/service.pp index fbd74eef..8689c8dc 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -2,21 +2,24 @@ # # This class declares the datadog-agent service # - -class datadog_agent::service( - $service_ensure = 'running', +# @param service_ensure +# @param service_enable +# @param service_provider +# @param agent_flavor +# +class datadog_agent::service ( + String $service_ensure = 'running', Variant[Boolean, Enum['manual', 'mask', 'delayed']] $service_enable = true, - Optional[String] $service_provider = undef, - String $agent_flavor = $datadog_agent::params::package_name, + Optional[String] $service_provider = undef, + String $agent_flavor = $datadog_agent::params::package_name, ) inherits datadog_agent::params { - if ($facts['os']['name'] == 'Windows') { - service { $datadog_agent::params::service_name: - ensure => $service_ensure, - enable => $service_enable, - restart => ['powershell', '-Command', 'Restart-Service -Force DatadogAgent'], # Force restarts dependent services - require => Package[$datadog_agent::params::package_name] - } + service { $datadog_agent::params::service_name: + ensure => $service_ensure, + enable => $service_enable, + restart => ['powershell', '-Command', 'Restart-Service -Force DatadogAgent'], # Force restarts dependent services + require => Package[$datadog_agent::params::package_name], + } } else { if $service_provider { service { $datadog_agent::params::service_name: @@ -37,6 +40,4 @@ } } } - - } diff --git a/manifests/suse.pp b/manifests/suse.pp index 554d801a..e4aa1c80 100644 --- a/manifests/suse.pp +++ b/manifests/suse.pp @@ -2,16 +2,21 @@ # # This class contains the DataDog agent installation mechanism for SUSE distributions # - -class datadog_agent::suse( - Integer $agent_major_version = $datadog_agent::params::default_agent_major_version, - String $agent_version = $datadog_agent::params::agent_version, - String $release = $datadog_agent::params::apt_default_release, - Optional[String] $agent_repo_uri = undef, - String $agent_flavor = $datadog_agent::params::package_name, +# @param agent_major_version +# @param agent_version +# @param release +# @param agent_repo_uri +# @param agent_flavor +# @param rpm_repo_gpgcheck +# +class datadog_agent::suse ( + Integer $agent_major_version = $datadog_agent::params::default_agent_major_version, + String $agent_version = $datadog_agent::params::agent_version, + String $release = $datadog_agent::params::apt_default_release, + Optional[String] $agent_repo_uri = undef, + String $agent_flavor = $datadog_agent::params::package_name, Optional[Boolean] $rpm_repo_gpgcheck = undef, ) inherits datadog_agent::params { - $current_key = 'https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public' $all_keys = [ $current_key, @@ -31,10 +36,10 @@ } case $agent_major_version { - 5 : { fail('Agent v5 package not available in SUSE') } - 6 : { $gpgkeys = $all_keys } - 7 : { $gpgkeys = $all_keys } - default: { fail('invalid agent_major_version') } + '5' : { fail('Agent v5 package not available in SUSE') } + '6' : { $gpgkeys = $all_keys } + '7' : { $gpgkeys = $all_keys } + default: { fail('invalid agent_major_version') } } if ($agent_repo_uri != undef) { @@ -91,5 +96,4 @@ package { $agent_flavor: ensure => $agent_version, } - } diff --git a/manifests/system_probe.pp b/manifests/system_probe.pp index df0443a5..ef889c5b 100644 --- a/manifests/system_probe.pp +++ b/manifests/system_probe.pp @@ -4,22 +4,29 @@ # On Windows, install the NPM driver by setting 'windows_npm_install' # to 'true on the datadog_agent class. # - -class datadog_agent::system_probe( - Boolean $enabled = false, - Boolean $network_enabled = false, - Boolean $service_monitoring_enabled = false, - Optional[String] $log_file = undef, - Optional[String] $sysprobe_socket = undef, - Optional[Boolean] $enable_oom_kill = false, +# @param enabled +# @param network_enabled +# @param service_monitoring_enabled +# @param log_file +# @param sysprobe_socket +# @param enable_oom_kill +# @param runtime_security_config +# @param service_enable +# @param service_ensure +# @param service_provider +# +class datadog_agent::system_probe ( + Boolean $enabled = false, + Boolean $network_enabled = false, + Boolean $service_monitoring_enabled = false, + Optional[String] $log_file = undef, + Optional[String] $sysprobe_socket = undef, + Optional[Boolean] $enable_oom_kill = undef, Optional[Hash] $runtime_security_config = undef, - - Boolean $service_enable = true, - String $service_ensure = 'running', + Boolean $service_enable = true, + String $service_ensure = 'running', Optional[String] $service_provider = undef, ) inherits datadog_agent::params { - - $sysprobe_config = { 'system_probe_config' => { 'enabled' => $enabled, @@ -45,9 +52,7 @@ require => File['C:/ProgramData/Datadog'], notify => Service[$datadog_agent::params::service_name], } - } else { - if $service_provider { service { $datadog_agent::params::sysprobe_service_name: ensure => $service_ensure, @@ -76,5 +81,4 @@ require => File['/etc/datadog-agent'], } } - } diff --git a/manifests/tag5.pp b/manifests/tag5.pp index 9134b421..90354eb8 100644 --- a/manifests/tag5.pp +++ b/manifests/tag5.pp @@ -1,18 +1,21 @@ # Allow custom tags via a define -define datadog_agent::tag5( - $tag_name = $name, - $lookup_fact = false, -){ - - if $lookup_fact{ +# +# @param tag_name +# @param lookup_fact +# +define datadog_agent::tag5 ( + String $tag_name = $name, + Boolean $lookup_fact = false, +) { + if $lookup_fact { $value = getvar($tag_name) - if is_array($value){ + if is_array($value) { $tags = prefix($value, "${tag_name}:") - datadog_agent::tag5{$tags: } + datadog_agent::tag5 { $tags: } } else { if $value { - concat::fragment{ "datadog tag ${tag_name}:${value}": + concat::fragment { "datadog tag ${tag_name}:${value}": target => '/etc/dd-agent/datadog.conf', content => "${tag_name}:${value}, ", order => '03', @@ -20,11 +23,10 @@ } } } else { - concat::fragment{ "datadog tag ${tag_name}": + concat::fragment { "datadog tag ${tag_name}": target => '/etc/dd-agent/datadog.conf', content => "${tag_name}, ", order => '03', } } - } diff --git a/manifests/ubuntu.pp b/manifests/ubuntu.pp index 806cbef8..79847023 100644 --- a/manifests/ubuntu.pp +++ b/manifests/ubuntu.pp @@ -2,24 +2,32 @@ # # This class contains the DataDog agent installation mechanism for Debian derivatives # - -class datadog_agent::ubuntu( - Integer $agent_major_version = $datadog_agent::params::default_agent_major_version, - String $agent_version = $datadog_agent::params::agent_version, - Optional[String] $agent_repo_uri = undef, - String $release = $datadog_agent::params::apt_default_release, - Boolean $skip_apt_key_trusting = false, - String $agent_flavor = $datadog_agent::params::package_name, - Optional[String] $apt_trusted_d_keyring = '/etc/apt/trusted.gpg.d/datadog-archive-keyring.gpg', - Optional[String] $apt_usr_share_keyring = '/usr/share/keyrings/datadog-archive-keyring.gpg', - Optional[Hash[String, String]] $apt_default_keys = { +# @param agent_major_version +# @param agent_version +# @param agent_repo_uri +# @param release +# @param skip_apt_key_trusting +# @param agent_flavor +# @param apt_trusted_d_keyring +# @param apt_usr_share_keyring +# @param apt_default_keys +# +class datadog_agent::ubuntu ( + Variant[Integer, String] $agent_major_version = $datadog_agent::params::default_agent_major_version, + String $agent_version = $datadog_agent::params::agent_version, + Optional[String] $agent_repo_uri = undef, + String $release = $datadog_agent::params::apt_default_release, + Boolean $skip_apt_key_trusting = false, + String $agent_flavor = $datadog_agent::params::package_name, + String $apt_trusted_d_keyring = '/etc/apt/trusted.gpg.d/datadog-archive-keyring.gpg', + String $apt_usr_share_keyring = '/usr/share/keyrings/datadog-archive-keyring.gpg', + Hash[String, String] $apt_default_keys = { 'DATADOG_APT_KEY_CURRENT.public' => 'https://keys.datadoghq.com/DATADOG_APT_KEY_CURRENT.public', '5F1E256061D813B125E156E8E6266D4AC0962C7D' => 'https://keys.datadoghq.com/DATADOG_APT_KEY_C0962C7D.public', 'D75CEA17048B9ACBF186794B32637D44F14F620E' => 'https://keys.datadoghq.com/DATADOG_APT_KEY_F14F620E.public', 'A2923DFF56EDA6E76E55E492D3A80E30382E94DE' => 'https://keys.datadoghq.com/DATADOG_APT_KEY_382E94DE.public', }, ) inherits datadog_agent::params { - if $agent_version =~ /^[0-9]+\.[0-9]+\.[0-9]+((?:~|-)[^0-9\s-]+[^-\s]*)?$/ { $platform_agent_version = "1:${agent_version}-1" } @@ -28,9 +36,9 @@ } case $agent_major_version { - 5 : { $repos = 'main' } - 6 : { $repos = '6' } - 7 : { $repos = '7' } + '5' : { $repos = 'main' } + '6' : { $repos = '6' } + '7' : { $repos = '7' } default: { fail('invalid agent_major_version') } } @@ -55,7 +63,7 @@ exec { "ensure key ${key_fingerprint} is imported in APT keyring": command => "/bin/cat /tmp/${key_fingerprint} | gpg --import --batch --no-default-keyring --keyring ${apt_usr_share_keyring}", # the second part extracts the fingerprint of the key from output like "fpr::::A2923DFF56EDA6E76E55E492D3A80E30382E94DE:" - unless => @("CMD"/L) + unless => @("CMD"/L), /usr/bin/gpg --no-default-keyring --keyring ${apt_usr_share_keyring} --list-keys --with-fingerprint --with-colons | grep \ $(cat /tmp/${key_fingerprint} | gpg --with-colons --with-fingerprint 2>/dev/null | grep 'fpr:' | sed 's|^fpr||' | tr -d ':') | CMD @@ -63,7 +71,7 @@ } if ($facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['full'], '16') == -1) or - ($facts['os']['name'] == 'Debian' and versioncmp($facts['os']['release']['full'], '9') == -1) { + ($facts['os']['name'] == 'Debian' and versioncmp($facts['os']['release']['full'], '9') == -1) { file { $apt_trusted_d_keyring: mode => '0644', source => "file://${apt_usr_share_keyring}", @@ -104,12 +112,12 @@ package { $agent_flavor: ensure => $platform_agent_version, require => [Apt::Source['datadog'], - Class['apt::update']], + Class['apt::update']], } package { 'datadog-signing-keys': ensure => 'latest', require => [Apt::Source['datadog'], - Class['apt::update']], + Class['apt::update']], } } diff --git a/manifests/windows.pp b/manifests/windows.pp index 15e014af..795e452b 100644 --- a/manifests/windows.pp +++ b/manifests/windows.pp @@ -2,23 +2,35 @@ # # This class contains the DataDog agent installation mechanism for Windows # - -class datadog_agent::windows( - Integer $agent_major_version = $datadog_agent::params::default_agent_major_version, - String $agent_version = $datadog_agent::params::agent_version, - Optional[String] $agent_repo_uri = undef, - String $msi_location = 'C:/Windows/temp', - String $api_key = $datadog_agent::api_key, - String $hostname = $datadog_agent::host, - Array $tags = $datadog_agent::tags, - String $tags_join = join($tags,','), - String $tags_quote_wrap = "\"${tags_join}\"", - Enum['present', 'absent'] $ensure = 'present', - Boolean $npm_install = false, - Optional[String] $ddagentuser_name = undef, - Optional[String] $ddagentuser_password = undef, +# @param agent_major_version +# @param agent_version +# @param agent_repo_uri +# @param msi_location +# @param api_key +# @param hostname +# @param tags +# @param tags_join +# @param tags_quote_wrap +# @param ensure +# @param npm_install +# @param ddagentuser_name +# @param ddagentuser_password +# +class datadog_agent::windows ( + Variant[Integer, String] $agent_major_version = $datadog_agent::params::default_agent_major_version, + String $agent_version = $datadog_agent::params::agent_version, + Optional[String] $agent_repo_uri = undef, + String $msi_location = 'C:/Windows/temp', + String $api_key = $datadog_agent::api_key, + String $hostname = $datadog_agent::host, + Array $tags = $datadog_agent::tags, + String $tags_join = join($tags,','), + String $tags_quote_wrap = "\"${tags_join}\"", + Enum['present', 'absent'] $ensure = 'present', + Boolean $npm_install = false, + Optional[String] $ddagentuser_name = undef, + Optional[String] $ddagentuser_password = undef, ) inherits datadog_agent::params { - $msi_full_path = "${msi_location}/datadog-agent-${agent_major_version}-${agent_version}.amd64.msi" if ($agent_repo_uri != undef) { @@ -71,16 +83,15 @@ $hostname_option = $hostname ? { '' => {}, default => { 'HOSTNAME' => $hostname } } $npm_install_option = $npm_install ? { false => {}, true => { 'ADDLOCAL' => 'MainApplication,NPM' } } - $ddagentuser_name_option = $ddagentuser_name ? { undef => {}, default => { 'DDAGENTUSER_NAME' => $ddagentuser_name}} - $ddagentuser_password_option = ($ddagentuser_name != undef and $ddagentuser_password != undef) ? { true => {'DDAGENTUSER_PASSWORD' => $ddagentuser_password}, false => {}} + $ddagentuser_name_option = $ddagentuser_name ? { undef => {}, default => { 'DDAGENTUSER_NAME' => $ddagentuser_name } } + $ddagentuser_password_option = ($ddagentuser_name != undef and $ddagentuser_password != undef) ? { true => { 'DDAGENTUSER_PASSWORD' => $ddagentuser_password }, false => {} } package { $datadog_agent::params::package_name: ensure => $ensure_version, provider => 'windows', source => $msi_full_path, - install_options => ['/norestart', {'APIKEY' => $api_key, 'TAGS' => $tags_quote_wrap} + $npm_install_option + $hostname_option + $ddagentuser_name_option + $ddagentuser_password_option] + install_options => ['/norestart', { 'APIKEY' => $api_key, 'TAGS' => $tags_quote_wrap } + $npm_install_option + $hostname_option + $ddagentuser_name_option + $ddagentuser_password_option], } - } else { exec { 'datadog_6_14_fix': command => "((New-Object System.Net.WebClient).DownloadFile('https://s3.amazonaws.com/ddagent-windows-stable/scripts/fix_6_14.ps1', \$env:temp + '\\fix_6_14.ps1')); &\$env:temp\\fix_6_14.ps1", @@ -93,6 +104,5 @@ uninstall_options => ['/quiet'], subscribe => Exec['datadog_6_14_fix'], } - } } diff --git a/metadata.json b/metadata.json index ba75907b..d9a322ad 100644 --- a/metadata.json +++ b/metadata.json @@ -10,7 +10,7 @@ "dependencies": [ { "name": "puppetlabs/stdlib", - "version_requirement": ">=4.25.0 <9.0.0" + "version_requirement": ">=4.25.0 <10.0.0" }, { "name": "puppetlabs/concat", @@ -148,7 +148,7 @@ "requirements": [ { "name": "puppet", - "version_requirement": ">=4.6.0 <8.0.0" + "version_requirement": ">=4.6.0 <9.0.0" } ], "description": "This will install the Datadog monitoring agent. Sign up and get your API key at: http://www.datadoghq.com",