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?
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:ensure => latest
and hope for a package update (or trigger one yourself) - probably not what you want.notify
event, if the provider supportsreinstallable
. While this works on Debian, this option is probably not useable for you.Reinstall it yourself: Probably the only option you have for now: Write something along these lines:
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.I believe
ensure => installed
will only make sure it is installed, but it won't upgrade if there is a newer version. Uselatest
to do that. It will also only upgrade if there is a newer version. If that is a preferred version you want that is older than the version that is currently installed, you will have to find a way to work around that. Perhaps anexec
that will check if current installed version is different than the version in that other repo, then uninstall if it is, and let the package resource install the correct version after.You will need to trigger the install action for the install_options to take effect. A possible workaround is to first
ensure => absent
, and then once the package is removed you canensure => present
orensure => 1.2-8+deb8u1
and the subsequent install will honor install_options.I'm using
APT pinning
quite extensively since a while, and I believe this is (one of) the cleanest solutions out there, especially if combined withunattended upgrades
and / or a regularapt-get dist-upgrade
.