-
Notifications
You must be signed in to change notification settings - Fork 68
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
[Feature] Only ensure package is latest if it is installed #357
Comments
Hi! This sounds a bit like an antipattern. Can you explain your usecase? |
For patching/compliance. If a software is installed, ensure it is the latest available version. Otherwise, leave it absent. I had to write a custom facter to enumerate installed packages, and then basically achieved this with: if $facts['choco_packages']['packagename'] {
package { 'packagename':
ensure => latest,
provider => 'chocolatey',
source => 'chocolatey',
}
} But providing this functionality out-of-the-box would be beneficial. It could look something like: package { 'packagename':
ensure => latest,
provider => 'chocolatey',
source => 'chocolatey',
unless => absent,
} or package { 'packagename':
ensure => latest,
provider => 'chocolatey',
source => 'chocolatey',
onlyif => present,
} |
This doesn't make sense. Your fact logic is the right approach. If you wanted some other workable approach, you could use exec resource |
Are you saying the only way to install a package with chocolatey is to do so with puppet? 😄 User manually installs a package, and then the puppet code would say that if the package is present, make sure it is the latest package. This is a simple |
if you had compliance control, I would think a user does not manually install a package in the first place. |
This approach is wrong in my opinion. Puppet defines the desired state, not the system. Either you want a specific package installed via puppet or not. And Puppet is a configuration management system, not a patch tool. You can use facts to identify available updates or all packages that are installed but not managed by Puppet. But for patching, you should use orchestration tools like Bolt. |
Use Case
I would like to be able to ensure that certain packages are the latest version only if they are currently installed. If they are not installed, allow them to remain absent.
Describe the Solution You Would Like
Currently,
ensure => latest
will install the package if it is absent, and then ensure it is the latest version. This is not what I desire in certain use-cases.In light of this, one possible solution would be to add an additional option that could be paired with
ensure => present|1.0.0|etc.
that would change the behavior to only correct if the package already exists/is currently installed.Describe Alternatives You've Considered
I could write some conditional code to determine if the package is already installed before applying this condition, but that would require enumerating existing packages. As far as I know, this functionality does not currently exist in this module, which would mean having to either hack together an Exec statement to determine if the package is installed, or write a custom Facter to enumerate installed packages.
The text was updated successfully, but these errors were encountered: