Remove windows dependency too and cleanup Chef 11
MODIFY
README.md
README.md
@@ -47,20 +47,8 @@ The following Opscode cookbooks are dependencies:
* `apt`
* `chef_handler`
-* `windows`
* `yum`
-**Note for Chef 11 users**: please use these additional dependency version contraints for compatibility with Chef 11:
-
-```
-cookbook 'apt', '< 4.0'
-cookbook 'chef_handler', '< 2.0'
-cookbook 'windows', '< 2.0'
-cookbook 'yum', '~> 3.0'
-```
-
-(in Berkshelf/Librarian format)
-
Recipes
=======
@@ -75,8 +63,6 @@ Installs the Datadog agent on the target system, sets the API key, and start the
**Notes for Windows**:
* With Chef >= 12.6 _and_ the `windows` cookbook >= 1.39.0, Agent upgrades are known to fail.
- For Chef>=12.6 users on Windows, we recommend pinning the `windows` cookbook to a lower version (`~> 1.38.0` for instance).
-
If that's not an option, a known workaround is to use the `remove-dd-agent` recipe (since the `2.5.0` version of the present cookbook) to uninstall the Agent
prior to any Agent upgrade.

MODIFY
metadata.rb
metadata.rb
@@ -24,7 +24,6 @@ end
depends 'apt' # We recommend '>= 2.1.0'. See CHANGELOG.md for details
depends 'chef_handler', '>= 1.1' # We recommend '~> 1.3' with Chef < 12. See CHANGELOG.md for details
-depends 'windows' # We recommend '< 1.39.0' if running Chef >= 12.6. See README.md for details
depends 'yum', '>= 3.0' # Use '~> 3.0' with Chef < 12
recipe 'datadog::default', 'Default'

MODIFY
recipes/_install-windows.rb
recipes/_install-windows.rb
@@ -42,24 +42,10 @@ else
install_options = '/norestart ALLUSERS=1'
end
-# Use a separate resource without a `source` so that it looks in the Registry to find the MSI to use
-# for the package removal
-# On Chef >= 12.6, we have to use the `package` resource instead of `windows_package` to allow not specifying a source
-# (this is related to the way the windows cookbook changes the provider of `windows_package` depending on the
-# version of Chef, and to improvements on the `package` resource made in Chef 12.6)
-# FIXME: when we remove Chef < 12.6 support on Windows, which should allow using core resources only
-use_windows_package_resource = Gem::Version.new(Chef::VERSION) < Gem::Version.new('12.6.0')
-if use_windows_package_resource
- windows_package 'Datadog Agent removal' do
- package_name 'Datadog Agent'
- action :nothing
- end
-else
package 'Datadog Agent removal' do
package_name 'Datadog Agent'
action :nothing
end
-end
package_retries = node['datadog']['agent_package_retries']
package_retry_delay = node['datadog']['agent_package_retry_delay']
@@ -72,12 +58,8 @@ remote_file temp_file do
retry_delay package_retry_delay unless package_retry_delay.nil?
# As of v1.37, the windows cookbook doesn't upgrade the package if a newer version is downloaded
# As a workaround uninstall the package first if a new MSI is downloaded
- if use_windows_package_resource
- notifies :remove, 'windows_package[Datadog Agent removal]', :immediately
- else
notifies :remove, 'package[Datadog Agent removal]', :immediately
end
-end
# Install the package
windows_package 'Datadog Agent' do # ~FC009
@@ -85,9 +67,5 @@ windows_package 'Datadog Agent' do # ~FC009
installer_type installer_type
options install_options
action :install
- if respond_to?(:returns)
returns [0, 3010]
- else
- success_codes [0, 3010]
- end
end

Remove windows dependency too and cleanup Chef 11