diff --git a/manifests/init.pp b/manifests/init.pp index b124f2f8..badd8b62 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -646,309 +646,198 @@ } } - if $_agent_major_version == 5 { - 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': } - } - - file { '/etc/dd-agent': - ensure => directory, - owner => $dd_user, - group => $dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$agent_flavor], - } - - file { $_conf_dir: - ensure => directory, - purge => $conf_dir_purge, - recurse => true, - force => $conf_dir_purge, - owner => $dd_user, - group => $dd_group, - notify => Service[$datadog_agent::params::service_name], - } - - concat { '/etc/dd-agent/datadog.conf': - owner => $dd_user, - group => $dd_group, - mode => '0640', - notify => Service[$datadog_agent::params::service_name], - require => File['/etc/dd-agent'], - } - - if $dd_url.empty { - $_dd_url = 'https://app.datadoghq.com' - } else { - $_dd_url = $dd_url - } - concat::fragment { 'datadog header': - target => '/etc/dd-agent/datadog.conf', - content => template('datadog_agent/datadog_header.conf.erb'), - order => '01', - } - - 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: - lookup_fact => true, - } - - concat::fragment { 'datadog footer': - target => '/etc/dd-agent/datadog.conf', - content => template('datadog_agent/datadog_footer.conf.erb'), - order => '05', + # 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, + } + if $logs_open_files_limit { + $logs_base_config = { + 'logs_config' => { + 'container_collect_all' => $container_collect_all, + 'open_files_limit' => $logs_open_files_limit, + }, } - - unless $extra_template.empty { - concat::fragment { 'datadog extra_template footer': - target => '/etc/dd-agent/datadog.conf', - content => template($extra_template), - order => '06', - } + } else { + $logs_base_config = { + 'logs_config' => { + 'container_collect_all' => $container_collect_all, + }, } - - if ($apm_enabled == true) and (($apm_env != 'none') or $apm_analyzed_spans or $apm_obfuscation) { - concat::fragment { 'datadog apm footer': - target => '/etc/dd-agent/datadog.conf', - content => template('datadog_agent/datadog_apm_footer.conf.erb'), - order => '07', - } + } + if $host.empty { + $host_config = {} + } else { + $host_config = { + 'hostname' => $host, } + } - if ($process_enabled == true) { - concat::fragment { 'datadog process agent footer': - target => '/etc/dd-agent/datadog.conf', - content => template('datadog_agent/datadog_process_footer.conf.erb'), - order => '08', - } + if $apm_analyzed_spans { + $apm_analyzed_span_config = { + 'apm_config' => { + 'analyzed_spans' => $apm_analyzed_spans, + }, } + } else { + $apm_analyzed_span_config = {} + } - 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'], + if $apm_obfuscation { + $apm_obfuscation_config = { + 'apm_config' => { + 'obfuscation' => $apm_obfuscation, + }, } - } else { #Agent 6/7 + } else { + $apm_obfuscation_config = {} + } - # 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': } - } - if !empty($proxy_port) { - 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': } - } - if !empty($proxy_password) { - notify { 'Setting proxy_password is only used with Agent 5. Please use agent_extra_options to set your proxy': } + if $apm_filter_tags { + $apm_filter_tags_config = { + 'apm_config' => { + 'filter_tags' => $apm_filter_tags, + }, } + } else { + $apm_filter_tags_config = {} + } - # lint:ignore:quoted_booleans - $process_enabled_str = $process_enabled ? { true => 'true' , default => 'disabled' } - # lint:endignore - $base_extra_config = { + if $apm_filter_tags_regex { + $apm_filter_tags_regex_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, + 'filter_tags_regex' => $apm_filter_tags_regex, }, - '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, - }, - } - } else { - $logs_base_config = { - 'logs_config' => { - 'container_collect_all' => $container_collect_all, - }, + } else { + $apm_filter_tags_regex_config = {} + } + + if $statsd_forward_host.empty { + $statsd_forward_config = {} + } else { + if String($statsd_forward_port).empty { + $statsd_forward_config = { + 'statsd_forward_host' => $statsd_forward_host, } - } - if $host.empty { - $host_config = {} } else { - $host_config = { - 'hostname' => $host, + $statsd_forward_config = { + 'statsd_forward_host' => $statsd_forward_host, + 'statsd_forward_port' => $statsd_forward_port, } } + } - if $apm_analyzed_spans { - $apm_analyzed_span_config = { - 'apm_config' => { - 'analyzed_spans' => $apm_analyzed_spans, - }, - } - } else { - $apm_analyzed_span_config = {} + if $additional_checksd { + $additional_checksd_config = { + 'additional_checksd' => $additional_checksd, } + } else { + $additional_checksd_config = {} + } - if $apm_obfuscation { - $apm_obfuscation_config = { - 'apm_config' => { - 'obfuscation' => $apm_obfuscation, - }, - } - } else { - $apm_obfuscation_config = {} - } + $extra_config = deep_merge( + $base_extra_config, + $logs_base_config, + $agent_extra_options, + $apm_analyzed_span_config, + $apm_obfuscation_config, + $apm_filter_tags_config, + $apm_filter_tags_regex_config, + $statsd_forward_config, + $host_config, + $additional_checksd_config + ) + + file { $_conf_dir: + ensure => directory, + purge => $conf_dir_purge, + recurse => true, + force => $conf_dir_purge, + owner => $dd_user, + group => $dd_group, + } - if $apm_filter_tags { - $apm_filter_tags_config = { - 'apm_config' => { - 'filter_tags' => $apm_filter_tags, - }, - } - } else { - $apm_filter_tags_config = {} - } + if ! $_agent_managed_by_installer { + File[$_conf_dir] ~> Service[$datadog_agent::params::service_name] + } - if $apm_filter_tags_regex { - $apm_filter_tags_regex_config = { - 'apm_config' => { - 'filter_tags_regex' => $apm_filter_tags_regex, - }, - } - } else { - $apm_filter_tags_regex_config = {} - } + $_local_tags = datadog_agent::tag6($local_tags, false, undef) + $_facts_tags = datadog_agent::tag6($facts_to_tags, true, $facts) + $_trusted_facts_tags = datadog_agent::tag6($trusted_facts_to_tags, true, $trusted) + + $_agent_config = { + 'api_key' => $api_key, + 'dd_url' => $dd_url, + 'site' => $datadog_site, + 'cmd_port' => $cmd_port, + 'hostname_fqdn' => $hostname_fqdn, + 'collect_ec2_tags' => $collect_ec2_tags, + 'collect_gce_tags' => $collect_gce_tags, + 'confd_path' => $_conf_dir, + 'enable_metadata_collection' => $collect_instance_metadata, + 'dogstatsd_port' => $dogstatsd_port, + 'dogstatsd_socket' => $dogstatsd_socket, + 'dogstatsd_non_local_traffic' => $non_local_traffic, + 'log_file' => $agent_log_file, + 'log_level' => $log_level, + 'remote_updates' => $remote_updates, + 'remote_policies' => $remote_policies, + 'tags' => unique(flatten(union($_local_tags, $_facts_tags, $_trusted_facts_tags))), + } - if $statsd_forward_host.empty { - $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, - } - } + $agent_config = deep_merge($_agent_config, $extra_config) + + if ($facts['os']['name'] == 'Windows') { + file { 'C:/ProgramData/Datadog': + ensure => directory, } - if $additional_checksd { - $additional_checksd_config = { - 'additional_checksd' => $additional_checksd, - } - } else { - $additional_checksd_config = {} + file { 'C:/ProgramData/Datadog/datadog.yaml': + owner => $dd_user, + group => $dd_group, + mode => '0660', + content => template('datadog_agent/datadog.yaml.erb'), + show_diff => false, + notify => Service[$datadog_agent::params::service_name], + require => File['C:/ProgramData/Datadog'], } - $extra_config = deep_merge( - $base_extra_config, - $logs_base_config, - $agent_extra_options, - $apm_analyzed_span_config, - $apm_obfuscation_config, - $apm_filter_tags_config, - $apm_filter_tags_regex_config, - $statsd_forward_config, - $host_config, - $additional_checksd_config - ) - - file { $_conf_dir: - ensure => directory, - purge => $conf_dir_purge, - recurse => true, - force => $conf_dir_purge, + file { 'C:/ProgramData/Datadog/install_info': owner => $dd_user, group => $dd_group, + mode => '0660', + content => template('datadog_agent/install_info.erb'), + require => File['C:/ProgramData/Datadog'], } - - if ! $_agent_managed_by_installer { - File[$_conf_dir] ~> Service[$datadog_agent::params::service_name] - } - - $_local_tags = datadog_agent::tag6($local_tags, false, undef) - $_facts_tags = datadog_agent::tag6($facts_to_tags, true, $facts) - $_trusted_facts_tags = datadog_agent::tag6($trusted_facts_to_tags, true, $trusted) - - $_agent_config = { - 'api_key' => $api_key, - 'dd_url' => $dd_url, - 'site' => $datadog_site, - 'cmd_port' => $cmd_port, - 'hostname_fqdn' => $hostname_fqdn, - 'collect_ec2_tags' => $collect_ec2_tags, - 'collect_gce_tags' => $collect_gce_tags, - 'confd_path' => $_conf_dir, - 'enable_metadata_collection' => $collect_instance_metadata, - 'dogstatsd_port' => $dogstatsd_port, - 'dogstatsd_socket' => $dogstatsd_socket, - 'dogstatsd_non_local_traffic' => $non_local_traffic, - 'log_file' => $agent_log_file, - 'log_level' => $log_level, - 'remote_updates' => $remote_updates, - 'remote_policies' => $remote_policies, - 'tags' => unique(flatten(union($_local_tags, $_facts_tags, $_trusted_facts_tags))), + } else { + file { '/etc/datadog-agent/datadog.yaml': + owner => $dd_user, + group => $dd_group, + mode => '0640', + content => template('datadog_agent/datadog.yaml.erb'), + show_diff => false, + notify => Service[$datadog_agent::params::service_name], + require => File['/etc/datadog-agent'], } - $agent_config = deep_merge($_agent_config, $extra_config) - - if ($facts['os']['name'] == 'Windows') { - file { 'C:/ProgramData/Datadog': - ensure => directory, - } - - file { 'C:/ProgramData/Datadog/datadog.yaml': - owner => $dd_user, - group => $dd_group, - mode => '0660', - content => template('datadog_agent/datadog.yaml.erb'), - show_diff => false, - notify => Service[$datadog_agent::params::service_name], - require => File['C:/ProgramData/Datadog'], - } - - file { 'C:/ProgramData/Datadog/install_info': - owner => $dd_user, - group => $dd_group, - mode => '0660', - 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, - mode => '0640', - content => template('datadog_agent/datadog.yaml.erb'), - show_diff => false, - notify => Service[$datadog_agent::params::service_name], - require => File['/etc/datadog-agent'], - } - - file { '/etc/datadog-agent/install_info': - owner => $dd_user, - group => $dd_group, - mode => '0640', - content => template('datadog_agent/install_info.erb'), - require => File['/etc/datadog-agent'], - } + file { '/etc/datadog-agent/install_info': + owner => $dd_user, + group => $dd_group, + mode => '0640', + content => template('datadog_agent/install_info.erb'), + require => File['/etc/datadog-agent'], } } diff --git a/spec/classes/datadog_agent_integrations_kafka_spec.rb b/spec/classes/datadog_agent_integrations_kafka_spec.rb index 1c32579a..fdeacea2 100644 --- a/spec/classes/datadog_agent_integrations_kafka_spec.rb +++ b/spec/classes/datadog_agent_integrations_kafka_spec.rb @@ -5,11 +5,7 @@ context 'supported agents' do let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/kafka.yaml' - else - "#{CONF_DIR}/kafka.d/conf.yaml" - end + conf_file = "#{CONF_DIR}/kafka.d/conf.yaml" it { is_expected.to compile.with_all_deps } it { diff --git a/spec/classes/datadog_agent_redhat_spec.rb b/spec/classes/datadog_agent_redhat_spec.rb index 2c4ea4da..c469717f 100644 --- a/spec/classes/datadog_agent_redhat_spec.rb +++ b/spec/classes/datadog_agent_redhat_spec.rb @@ -1,66 +1,6 @@ require 'spec_helper' describe 'datadog_agent::redhat' do - context 'agent 5' do - if RSpec::Support::OS.windows? - return - end - - let(:facts) do - { - os: { - 'architecture' => 'x86_64', - 'family' => 'redhat', - 'name' => 'Fedora', - 'release' => { - 'major' => '36', - 'full' => '36', - }, - }, - } - end - - # it should install the mirror - context 'with manage_repo => true' do - let(:params) do - { - manage_repo: true, - agent_major_version: 5, - } - end - - it do - is_expected.to contain_yumrepo('datadog') - .with_enabled(1)\ - .with_gpgcheck(1)\ - .with_gpgkey('https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.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_E09422B3.public')\ - .with_baseurl('https://yum.datadoghq.com/rpm/x86_64/')\ - .with_repo_gpgcheck(false) - end - end - context 'with manage_repo => false' do - let(:params) do - { - manage_repo: false, agent_major_version: 5 - } - end - - it do - is_expected.not_to contain_yumrepo('datadog') - is_expected.not_to contain_yumrepo('datadog5') - is_expected.not_to contain_yumrepo('datadog6') - end - end - # it should install the packages - it do - is_expected.to contain_package('datadog-agent')\ - .with_ensure('latest') - end - end - context 'agent 6' do let(:facts) do { diff --git a/spec/classes/datadog_agent_spec.rb b/spec/classes/datadog_agent_spec.rb index 60e59342..0fc614fe 100644 --- a/spec/classes/datadog_agent_spec.rb +++ b/spec/classes/datadog_agent_spec.rb @@ -29,32 +29,6 @@ end end - context 'autodetect major version agent 5' do - let(:params) do - { - agent_version: '5.15.1', - } - end - let(:facts) do - { - os: { - 'architecture' => 'x86_64', - 'family' => 'debian', - 'name' => 'Ubuntu', - 'release' => { - 'major' => '14', - 'full' => '14.04', - }, - }, - } - end - - it do - is_expected.to contain_file('/etc/apt/sources.list.d/datadog.list')\ - .with_content(%r{deb\s+\[signed-by=/usr/share/keyrings/datadog-archive-keyring.gpg\]\s+https://apt.datadoghq.com/\s+stable\s+main}) - end - end - context 'autodetect major version agent 6' do let(:params) do { @@ -158,6 +132,9 @@ 'major' => '14', 'full' => '14.04', }, + 'distro' => { + 'codename' => 'trusty', + }, }, } end @@ -184,6 +161,9 @@ 'major' => '14', 'full' => '14.04', }, + 'distro' => { + 'codename' => 'trusty', + }, }, } end @@ -210,6 +190,9 @@ 'major' => '14', 'full' => '14.04', }, + 'distro' => { + 'codename' => 'trusty', + }, }, } end @@ -238,6 +221,9 @@ 'major' => '14', 'full' => '14.04', }, + 'distro' => { + 'codename' => 'trusty', + }, }, } end @@ -316,6 +302,9 @@ 'major' => getosmajor(operatingsystem), 'full' => getosrelease(operatingsystem), }, + 'distro' => { + 'code' => getoscodename(operatingsystem), + } }, } end @@ -348,1304 +337,6 @@ end end - describe "datadog_agent 5 class common actions on #{operatingsystem}" do - let(:params) do - { - puppet_run_reports: true, - agent_major_version: 5, - } - end - let(:facts) do - { - os: { - 'architecture' => 'x86_64', - 'family' => getosfamily(operatingsystem), - 'name' => operatingsystem, - 'release' => { - 'major' => getosmajor(operatingsystem), - 'full' => getosrelease(operatingsystem), - }, - }, - } - end - - if WINDOWS_OS.include?(operatingsystem) - it 'agent 5 should raise on Windows' do - is_expected.to raise_error(Puppet::Error, %r{Installation of agent 5 with puppet is not supported on Windows}) - end - else - it { is_expected.to compile.with_all_deps } - - it { is_expected.to contain_class('datadog_agent') } - - describe 'datadog_agent imports the default params' do - it { is_expected.to contain_class('datadog_agent::params') } - end - - it { is_expected.to contain_file('/etc/datadog-agent') } - it { is_expected.to contain_file('/etc/dd-agent') } - it { is_expected.to contain_concat('/etc/dd-agent/datadog.conf') } - it { is_expected.to contain_file('/etc/dd-agent/conf.d').with_ensure('directory') } - - it { is_expected.to contain_class('datadog_agent::reports') } - - describe 'parameter check' do - context 'with defaults' do - context 'for proxy' do - it { - is_expected.to contain_concat__fragment('datadog header').with( - 'content' => %r{dd_url: https://app.datadoghq.com\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog header').with( - 'content' => %r{^# proxy_host:\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog header').with( - 'content' => %r{^# proxy_port:\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog header').with( - 'content' => %r{^# proxy_user:\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog header').with( - 'content' => %r{^# proxy_password:\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog header').with( - 'content' => %r{^# skip_ssl_validation: no\n}, - ) - } - end - - context 'for general' do - it { - is_expected.to contain_concat__fragment('datadog header').with( - 'content' => %r{^api_key: your_API_key\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog header').with( - 'content' => %r{^# hostname:\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^non_local_traffic: false\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^collect_ec2_tags: false\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^collect_instance_metadata: true\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{# recent_point_threshold: 30\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^# listen_port: 17123\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^# graphite_listen_port: 17124\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{# additional_checksd: /etc/dd-agent/checks.d/\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^use_curl_http_client: false\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^# device_blacklist_re: .*\\/dev\\/mapper\\/lxc-box.*\n}, - ) - } - end - - context 'for pup' do - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^use_pup: no\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^# pup_port: 17125\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^# pup_interface: localhost\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{# pup_url: http://localhost:17125\n}, - ) - } - end - - context 'for dogstatsd' do - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^# bind_host: localhost\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^use_dogstatsd: yes\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^dogstatsd_port: 8125\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{# dogstatsd_target: http://localhost:17123\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^# dogstatsd_interval: 10\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^dogstatsd_normalize: yes\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^# statsd_forward_host: address_of_own_statsd_server\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^# statsd_forward_port: 8125\n}, - ) - } - end - - context 'for logging' do - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^log_level: INFO\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^log_to_syslog: yes\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{# collector_log_file: /var/log/datadog/collector.log\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{# forwarder_log_file: /var/log/datadog/forwarder.log\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{# dogstatsd_log_file: /var/log/datadog/dogstatsd.log\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with - # 'content' => %r{# pup_log_file: /var/log/datadog/pup.log\n}, - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^# syslog_host:\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^# syslog_port:\n}, - ) - } - end - - context 'for service_discovery' do - it { - is_expected.to contain_concat__fragment('datadog footer').without( - 'content' => %r{^service_discovery_backend:\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').without( - 'content' => %r{^sd_config_backend:\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').without( - 'content' => %r{^sd_backend_host:\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').without( - 'content' => %r{^sd_backend_port:\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').without( - 'content' => %r{^sd_template_dir:\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').without( - 'content' => %r{^consul_token:\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').without( - 'content' => %r{^# sd_jmx_enable:\n}, - ) - } - end - - context 'for APM' do - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^apm_enabled: false\n}, - ) - } - end - end - - context 'with user provided paramaters' do - context 'with a custom dd_url' do - let(:params) do - { - dd_url: 'https://notaurl.datadoghq.com', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog header').with( - 'content' => %r{dd_url: https://notaurl.datadoghq.com\n}, - ) - } - end - context 'with a custom proxy_host' do - let(:params) do - { - proxy_host: 'localhost', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog header').with( - 'content' => %r{^proxy_host: localhost\n}, - ) - } - end - context 'with a custom proxy_port' do - let(:params) do - { - proxy_port: '1234', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog header').with( - 'content' => %r{^proxy_port: 1234\n}, - ) - } - end - context 'with a custom proxy_port, specified as an integer' do - let(:params) do - { - proxy_port: 1234, - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog header').with( - 'content' => %r{^proxy_port: 1234\n}, - ) - } - end - context 'with a custom proxy_user' do - let(:params) do - { - proxy_user: 'notauser', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog header').with( - 'content' => %r{^proxy_user: notauser\n}, - ) - } - end - context 'with a custom api_key' do - let(:params) do - { - api_key: 'notakey', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog header').with( - 'content' => %r{^api_key: notakey\n}, - ) - } - end - context 'with a custom hostname' do - let(:params) do - { - host: 'notahost', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog header').with( - 'content' => %r{^hostname: notahost\n}, - ) - } - end - context 'with non_local_traffic set to true' do - let(:params) do - { - non_local_traffic: true, - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^non_local_traffic: true\n}, - ) - } - end - # Should expand testing to cover changes to the case upcase - context 'with log level set to critical' do - let(:params) do - { - log_level: 'critical', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^log_level: CRITICAL\n}, - ) - } - end - context 'with a custom hostname' do - let(:params) do - { - host: 'notahost', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog header').with( - 'content' => %r{^hostname: notahost\n}, - ) - } - end - context 'with log_to_syslog set to false' do - let(:params) do - { - log_to_syslog: false, - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^log_to_syslog: no\n}, - ) - } - end - context 'with skip_ssl_validation set to true' do - let(:params) do - { - skip_ssl_validation: true, - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog header').with( - 'content' => %r{^skip_ssl_validation: true\n}, - ) - } - end - context 'with collect_ec2_tags set to yes' do - let(:params) do - { - collect_ec2_tags: true, - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^collect_ec2_tags: true\n}, - ) - } - end - context 'with collect_instance_metadata set to no' do - let(:params) do - { - collect_instance_metadata: false, - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^collect_instance_metadata: false\n}, - ) - } - end - context 'with recent_point_threshold set to 60' do - let(:params) do - { - recent_point_threshold: '60', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^recent_point_threshold: 60\n}, - ) - } - end - context 'with a custom port set to 17125' do - let(:params) do - { - listen_port: '17125', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^listen_port: 17125\n}, - ) - } - end - context 'with a custom port set to 17125, specified as an integer' do - let(:params) do - { - listen_port: 17_125, - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^listen_port: 17125\n}, - ) - } - end - context 'listening for graphite data on port 17124' do - let(:params) do - { - graphite_listen_port: '17124', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^graphite_listen_port: 17124\n}, - ) - } - end - context 'listening for graphite data on port 17124, port specified as an integer' do - let(:params) do - { - graphite_listen_port: 17_124, - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^graphite_listen_port: 17124\n}, - ) - } - end - context 'with configuration for a custom checks.d' do - let(:params) do - { - additional_checksd: '/etc/dd-agent/checks_custom.d', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{additional_checksd: /etc/dd-agent/checks_custom.d\n}, - ) - } - end - context 'with configuration for a custom checks.d' do - let(:params) do - { - additional_checksd: '/etc/dd-agent/checks_custom.d', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{additional_checksd: /etc/dd-agent/checks_custom.d\n}, - ) - } - end - context 'with configuration for a custom checks.d' do - let(:params) do - { - additional_checksd: '/etc/dd-agent/checks_custom.d', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{additional_checksd: /etc/dd-agent/checks_custom.d\n}, - ) - } - end - context 'with using the Tornado HTTP client' do - let(:params) do - { - use_curl_http_client: true, - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^use_curl_http_client: true\n}, - ) - } - end - context 'with a custom bind_host' do - let(:params) do - { - bind_host: 'test', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^bind_host: test\n}, - ) - } - end - context 'with pup enabled' do - let(:params) do - { - use_pup: true, - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^use_pup: yes\n}, - ) - } - end - context 'with a custom pup_port' do - let(:params) do - { - pup_port: '17126', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^pup_port: 17126\n}, - ) - } - end - context 'with a custom pup_port, specified as an integer' do - let(:params) do - { - pup_port: 17_126, - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^pup_port: 17126\n}, - ) - } - end - context 'with a custom pup_interface' do - let(:params) do - { - pup_interface: 'notalocalhost', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^pup_interface: notalocalhost\n}, - ) - } - end - context 'with a custom pup_url' do - let(:params) do - { - pup_url: 'http://localhost:17126', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{pup_url: http://localhost:17126\n}, - ) - } - end - context 'with use_dogstatsd set to no' do - let(:params) do - { - use_dogstatsd: false, - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^use_dogstatsd: no\n}, - ) - } - end - context 'with use_dogstatsd set to yes' do - let(:params) do - { - use_dogstatsd: true, - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^use_dogstatsd: yes\n}, - ) - } - end - context 'with dogstatsd_port set to 8126 - must be specified as an integer!' do - let(:params) do - { - dogstatsd_port: 8126, - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^dogstatsd_port: 8126\n}, - ) - } - end - context 'with dogstatsd_port set to 8126' do - let(:params) do - { - dogstatsd_port: 8126, - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^dogstatsd_port: 8126\n}, - ) - } - end - context 'with dogstatsd_target set to localhost:17124' do - let(:params) do - { - dogstatsd_target: 'http://localhost:17124', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{dogstatsd_target: http://localhost:17124\n}, - ) - } - end - context 'with dogstatsd_interval set to 5' do - let(:params) do - { - dogstatsd_interval: '5', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^dogstatsd_interval: 5\n}, - ) - } - end - context 'with dogstatsd_interval set to 5' do - let(:params) do - { - dogstatsd_interval: '5', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^dogstatsd_interval: 5\n}, - ) - } - end - context 'with dogstatsd_normalize set to false' do - let(:params) do - { - dogstatsd_normalize: false, - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^dogstatsd_normalize: no\n}, - ) - } - end - context 'with statsd_forward_host set to localhost:3958' do - let(:params) do - { - statsd_forward_host: 'localhost:3958', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^statsd_forward_host: localhost:3958\n}, - ) - } - end - context 'with statsd_forward_port set to 8126' do - let(:params) do - { - statsd_forward_port: '8126', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^statsd_forward_port: 8126\n}, - ) - } - end - context 'with statsd_forward_port set to 8126, specified as an integer' do - let(:params) do - { - statsd_forward_port: 8126, - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^statsd_forward_port: 8126\n}, - ) - } - end - context 'with device_blacklist_re set to test' do - let(:params) do - { - device_blacklist_re: 'test', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^device_blacklist_re: test\n}, - ) - } - end - context 'with device_blacklist_re set to test' do - let(:params) do - { - device_blacklist_re: 'test', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^device_blacklist_re: test\n}, - ) - } - end - context 'with custom_emitters set to /test/emitter' do - let(:params) do - { - custom_emitters: '/test/emitter/', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{custom_emitters: /test/emitter/\n}, - ) - } - end - context 'with custom_emitters set to /test/emitter' do - let(:params) do - { - custom_emitters: '/test/emitter/', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{custom_emitters: /test/emitter/\n}, - ) - } - end - context 'with collector_log_file set to /test/log' do - let(:params) do - { - collector_log_file: '/test/log', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{collector_log_file: /test/log\n}, - ) - } - end - context 'with forwarder_log_file set to /test/log' do - let(:params) do - { - forwarder_log_file: '/test/log', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{forwarder_log_file: /test/log\n}, - ) - } - end - context 'with forwarder_log_file set to /test/log' do - let(:params) do - { - forwarder_log_file: '/test/log', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{forwarder_log_file: /test/log\n}, - ) - } - end - context 'with dogstatsd_log_file set to /test/log' do - let(:params) do - { - dogstatsd_log_file: '/test/log', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{dogstatsd_log_file: /test/log\n}, - ) - } - end - context 'with pup_log_file set to /test/log' do - let(:params) do - { - pup_log_file: '/test/log', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^pup_log_file: /test/log\n}, - ) - } - end - context 'with syslog location set to localhost' do - let(:params) do - { - syslog_host: 'localhost', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^syslog_host: localhost\n}, - ) - } - end - context 'with syslog port set to 8080' do - let(:params) do - { - syslog_port: '8080', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^syslog_port: 8080\n}, - ) - } - end - context 'with syslog port set to 8080, specified as an integer' do - let(:params) do - { - syslog_port: 8080, - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^syslog_port: 8080\n}, - ) - } - end - context 'with apm_enabled set to true' do - let(:params) do - { - apm_enabled: true, - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^apm_enabled: true\n}, - ) - } - end - context 'with apm_enabled set to true and env specified' do - let(:params) do - { - apm_enabled: true, - apm_env: 'foo', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^apm_enabled: true\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog apm footer').with( - 'content' => %r{^\[trace.agent\]\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog apm footer').with( - 'content' => %r{^env: foo\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog apm footer').with( - 'order' => '07', - ) - } - end - context 'with apm_enabled and apm_analyzed_spans set' do - let(:params) do - { - apm_enabled: true, - agent_major_version: 5, - apm_analyzed_spans: { - 'foo|bar' => 0.5, - 'haz|qux' => 0.1, - }, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^apm_enabled: true\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog apm footer').with( - 'content' => %r{^\[trace.analyzed_spans\]\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog apm footer').with( - 'content' => %r{^\[trace.analyzed_spans\]\nfoo|bar: 0.5\nhaz|qux: 0.1}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog apm footer').with( - 'order' => '07', - ) - } - end - context 'with service_discovery enabled' do - let(:params) do - { - service_discovery_backend: 'docker', - sd_config_backend: 'etcd', - sd_backend_host: 'localhost', - sd_backend_port: 8080, - sd_jmx_enable: true, - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^service_discovery_backend: docker\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^sd_config_backend: etcd\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^sd_backend_host: localhost\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^sd_backend_port: 8080\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^sd_jmx_enable: true\n}, - ) - } - end - context 'with extra_template enabled' do - let(:params) do - { - extra_template: 'custom_datadog/extra_template_test.erb', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog extra_template footer').with( - 'order' => '06', - ) - } - it { - is_expected.to contain_concat__fragment('datadog extra_template footer').with( - 'content' => %r{^# extra template is here\n}, - ) - } - it { - is_expected.not_to contain_concat__fragment('datadog apm footer').with( - 'order' => '07', - ) - } - end - context 'with APM enabled' do - let(:params) do - { - apm_enabled: true, - apm_env: 'foo', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog apm footer').with( - 'order' => '07', - ) - } - end - context 'with APM enabled but no APM env' do - let(:params) do - { - apm_enabled: true, - agent_major_version: 5, - } - end - - it { - is_expected.not_to contain_concat__fragment('datadog apm footer').with( - 'order' => '07', - ) - } - end - context 'with extra_template and APM enabled' do - let(:params) do - { - extra_template: 'custom_datadog/extra_template_test.erb', - apm_enabled: true, - apm_env: 'foo', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog extra_template footer').with( - 'order' => '06', - ) - } - it { - is_expected.to contain_concat__fragment('datadog extra_template footer').with( - 'content' => %r{^# extra template is here\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog apm footer').with( - 'order' => '07', - ) - } - end - context 'with process_agent enabled' do - let(:params) do - { - process_enabled: true, - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^process_agent_enabled: true\n}, - ) - } - end - - context 'with data scrubbing disabled' do - let(:params) do - { - process_enabled: true, - agent_major_version: 5, - scrub_args: false, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^process_agent_enabled: true\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog process agent footer').with( - 'content' => %r{^\[process.config\]\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog process agent footer').with( - 'content' => %r{^scrub_args: false\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog process agent footer').with( - 'content' => %r{^custom_sensitive_words: \n}, - ) - } - end - - context 'with data scrubbing enabled with custom sensitive_words' do - let(:params) do - { - process_enabled: true, - agent_major_version: 5, - custom_sensitive_words: ['consul_token', 'dd_key'], - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^process_agent_enabled: true\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog process agent footer').with( - 'content' => %r{^\[process.config\]\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog process agent footer').with( - 'content' => %r{^scrub_args: true\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog process agent footer').with( - 'content' => %r{^custom_sensitive_words: consul_token,dd_key\n}, - ) - } - end - end - end - - if REDHAT_OS.include?(operatingsystem) - it { is_expected.to contain_class('datadog_agent::redhat') } - end - end - end - describe "datadog_agent 6/7 class with reports on #{operatingsystem}" do let(:params) do { @@ -1662,6 +353,9 @@ 'major' => getosmajor(operatingsystem), 'full' => getosrelease(operatingsystem), }, + 'distro' => { + 'codename' => getoscodename(operatingsystem), + } }, } end @@ -1695,6 +389,9 @@ 'major' => getosmajor(operatingsystem), 'full' => getosrelease(operatingsystem), }, + 'distro' => { + 'codename' => getoscodename(operatingsystem) + }, }, } end @@ -1717,11 +414,6 @@ it { is_expected.to contain_file(install_info_file) } it { is_expected.to contain_file(config_dir + '/conf.d').with_ensure('directory') } - # Agent 5 files - it { is_expected.not_to contain_file('/etc/dd-agent') } - it { is_expected.not_to contain_concat('/etc/dd-agent/datadog.conf') } - it { is_expected.not_to contain_file('/etc/dd-agent/conf.d').with_ensure('directory') } - describe 'install_info check' do let!(:install_info) do contents = catalogue.resource('file', install_info_file).send(:parameters)[:content] @@ -1905,68 +597,6 @@ ) } end - context 'deprecated proxy settings' do - let(:params) do - { - proxy_host: 'foo', - proxy_port: 1234, - proxy_user: 'bar', - proxy_password: 'abcd1234', - } - end - - it { - is_expected.to contain_notify( - 'Setting proxy_host is only used with Agent 5. Please use agent_extra_options to set your proxy', - ) - } - it { - is_expected.to contain_notify( - 'Setting proxy_port is only used with Agent 5. Please use agent_extra_options to set your proxy', - ) - } - it { - is_expected.to contain_notify( - 'Setting proxy_user is only used with Agent 5. Please use agent_extra_options to set your proxy', - ) - } - it { - is_expected.to contain_notify( - 'Setting proxy_password is only used with Agent 5. Please use agent_extra_options to set your proxy', - ) - } - end - context 'deprecated proxy settings with default values' do - let(:params) do - { - proxy_host: '', - proxy_port: '', - proxy_user: '', - proxy_password: '', - } - end - - it { - is_expected.not_to contain_notify( - 'Setting proxy_host is only used with Agent 5. Please use agent_extra_options to set your proxy', - ) - } - it { - is_expected.not_to contain_notify( - 'Setting proxy_port is only used with Agent 5. Please use agent_extra_options to set your proxy', - ) - } - it { - is_expected.not_to contain_notify( - 'Setting proxy_user is only used with Agent 5. Please use agent_extra_options to set your proxy', - ) - } - it { - is_expected.not_to contain_notify( - 'Setting proxy_password is only used with Agent 5. Please use agent_extra_options to set your proxy', - ) - } - end end context 'with additional agents config' do @@ -2311,6 +941,9 @@ 'major' => '6', 'full' => '6.3', }, + 'distro' => { + 'codename' => 'santiago', + } }, } end @@ -2361,6 +994,9 @@ 'major' => '6', 'full' => '6.3', }, + 'distro' => { + 'codename' => 'santiago', + } }, } end @@ -2370,36 +1006,5 @@ .with_content(%r{tags:\n- os.family:redhat\n- facts_array:one\n- facts_array:two\n- facts_hash.actor.first_name:Macaulay\n- looks.like.a.path:but_its_not}) end end - - describe 'a5 ensure facts_array outputs a list of tags' do - let(:params) do - { - agent_major_version: 5, - puppet_run_reports: true, - facts_to_tags: ['osfamily', 'facts_array'], - } - end - let(:facts) do - { - facts_array: ['one', 'two'], - osfamily: 'redhat', - os: { - 'architecture' => 'x86_64', - 'family' => 'redhat', - 'name' => 'CentOS', - 'release' => { - 'major' => '6', - 'full' => '6.3', - }, - }, - } - end - - it { is_expected.to contain_concat('/etc/dd-agent/datadog.conf') } - it { is_expected.to contain_concat__fragment('datadog tags').with_content('tags: ') } - it { is_expected.to contain_concat__fragment('datadog tag osfamily:redhat').with_content('osfamily:redhat, ') } - it { is_expected.to contain_concat__fragment('datadog tag facts_array:one').with_content('facts_array:one, ') } - it { is_expected.to contain_concat__fragment('datadog tag facts_array:two').with_content('facts_array:two, ') } - end end end diff --git a/spec/classes/datadog_agent_ubuntu_spec.rb b/spec/classes/datadog_agent_ubuntu_spec.rb index ee6ef100..da5c31e9 100644 --- a/spec/classes/datadog_agent_ubuntu_spec.rb +++ b/spec/classes/datadog_agent_ubuntu_spec.rb @@ -23,60 +23,6 @@ end describe 'datadog_agent::ubuntu' do - context 'agent 5' do - if RSpec::Support::OS.windows? - return - end - let(:params) do - { - agent_major_version: 5, - } - end - let(:facts) do - { - os: { - 'architecture' => 'x86_64', - 'family' => 'debian', - 'name' => 'Ubuntu', - 'release' => { - 'major' => '14', - 'full' => '14.04', - }, - }, - } - end - - it do - is_expected.to contain_file('/etc/apt/sources.list.d/datadog5.list') - .with_ensure('absent') - is_expected.to contain_file('/etc/apt/sources.list.d/datadog6.list') - .with_ensure('absent') - is_expected.to contain_file('/etc/apt/sources.list.d/datadog.list')\ - .with_content(%r{deb\s+\[signed-by=/usr/share/keyrings/datadog-archive-keyring.gpg\]\s+https://apt.datadoghq.com/\s+stable\s+main}) - end - - # it should install the mirror - it { is_expected.not_to contain_apt__key('935F5A436A5A6E8788F0765B226AE980C7A7DA52') } - - it do - is_expected.to contain_file('/etc/apt/sources.list.d/datadog.list')\ - .that_notifies('exec[apt_update]') - end - it { is_expected.to contain_exec('apt_update') } - - # it should install the packages - it do - is_expected.to contain_package('datadog-agent-base')\ - .with_ensure('absent')\ - .that_comes_before('package[datadog-agent]') - end - it do - is_expected.to contain_package('datadog-agent')\ - .that_requires('file[/etc/apt/sources.list.d/datadog.list]')\ - .that_requires('exec[apt_update]') - end - end - context 'agent 6' do let(:params) do { diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 0989f844..10336330 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -27,7 +27,7 @@ PERMISSIONS_PROTECTED_FILE = '0660' else ALL_OS = DEBIAN_OS + REDHAT_OS - ALL_SUPPORTED_AGENTS = [5, 6, 7].freeze + ALL_SUPPORTED_AGENTS = [6, 7].freeze CONF_DIR = '/etc/datadog-agent/conf.d' DD_USER = 'dd-agent' DD_GROUP = 'dd-agent' diff --git a/templates/agent-conf.d/cassandra.yaml.erb b/templates/agent-conf.d/cassandra.yaml.erb index afc51389..86afee02 100644 --- a/templates/agent-conf.d/cassandra.yaml.erb +++ b/templates/agent-conf.d/cassandra.yaml.erb @@ -33,8 +33,7 @@ init_config: ## @param conf - list of objects - required ## List of metrics to be collected by the integration ## Read http://docs.datadoghq.com/integrations/java/ to learn how to customize it - ## Agent 5: Customize all your metrics below - ## Agent 6: The default metrics to be collected are kept in metrics.yaml, but you can still add your own metrics here + ## Agent 6/7: The default metrics to be collected are kept in metrics.yaml, but you can still add your own metrics here # conf: - include: diff --git a/templates/agent-conf.d/kafka.yaml.erb b/templates/agent-conf.d/kafka.yaml.erb index c76955f2..88ffabbc 100644 --- a/templates/agent-conf.d/kafka.yaml.erb +++ b/templates/agent-conf.d/kafka.yaml.erb @@ -1,11 +1,5 @@ ### MANAGED BY PUPPET -########## -# WARNING -########## -# This sample works only for Kafka >= 0.8.2. -# If you are running a version older than that, you can refer to agent 5.2.x released -# sample files, https://raw.githubusercontent.com/DataDog/dd-agent/5.2.1/conf.d/kafka.yaml.example instances: <% @servers.each do |server| -%> - host: <%= server['host'] %>