Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package ensure => $version, should use upgrade rather than install if a version is already installed #71

Closed
steve-hawkins opened this issue Jul 21, 2015 · 8 comments · Fixed by #73

Comments

@steve-hawkins
Copy link

When stating a specific version of a package choco.exe list -lo -r should be used to determine if the package is already present, if present choco.exe upgrade $package -version $version -dvy else choco.exe install $package -version $version -dvy

output of puppet agent -t --debug

Debug: Prefetching chocolatey resources for package
Debug: Executing 'C:\ProgramData\chocolatey\bin\choco.exe -v'
Debug: Executing 'C:\ProgramData\chocolatey\bin\choco.exe list -lo -r'
Debug: Executing 'C:\ProgramData\chocolatey\bin\choco.exe install win-pack-man -version 0.0.13 -dvy '
Notice: /Stage[main]/Win_pack_man/Package[win-pack-man]/ensure: ensure changed '0.0.9' to '0.0.13'

At the moment choco.exe install is being used even if the package is already present, which is leading to strange behavior in the c:/programdata/chocolatey/lib directory, such as duplicate content.

choco.exe -v 0.9.9.6

output of puppet module list

/etc/puppetlabs/puppet/environments/production/modules
└── counsyl-windows (v1.0.0)
/etc/puppetlabs/puppet/modules
├── badgerious-windows_env (v2.2.1)
├── choco_inst (???)
├── chocolatey-chocolatey (v1.0.1)
├── counsyl-sys (v0.9.18)
├── hiscox-app_obx (v0.0.1)
├── jordan-windows_service (v0.0.4)
├── opentable-iis (v1.3.0)
├── programs_dotnet45 (???)
├── programs_wmf40 (???)
├── puppet-windowsfeature (v1.1.0)
├── puppetlabs-acl (v1.0.3)
├── puppetlabs-dism (v1.1.0)
├── puppetlabs-powershell (v1.0.4)
├── puppetlabs-registry (v1.1.0)
└── win_pack_man (???)
@ferventcoder
Copy link
Contributor

Definitely a bug.

@ferventcoder
Copy link
Contributor

@ferventcoder
Copy link
Contributor

Think this is as easy as moving to upgrade instead of install.

@ferventcoder
Copy link
Contributor

Of course I had to make reservations for install with packages.config - not allowed with upgrade/uninstall.

ferventcoder added a commit to ferventcoder/puppet-chocolatey that referenced this issue Jul 22, 2015
When ensure => $version, the underlying package provider will call
install instead of upgrade if the package is already installed.
Chocolatey's default install behavior is to do nothing if a package is
already installed, even if there is a newer version available. In most
cases we can call upgrade, except when the installer is using a
packages.config.

We'll also need to address the use of side by side installs, which this
will remove the ability to do.
@ferventcoder
Copy link
Contributor

@steve-hawkins take a look at #73

@ferventcoder
Copy link
Contributor

@steve-hawkins this has been released in 1.0.2

@steve-hawkins
Copy link
Author

Thanks Rob!

Excellent turn-around and I can confirm this has sorted the original issue.

I have however found that this does not support down-grading versions and raised a new issue #75

@ferventcoder
Copy link
Contributor

FYI just implemented an additional fix here so I could implement held.

ferventcoder added a commit that referenced this issue Oct 4, 2015
When ensure => "$version", Puppet will always call install. In cases of
when a version is already installed, we should ensure that choco is
called with upgrade.
DavidS pushed a commit to DavidS/puppetlabs-chocolatey that referenced this issue Mar 24, 2017
[MODULES-4528] Replace Puppet.version.to_f version comparison from spec_helper.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants