Refactor to remove agent version-specific variables
MODIFY
attributes/default.rb
attributes/default.rb
@@ -28,27 +28,13 @@ default['datadog']['api_key'] = nil
# Set it as an attribute, or on your node `run_state` under the key `['datadog']['application_key']`
default['datadog']['application_key'] = nil
-# Set node['datadog']['agent6'] to false to install an agent5 instead of agent6.
-# To upgrade from agent5 to agent6, you need to:
-# * set node['datadog']['agent6'] to true, and
-# * either set node['datadog']['agent6_version'] to an existing agent6 version (recommended), or
-# set node['datadog']['agent6_package_action'] to 'upgrade'
-# To downgrade from agent6 to agent5, you need to:
-# * set node['datadog']['agent6'] to false, and
-# * pin node['datadog']['agent_version'] to an existing agent5 version, and
-# * set node['datadog']['agent_allow_downgrade'] to true
# If you're installing a pre-release version of Agent 6 (beta or RC), you need to:
# * on debian: set node['datadog']['agent6_aptrepo_dist'] to 'beta' instead of 'stable'
# * on RHEL: set node['datadog']['agent6_yumrepo'] to 'https://yum.datadoghq.com/beta/x86_64/'
-default['datadog']['agent6'] = true
+default['datadog']['agent_major_version'] = 6
########################################################################
-### Agent6-only attributes ###
-
-# Default of `nil` will install latest version, applies to agent6 only.
-# See documentation of `agent_version` attribute for allowed configuration format.
-default['datadog']['agent6_version'] = nil
-default['datadog']['agent6_package_action'] = 'install' # set to `upgrade` to always upgrade to latest
+### Agent 6/7 only attributes ###
# repos where datadog-agent v6 packages are available
default['datadog']['agent6_aptrepo'] = 'http://apt.datadoghq.com'
@@ -57,15 +43,6 @@ default['datadog']['agent6_aptrepo_dist'] = 'stable'
default['datadog']['agent6_yumrepo'] = 'https://yum.datadoghq.com/stable/6/x86_64/'
default['datadog']['agent6_yumrepo_suse'] = 'https://yum.datadoghq.com/suse/stable/6/x86_64/'
-# Values that differ on Windows
-# The location of the config folder (containing conf.d)
-default['datadog']['agent6_config_dir'] =
- if node['platform_family'] == 'windows'
- "#{ENV['ProgramData']}/Datadog"
- else
- '/etc/datadog-agent'
- end
-
# The site of the Datadog intake to send Agent data to.
# This configuration option is supported since Agent 6.6
# Defaults to 'datadoghq.com', set to 'datadoghq.eu' to send data to the EU site.
@@ -81,7 +58,7 @@ default['datadog']['cmd_port'] = nil
# GUI_port: -1
default['datadog']['gui_port'] = nil
-### End of Agent6-only attributes ###
+### End of Agent 6/7 only attributes ###
########################################################################
# Use this attribute to send data to additional accounts
@@ -159,14 +136,14 @@ yum_protocol =
# NB: if you're not using the default repos and/or distributions, make sure
# to pin the version you're installing with node['datadog']['agent_version']
default['datadog']['installrepo'] = true
-default['datadog']['aptrepo'] = 'http://apt.datadoghq.com'
-default['datadog']['aptrepo_dist'] = 'stable'
+default['datadog']['agent5_aptrepo'] = 'http://apt.datadoghq.com'
+default['datadog']['agent5_aptrepo_dist'] = 'stable'
default['datadog']['aptrepo_retries'] = 4
default['datadog']['aptrepo_use_backup_keyserver'] = false
default['datadog']['aptrepo_keyserver'] = 'hkp://keyserver.ubuntu.com:80'
default['datadog']['aptrepo_backup_keyserver'] = 'hkp://pool.sks-keyservers.net:80'
-default['datadog']['yumrepo'] = "#{yum_protocol}://yum.datadoghq.com/rpm/#{architecture_map[node['kernel']['machine']]}/"
-default['datadog']['yumrepo_suse'] = "https://yum.datadoghq.com/suse/rpm/#{architecture_map[node['kernel']['machine']]}/"
+default['datadog']['agent5_yumrepo'] = "#{yum_protocol}://yum.datadoghq.com/rpm/#{architecture_map[node['kernel']['machine']]}/"
+default['datadog']['agent5_yumrepo_suse'] = "https://yum.datadoghq.com/suse/rpm/#{architecture_map[node['kernel']['machine']]}/"
default['datadog']['yumrepo_gpgkey'] = "#{yum_protocol}://yum.datadoghq.com/DATADOG_RPM_KEY.public"
default['datadog']['yumrepo_proxy'] = nil
default['datadog']['yumrepo_proxy_username'] = nil
@@ -197,11 +174,16 @@ default['datadog']['windows_agent_use_exe'] = false
# The location of the config folder (containing conf.d)
# The name of the dd agent service
# The log file directory (see logging section below)
+
+# Values that differ on Windows
+# The location of the config folder (containing conf.d)
if node['platform_family'] == 'windows'
- default['datadog']['config_dir'] = "#{ENV['ProgramData']}/Datadog"
+ default['datadog']['agent5_config_dir'] = "#{ENV['ProgramData']}/Datadog"
+ default['datadog']['agent6_config_dir'] = "#{ENV['ProgramData']}/Datadog"
default['datadog']['agent_name'] = 'DatadogAgent'
else
- default['datadog']['config_dir'] = '/etc/dd-agent'
+ default['datadog']['agent5_config_dir'] = '/etc/dd-agent'
+ default['datadog']['agent6_config_dir'] = '/etc/datadog-agent'
default['datadog']['agent_name'] = 'datadog-agent'
end
@@ -213,8 +195,7 @@ end
default['datadog']['windows_ddagentuser_name'] = nil
default['datadog']['windows_ddagentuser_password'] = nil
-# Agent Version for v5 Agents
-# To pin the version of v6 Agents, use the `agent6_version` attribute instead.
+# Agent Version
# Default of `nil` will install latest version. On Windows, this will also upgrade to latest
# This attribute accepts either a `string` or `hash` with the key as platform_name and value of package version
# In the case of fedora and amazon linux, use platform_name of rhel
@@ -226,8 +207,6 @@ default['datadog']['windows_ddagentuser_password'] = nil
# }
default['datadog']['agent_version'] = nil
-# Agent package action for v5 Agents
-# For v6 Agents, use the agent6_package_action attribute instead
# Allow override with `upgrade` to get latest (Linux only)
default['datadog']['agent_package_action'] = 'install'

MODIFY
kitchen.docker.yml
kitchen.docker.yml
@@ -30,6 +30,6 @@ suites:
attributes:
datadog:
# TODO(remy): run those tests with Agent v6 recipe.
- agent6: false
+ agent_major_version: 5
api_key: somenonnullapikeythats32charlong
application_key: alsonotnil

MODIFY
kitchen.yml
kitchen.yml
@@ -79,7 +79,7 @@ suites:
datadog: &DATADOG
agent6_aptrepo: 'http://apt.datad0g.com'
agent6_aptrepo_dist: 'beta'
- # agent6_version: '1:6.11.3~rc.2-1'
+ # agent_version: '1:6.11.3~rc.2-1'
agent6_package_action: 'install'
agent_allow_downgrade: true
api_key: somenonnullapikeythats32charlong

MODIFY
recipes/_agent6_config.rb
recipes/_agent6_config.rb
is_windows = node['platform_family'] == 'windows'
-agent6_config_file = ::File.join(node['datadog']['agent6_config_dir'], 'datadog.yaml')
-template agent6_config_file do
+agent_config_file = ::File.join(node['datadog']['agent6_config_dir'], 'datadog.yaml')
+template agent_config_file do
def template_vars
# we need to always provide an URL value for additional endpoints.
# use either the site option or the url one, the latter having priority.

MODIFY
recipes/_install-linux.rb
recipes/_install-linux.rb
# Install the Apt/Yum repository if enabled
include_recipe 'datadog::repository' if node['datadog']['installrepo']
-dd_agent5_version =
- if node['datadog']['agent_version'].respond_to?(:each_pair)
- case node['platform_family']
- when 'rhel', 'fedora', 'amazon'
- node['datadog']['agent_version']['rhel']
- else
- node['datadog']['agent_version'][node['platform_family']]
- end
- else
- node['datadog']['agent_version']
- end
-
-dd_agent6_version =
- if node['datadog']['agent6_version'].respond_to?(:each_pair)
- case node['platform_family']
- when 'rhel', 'fedora'
- node['datadog']['agent6_version']['rhel']
- else
- node['datadog']['agent6_version'][node['platform_family']]
+dd_agent_version = node['datadog']['agent_version']
+if dd_agent_version.respond_to?(:each_pair)
+ platform_family = node['platform_family']
+ # Unless explicitly listed, treat fedora and amazon as rhel
+ if not dd_agent_version.include? platform_family and ['fedora', 'amazon'].include? platform_family
+ platform_family = 'rhel'
end
- else
- node['datadog']['agent6_version']
+ dd_agent_version = dd_agent_version[platform_family]
end
-if node['datadog']['agent6']
- dd_agent_version = dd_agent6_version
- package_action = node['datadog']['agent6_package_action']
-else
- dd_agent_version = dd_agent5_version
package_action = node['datadog']['agent_package_action']
-end
package_retries = node['datadog']['agent_package_retries']
package_retry_delay = node['datadog']['agent_package_retry_delay']

MODIFY
recipes/_install-windows.rb
recipes/_install-windows.rb
# limitations under the License.
#
-dd_agent5_version =
- if node['datadog']['agent_version'].respond_to?(:each_pair)
- node['datadog']['agent_version']['windows']
- else
- node['datadog']['agent_version']
+dd_agent_version = node['datadog']['agent_version']
+if dd_agent_version.respond_to?(:each_pair)
+ dd_agent_version = dd_agent_version['windows']
end
-dd_agent6_version =
- if node['datadog']['agent6_version'].respond_to?(:each_pair)
- node['datadog']['agent6_version']['windows']
+if dd_agent_version.nil?
+ # Use latest
+ agent_major_version = node['datadog']['agent_major_version']
+ if agent_major_version.to_i == 5
+ dd_agent_installer_basename = 'ddagent-cli-latest'
else
- node['datadog']['agent6_version']
+ dd_agent_installer_basename = "datadog-agent-#{agent_major_version}-latest.amd64"
end
-
-if node['datadog']['agent6']
- dd_agent_version = dd_agent6_version
- dd_agent_latest = 'datadog-agent-6-latest.amd64'
else
- dd_agent_version = dd_agent5_version
- # The latest package basename is `ddagent-cli-latest` for '~> 5.12' versions
- dd_agent_latest = 'ddagent-cli-latest'
+ dd_agent_installer_prefix = (node['datadog']['windows_agent_installer_prefix'] or 'ddagent-cli')
+ dd_agent_installer_basename = "#{dd_agent_installer_prefix}-#{dd_agent_version}"
end
-# If a different file prefix is specified, use that:
-dd_agent_installer_prefix = node['datadog']['windows_agent_installer_prefix'] ? node['datadog']['windows_agent_installer_prefix'] : 'ddagent-cli'
-
-# If no version is specified, select the latest package.
-dd_agent_installer_basename = dd_agent_version ? "#{dd_agent_installer_prefix}-#{dd_agent_version}" : dd_agent_latest
temp_file_basename = ::File.join(Chef::Config[:file_cache_path], 'ddagent-cli')
if node['datadog']['windows_agent_use_exe']

MODIFY
recipes/dd-agent.rb
recipes/dd-agent.rb
@@ -44,13 +44,11 @@ agent_start = node['datadog']['agent_start'] ? :start : :stop
# To add integration-specific configurations, add 'datadog::config_name' to
# the node's run_list and set the relevant attributes
#
-if node['datadog']['agent6']
+if node['datadog']['agent_major_version'].to_i > 5
include_recipe 'datadog::_agent6_config'
else
- # Agent 5 and lower
-
# Make sure the config directory exists for Agent 5
- directory node['datadog']['config_dir'] do
+ directory node['datadog']['agent5_config_dir'] do
if is_windows
owner 'Administrators'
rights :full_control, 'Administrators'
@@ -62,7 +60,7 @@ else
end
end
- agent_config_file = ::File.join(node['datadog']['config_dir'], 'datadog.conf')
+ agent_config_file = ::File.join(node['datadog']['agent5_config_dir'], 'datadog.conf')
template agent_config_file do
def template_vars
# Default value of node['datadog']['url'] is now nil for an Agent 6
@@ -109,7 +107,7 @@ end
# Common configuration
service_provider = nil
-if node['datadog']['agent6'] &&
+if node['datadog']['agent_major_version'].to_i > 5 &&
(((node['platform'] == 'amazon' || node['platform_family'] == 'amazon') && node['platform_version'].to_i != 2) ||
(node['platform'] == 'ubuntu' && node['platform_version'].to_f < 15.04) || # chef <11.14 doesn't use the correct service provider
(node['platform'] != 'amazon' && node['platform_family'] == 'rhel' && node['platform_version'].to_i < 7))
@@ -135,10 +133,10 @@ service 'datadog-agent' do
retry_delay 5
end
-# only load system-probe recipe if an agent6 installation comes with it
+# only load system-probe recipe if an agent 6/7 installation comes with it
ruby_block 'include system-probe' do
block do
- if ::File.exist?('/opt/datadog-agent/embedded/bin/system-probe') && node['datadog']['agent6'] && !is_windows
+ if ::File.exist?('/opt/datadog-agent/embedded/bin/system-probe') && node['datadog']['agent_major_version'].to_i > 5 && !is_windows
run_context.include_recipe 'datadog::system-probe'
end
end

MODIFY
recipes/repository.rb
recipes/repository.rb
@@ -26,9 +26,19 @@ when 'debian'
action :install
end
- uri = node['datadog']['agent6'] ? node['datadog']['agent6_aptrepo'] : node['datadog']['aptrepo']
- distribution = node['datadog']['agent6'] ? node['datadog']['agent6_aptrepo_dist'] : node['datadog']['aptrepo_dist']
- components = node['datadog']['agent6'] ? ['main', '6'] : ['main']
+ case node['datadog']['agent_major_version'].to_i
+ when 6
+ uri = node['datadog']['agent6_aptrepo']
+ distribution = node['datadog']['agent6_aptrepo_dist']
+ components = ['main', '6']
+ when 5
+ uri = node['datadog']['agent5_aptrepo']
+ distribution = node['datadog']['agent5_aptrepo_dist']
+ components = ['main']
+ else
+ Chef::Log.error('agent_major_version not supported.')
+ end
+
retries = node['datadog']['aptrepo_retries']
keyserver = node['datadog']['aptrepo_use_backup_keyserver'] ? node['datadog']['aptrepo_backup_keyserver'] : node['datadog']['aptrepo_keyserver']
# Add APT repository
@@ -71,14 +81,19 @@ when 'rhel', 'fedora', 'amazon'
end
end
+ case node['datadog']['agent_major_version'].to_i
+ when 6
+ baseurl = node['datadog']['agent6_yumrepo']
+ when 5
+ baseurl = node['datadog']['agent5_yumrepo']
+ else
+ Chef::Log.error('agent_major_version not supported.')
+ end
+
# Add YUM repository
yum_repository 'datadog' do
description 'datadog'
- if node['datadog']['agent6']
- baseurl node['datadog']['agent6_yumrepo']
- else
- baseurl node['datadog']['yumrepo']
- end
+ baseurl baseurl
proxy node['datadog']['yumrepo_proxy']
proxy_username node['datadog']['yumrepo_proxy_username']
proxy_password node['datadog']['yumrepo_proxy_password']
@@ -121,14 +136,19 @@ when 'suse'
action :nothing
end
+ case node['datadog']['agent_major_version'].to_i
+ when 6
+ baseurl = node['datadog']['agent6_yumrepo_suse']
+ when 5
+ baseurl = node['datadog']['agent5_yumrepo_suse']
+ else
+ Chef::Log.error('agent_major_version not supported.')
+ end
+
# Add YUM repository
zypper_repository 'datadog' do
description 'datadog'
- if node['datadog']['agent6']
- baseurl node['datadog']['agent6_yumrepo_suse']
- else
- baseurl node['datadog']['yumrepo_suse']
- end
+ baseurl baseurl
gpgkey node['datadog']['yumrepo_gpgkey']
gpgautoimportkeys false
gpgcheck false

