问题原文
原帖链接 · gxx · CC BY-SA 3.0
If one thinks of a better title for this question: Please change it accordingly.
Environment:
- Debian jessie 8.5
- puppet master: 3.8.5
- puppet agent: 3.7.2
- apt: 1.0.9.8.3
Problem:
A specific package is installed already on the node, let's take needrestart for example:
# dpkg -l | grep needrestart
ii needrestart 1.2-8+deb8u1
Using the following code:
package{[
'needrestart',
]:
ensure => installed, # latest won't work, either
install_options => ['-t', 'jessie-backports']
}
I would expect that needrestart is reinstalled / upgraded to the version out of jessie-backports. However, this doesn't happen, there is no reinstall / upgrade happening. Inside the (debug) logs there's nothing worth to be shown regarding this.
Solution:
In case this is not intended: Anyone knows a clever way around this?
已采纳解答
原帖链接 · M. Glatki · CC BY-SA 3.0
Your problem is, that your install_options will only be used if the package resource is actually installing your packages. You have a few options:
- Use
ensure => latestand hope for a package update (or trigger one yourself) - probably not what you want. - Upgrading to Puppet 4.x. Since version 4, Puppet has reinstall_on_refresh, which allows a reinstall on a
notifyevent, if the provider supportsreinstallable. While this works on Debian, this option is probably not useable for you. - Trick Puppet into thinking the package is uninstalled - this would need a puppet patch on your local installation, not recommended.
- Patch Puppet with reinstallation capabilities: In this bug report from a few years ago, Aggelos Economopoulos supplied a patch for some version of puppet, which looks rather simple. This should get you started. I do not recommend patching your puppet agent installations, though.
Reinstall it yourself: Probably the only option you have for now: Write something along these lines:
exec { "apt-get reinstall $package $your_options": user => 'root', onlyif => 'dpkg -s $package| grep 'Version $your_version' }Depending on the differences of the packages with and without options, this can be arbitrarily hard. If only a handful of packages are affected, it can be managable.
Write your own provider and add it to
package, or establish something likepackage_reinstall: It is surprisingly easy, can be managed and versioned via a module, and works without a Puppet update. I suggest starting with provider/package/apt.rb. This might be your best option after all.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
