[windows] Update version logic for Agent 6
* update "latest" MSI URL for Agent 6
* make version handling consistent with Linux, with agent6_version
attribute
MODIFY
.kitchen.yml
.kitchen.yml
@@ -12,9 +12,11 @@ platforms:
ubuntu-12.04
centos-6.6
centos-5.11
+ centos-7.1
debian-7.7
)
chef_versions = %w(
+ 13
12.2.1
11.18.6
)

MODIFY
attributes/default.rb
attributes/default.rb
@@ -162,7 +162,7 @@ default['datadog']['windows_agent_checksum'] = nil
# Set to `true` to use the EXE installer on Windows, recommended to gracefully handle upgrades from per-user
# to per-machine installs on most environments. We recommend setting this option to `true` for Agent upgrades from
# versions <= 5.10.1 to versions >= 5.12.0.
-# The EXE installer exists since Agent release 5.12.0
+# The EXE installer exists since Agent release 5.12.0. It is not provided for >= 6.0.0 versions.
# If you're already using version >= 5.12.0 of the Agent, leave this to false.
default['datadog']['windows_agent_use_exe'] = false

MODIFY
recipes/_install-windows.rb
recipes/_install-windows.rb
# limitations under the License.
#
-dd_agent_version =
+dd_agent5_version =
if node['datadog']['agent_version'].respond_to?(:each_pair)
node['datadog']['agent_version']['windows']
else
node['datadog']['agent_version']
end
+dd_agent6_version =
+ if node['datadog']['agent6_version'].respond_to?(:each_pair)
+ node['datadog']['agent6_version']['windows']
+ else
+ node['datadog']['agent6_version']
+ 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'
+end
+
# If no version is specified, select the latest package.
-# The latest package basename is `ddagent-cli-latest` since Agent version 5.12.0
-dd_agent_installer_basename = dd_agent_version ? "ddagent-cli-#{dd_agent_version}" : 'ddagent-cli-latest'
+dd_agent_installer_basename = dd_agent_version ? "ddagent-cli-#{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
spec/dd-agent_spec.rb
spec/dd-agent_spec.rb
@@ -892,5 +892,39 @@ describe 'datadog::dd-agent' do
end
end
end
+
+ describe 'agent version set' do
+ context 'on windows' do
+ cached(:chef_run) do
+ set_env_var('ProgramData', 'C:\ProgramData')
+ ChefSpec::SoloRunner.new(
+ :platform => 'windows',
+ :version => '2012R2',
+ :file_cache_path => 'C:/chef/cache'
+ ) do |node|
+ node.set['datadog'] = {
+ 'api_key' => 'somethingnotnil',
+ 'agent6' => true,
+ 'agent_version' => '5.22.0',
+ 'agent6_version' => '6.0.3'
+ }
+ end.converge described_recipe
+ end
+
+ temp_file = ::File.join('C:/chef/cache', 'ddagent-cli.msi')
+
+ it 'installs Datadog Agent' do
+ expect(chef_run).to install_windows_package('Datadog Agent').with(installer_type: :msi)
+ end
+
+ # remote_file source gets converted to an array, so we need to do
+ # some tricky things to be able to regex against it
+ # Relevant: http://stackoverflow.com/a/12325983
+ it 'installs agent 6.0.3' do
+ expect(chef_run.remote_file(temp_file).source.to_s)
+ .to match(/ddagent-cli-6.0.3.msi/)
+ end
+ end
+ end
end
end

[windows] Update version logic for Agent 6 (#530)

* update "latest" MSI URL for Agent 6
* make version handling consistent with Linux, with agent6_version
  attribute