MODIFY
recipes/system-probe.rb
recipes/system-probe.rb
@@ -51,7 +51,7 @@ end
# Common configuration
service_provider = nil
-if node['datadog']['agent6'] &&
+if node['datadog']['agent_major_version'].to_i > 5 &&
(((node['platform'] == 'amazon' || node['platform_family'] == 'amazon') && node['platform_version'].to_i != 2) ||
(node['platform'] == 'ubuntu' && node['platform_version'].to_f < 15.04) || # chef <11.14 doesn't use the correct service provider
(node['platform'] != 'amazon' && node['platform_family'] == 'rhel' && node['platform_version'].to_i < 7))

MODIFY
resources/integration.rb
resources/integration.rb
@@ -12,8 +12,8 @@ property :property_name, String, name_property: true
property :version, String, required: true
action :install do
- unless node['datadog']['agent6']
- Chef::Log.error('The datadog_integration resource is only available with Agent v6.')
+ if node['datadog']['agent_major_version'].to_i == 5
+ Chef::Log.error('The datadog_integration resource is not available with Agent v5.')
return
end
@@ -31,8 +31,8 @@ action :install do
end
action :remove do
- unless node['datadog']['agent6']
- Chef::Log.error('The datadog_integration resource is only available with Agent v6.')
+ if node['datadog']['agent_major_version'].to_i == 5
+ Chef::Log.error('The datadog_integration resource is not available with Agent v5.')
return
end

MODIFY
resources/monitor.rb
resources/monitor.rb
@@ -19,7 +19,7 @@ action :add do
template ::File.join(yaml_dir, "#{new_resource.name}.yaml") do
# On Windows Agent v5, set the permissions on conf files to Administrators.
if node['platform_family'] == 'windows'
- unless node['datadog']['agent6']
+ if node['datadog']['agent_major_version'].to_i == 5
owner 'Administrators'
rights :full_control, 'Administrators'
inherits false
@@ -52,9 +52,9 @@ action :remove do
end
def yaml_dir
- if node['datadog']['agent6']
+ if node['datadog']['agent_major_version'].to_i > 5
::File.join(node['datadog']['agent6_config_dir'], 'conf.d')
else
- ::File.join(node['datadog']['config_dir'], 'conf.d')
+ ::File.join(node['datadog']['agent5_config_dir'], 'conf.d')
end
end

