chef / chef

Chef Infra, a powerful automation platform that transforms infrastructure into code automating how infrastructure is configured, deployed and managed across any environment, at any scale
http://www.chef.io/chef/
Apache License 2.0
7.63k stars 2.51k forks source link

Chocolatey package provider doesn't allow downgrades when specifying version #11915

Open erlogan opened 3 years ago

erlogan commented 3 years ago

Description

When specifying a version for a chocolatey package, you can only roll forward, not back, because the invocation to choco.exe lacks the --allow-downgrade or --force flag. It should probably either set --allow-downgrade every time or the provider should support allow_downgrade as an option (like, e.g., the yum package provider).

Chef Version

This is true on master (and reading code, probably since the provider was introduced)

Platform Version

Windows 10 1803 (but should repeat on any Windows install)

Replication Case

  1. Install a newer version of a package outside of chef
  2. Attempt to run chef-client
  3. error (pasted below)

Client Output

The package name has been changed for illustrative purposes.

Chocolatey installed 0/1 packages. 1 packages failed.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

Failures
 - some-windows-package - A newer version of some-windows-package (v20210812.092429) is already installed.
 Use --allow-downgrade or --force to attempt to install older versions, or use side by side to allow multiple versions.
STDERR:
---- End output of ["C:\\ProgramData\\chocolatey/bin/choco.exe", "install", "-y", "--version", "20210810.135405", "some-windows-package"] ----
Ran ["C:\\ProgramData\\chocolatey/bin/choco.exe", "install", "-y", "--version", "20210810.135405", "some-windows-package"] returned 1
[2021-08-12 18:42:11 +0100] INFO chefctl.rb: chef-client.bat failed with exit code 1, check log output!

Stacktrace

N/A

erlogan commented 3 years ago

Reading code again this morning I realized that I can pass in arbitrary options to choco.exe using the options field, so I did that for now, but that's more of a workaround than a fix.