MODIFY
spec/dd-agent_spec.rb
spec/dd-agent_spec.rb
@@ -168,7 +168,7 @@ describe 'datadog::dd-agent' do
:version => '14.04'
) do |node|
node.normal['datadog'] = {
- 'agent6' => false,
+ 'agent_major_version' => 5,
'api_key' => 'somethingnotnil',
'agent_version' => '1:5.1.0-440'
}
@@ -191,7 +191,7 @@ describe 'datadog::dd-agent' do
:version => '14.04'
) do |node|
node.normal['datadog'] = {
- 'agent6' => false,
+ 'agent_major_version' => 5,
'api_key' => 'somethingnotnil',
'agent_version' => '1:5.9.0-1'
}
@@ -212,7 +212,7 @@ describe 'datadog::dd-agent' do
:file_cache_path => 'C:/chef/cache'
) do |node|
node.normal['datadog'] = {
- 'agent6' => false,
+ 'agent_major_version' => 5,
'api_key' => 'somethingnotnil',
'agent_version' => '5.10.1'
}
@@ -243,14 +243,11 @@ describe 'datadog::dd-agent' do
:version => '14.04'
) do |node|
node.normal['datadog'] = {
- 'agent6' => true,
+ 'agent_major_version' => 6,
'api_key' => 'somethingnotnil',
- 'agent6_version' => {
+ 'agent_version' => {
'debian' => '1:6.9.0-1',
'rhel' => '6.9.0-1',
- },
- 'agent_version' => {
- 'windows' => '5.4.0'
}
}
end.converge described_recipe
@@ -268,15 +265,12 @@ describe 'datadog::dd-agent' do
:file_cache_path => 'C:/chef/cache'
) do |node|
node.normal['datadog'] = {
- 'agent6' => true,
+ 'agent_major_version' => 6,
'api_key' => 'somethingnotnil',
- 'agent6_version' => {
+ 'agent_version' => {
'debian' => '1:6.9.0-1',
'rhel' => '6.9.0-1',
'windows' => '6.9.0',
- },
- 'agent_version' => {
- 'windows' => '5.4.0'
}
}
end.converge described_recipe
@@ -304,17 +298,14 @@ describe 'datadog::dd-agent' do
:file_cache_path => 'C:/chef/cache'
) do |node|
node.normal['datadog'] = {
- 'agent6' => true,
+ 'agent_major_version' => 6,
'api_key' => 'somethingnotnil',
'windows_agent_url' => 'http://dd-agent-mstesting.s3.amazonaws.com/builds/tagged/',
'windows_agent_installer_prefix' => 'datadog-agent',
- 'agent6_version' => {
+ 'agent_version' => {
'debian' => '1:6.9.0-1',
'rhel' => '6.9.0-1',
'windows' => '6.9.0-1-x86_64'
- },
- 'agent_version' => {
- 'windows' => '5.4.0'
}
}
end.converge described_recipe
@@ -340,14 +331,11 @@ describe 'datadog::dd-agent' do
:version => '26'
) do |node|
node.normal['datadog'] = {
- 'agent6' => true,
+ 'agent_major_version' => 6,
'api_key' => 'somethingnotnil',
- 'agent6_version' => {
+ 'agent_version' => {
'debian' => '1:6.9.0-1',
'rhel' => '6.9.0-1',
- },
- 'agent_version' => {
- 'windows' => '5.4.0'
}
}
end.converge described_recipe
@@ -363,15 +351,12 @@ describe 'datadog::dd-agent' do
:version => '6.9'
) do |node|
node.normal['datadog'] = {
- 'agent6' => true,
+ 'agent_major_version' => 6,
'api_key' => 'somethingnotnil',
- 'agent6_version' => {
+ 'agent_version' => {
'debian' => '1:6.9.0-1',
'rhel' => '6.9.0-1',
},
- 'agent_version' => {
- 'windows' => '5.4.0'
- }
}
end.converge described_recipe
end
@@ -391,7 +376,7 @@ describe 'datadog::dd-agent' do
:version => '14.04'
) do |node|
node.normal['datadog'] = {
- 'agent6' => false,
+ 'agent_major_version' => 5,
'api_key' => 'somethingnotnil',
'agent_version' => {
'debian' => '1:5.32.2-1',
@@ -414,7 +399,7 @@ describe 'datadog::dd-agent' do
:file_cache_path => 'C:/chef/cache'
) do |node|
node.normal['datadog'] = {
- 'agent6' => false,
+ 'agent_major_version' => 5,
'api_key' => 'somethingnotnil',
'agent_version' => {
'debian' => '1:5.32.2-1',
@@ -445,9 +430,9 @@ describe 'datadog::dd-agent' do
:version => '26'
) do |node|
node.normal['datadog'] = {
- 'agent6' => false,
+ 'agent_major_version' => 5,
'api_key' => 'somethingnotnil',
- 'agent6_version' => {
+ 'agent_version' => {
'debian' => '1:5.32.2-1',
'rhel' => '5.32.2-1',
'windows' => '5.4.0'
@@ -466,7 +451,7 @@ describe 'datadog::dd-agent' do
:version => '6.9'
) do |node|
node.normal['datadog'] = {
- 'agent6' => false,
+ 'agent_major_version' => 5,
'api_key' => 'somethingnotnil',
'agent_version' => {
'debian' => '1:5.32.2-1',
@@ -489,7 +474,7 @@ describe 'datadog::dd-agent' do
version: '14.04'
) do |node|
node.normal['datadog'] = {
- 'agent6_version' => '1:6.8.0-1',
+ 'agent_version' => '1:6.8.0-1',
'api_key' => 'somethingnotnil'
}
node.normal['languages'] = { 'python' => { 'version' => '2.6.2' } }
@@ -508,7 +493,7 @@ describe 'datadog::dd-agent' do
) do |node|
node.normal['datadog'] = {
'api_key' => 'somethingnotnil',
- 'agent6_package_action' => :upgrade
+ 'agent_package_action' => :upgrade
}
node.normal['languages'] = { 'python' => { 'version' => '2.6.2' } }
end.converge described_recipe
@@ -533,7 +518,7 @@ describe 'datadog::dd-agent' do
version: '14.04'
) do |node|
node.normal['datadog'] = {
- 'agent6' => false,
+ 'agent_major_version' => 5,
'api_key' => 'somethingnotnil',
'tags' => 'datacenter:us-foo,database:bar'
}
@@ -556,7 +541,7 @@ describe 'datadog::dd-agent' do
version: '14.04'
) do |node|
node.normal['datadog'] = {
- 'agent6' => false,
+ 'agent_major_version' => 5,
'api_key' => 'somethingnotnil',
'tags' => { 'datacenter' => 'us-foo', 'database' => 'bar' }
}
@@ -579,7 +564,7 @@ describe 'datadog::dd-agent' do
version: '14.04'
) do |node|
node.normal['datadog'] = {
- 'agent6' => false,
+ 'agent_major_version' => 5,
'api_key' => 'somethingnotnil',
'tags' => { 'datacenter' => 'us-foo', 'database' => '' }
}
@@ -602,7 +587,7 @@ describe 'datadog::dd-agent' do
version: '14.04'
) do |node|
node.normal['datadog'] = {
- 'agent6' => false,
+ 'agent_major_version' => 5,
'api_key' => 'something1',
'url' => 'https://app.example.com',
'extra_endpoints' => {
@@ -633,7 +618,7 @@ describe 'datadog::dd-agent' do
version: '14.04'
) do |node|
node.normal['datadog'] = {
- 'agent6' => false,
+ 'agent_major_version' => 5,
'api_key' => 'something1',
'url' => 'https://app.example.com',
'extra_endpoints' => {
@@ -678,7 +663,7 @@ describe 'datadog::dd-agent' do
version: '14.04'
) do |node|
node.normal['datadog'] = {
- 'agent6' => false,
+ 'agent_major_version' => 5,
'api_key' => 'as_node_attribute',
'url' => 'https://app.example.com'
}
@@ -705,7 +690,7 @@ describe 'datadog::dd-agent' do
version: '14.04'
) do |node|
node.normal['languages'] = { 'python' => { 'version' => '2.6.2' } }
- node.normal['datadog'] = { 'agent6' => false }
+ node.normal['datadog'] = { 'agent_major_version' => 5 }
node.run_state['datadog'] = {
'api_key' => 'on_run_state'
}
@@ -728,7 +713,7 @@ describe 'datadog::dd-agent' do
version: '14.04'
) do |node|
node.normal['datadog'] = {
- 'agent6' => false,
+ 'agent_major_version' => 5,
'api_key' => 'something1',
'url' => 'https://app.example.com',
'extra_config' => {
@@ -889,7 +874,7 @@ describe 'datadog::dd-agent' do
end
end
- context 'agent6 set to true' do
+ context 'agent 6' do
describe 'the datadog-agent service' do
context 'on Amazon Linux < 2.0' do
cached(:chef_run) do
@@ -897,7 +882,7 @@ describe 'datadog::dd-agent' do
:platform => 'amazon',
:version => '2017.03'
) do |node|
- node.normal['datadog'] = { 'api_key' => 'somethingnotnil', 'agent6' => true }
+ node.normal['datadog'] = { 'api_key' => 'somethingnotnil', 'agent_major_version' => 6 }
end.converge described_recipe
end
@@ -914,7 +899,7 @@ describe 'datadog::dd-agent' do
:platform => 'redhat',
:version => '6.8'
) do |node|
- node.normal['datadog'] = { 'api_key' => 'somethingnotnil', 'agent6' => true }
+ node.normal['datadog'] = { 'api_key' => 'somethingnotnil', 'agent_major_version' => 6 }
end.converge described_recipe
end
@@ -931,7 +916,7 @@ describe 'datadog::dd-agent' do
:platform => 'redhat',
:version => '7.3'
) do |node|
- node.normal['datadog'] = { 'api_key' => 'somethingnotnil', 'agent6' => true }
+ node.normal['datadog'] = { 'api_key' => 'somethingnotnil', 'agent_major_version' => 6 }
end.converge described_recipe
end
@@ -953,7 +938,7 @@ describe 'datadog::dd-agent' do
version: '14.04'
) do |node|
node.name 'chef-nodename' # expected to be used as the hostname in `datadog.yaml`
- node.normal['datadog'] = { 'api_key' => 'somethingnotnil', 'agent6' => true }
+ node.normal['datadog'] = { 'api_key' => 'somethingnotnil', 'agent_major_version' => 6 }
end.converge described_recipe
end
@@ -1004,7 +989,7 @@ describe 'datadog::dd-agent' do
version: '2012R2'
) do |node|
node.name 'chef-nodename' # expected to be used as the hostname in `datadog.yaml`
- node.normal['datadog'] = { 'api_key' => 'somethingnotnil', 'agent6' => true }
+ node.normal['datadog'] = { 'api_key' => 'somethingnotnil', 'agent_major_version' => 6 }
end.converge described_recipe
end
@@ -1056,7 +1041,7 @@ describe 'datadog::dd-agent' do
node.name 'chef-nodename' # expected to be used as the hostname in `datadog.yaml`
node.normal['datadog'] = {
'api_key' => 'somethingnotnil',
- 'agent6' => true,
+ 'agent_major_version' => 6,
'extra_config' => {
'secret_backend_command' => '/sbin/local-secrets',
'process_config' => {
@@ -1120,9 +1105,8 @@ describe 'datadog::dd-agent' do
) do |node|
node.normal['datadog'] = {
'api_key' => 'somethingnotnil',
- 'agent6' => true,
- 'agent_version' => '5.22.0',
- 'agent6_version' => '6.0.3'
+ 'agent_major_version' => 6,
+ 'agent_version' => '6.0.3'
}
end.converge described_recipe
end

MODIFY
spec/system-probe_spec.rb
spec/system-probe_spec.rb
@@ -10,7 +10,7 @@ describe 'datadog::system-probe' do
node.name 'chef-nodename' # expected to be used as the hostname in `datadog.yaml`
node.normal['datadog'] = {
'api_key' => 'somethingnotnil',
- 'agent6' => true,
+ 'agent_major_version' => 6,
'system_probe' => {
'debug_port' => 123,
'bpf_debug' => true,
@@ -49,7 +49,7 @@ describe 'datadog::system-probe' do
node.name 'chef-nodename' # expected to be used as the hostname in `datadog.yaml`
node.normal['datadog'] = {
'api_key' => 'somethingnotnil',
- 'agent6' => true,
+ 'agent_major_version' => 6,
'extra_config' => {
'system_probe' => {
'max_tracked_connections' => 1000

Refactor to remove agent version-specific variables