Ask Your Question

Temporarily removing one package to install another

asked 2015-03-20 11:50:14 -0600

rmc47 gravatar image

A slightly odd requirement, and I'm wondering how to best tackle it in Puppet...

The Windows 7 SDK installer has an irritating bug (as do some others), which means it will fail to install if a more recent version of the Visual C++ Redistributable is installed than the one it ships with - but it's fine if the later version of the redist is installed again after the SDK.

So logically, a deployment looks like this:

  1. If C++ redist more recent than 10.0.30319 is installed, remove it
  2. Install SDK
  3. If we removed the newer C++ redist in step #1, put it back

Steps 1 and 3 should only, of course, happen if we need to do step 2, and step 3 should only happen if we needed to do step 1.

Is it sensible to try and do this as three package resources with what feels like somewhat awkward requires and notifies between them, or should I be looking to pull this out into something a bit more imperative?

Thanks, Rob

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-03-24 10:53:40 -0600

csharpsteen gravatar image

updated 2015-03-24 18:04:00 -0600

In general, Puppet models and enforces the end state of a resource. This means that moving a resource through a series of intermediate states is not something that fits well into the Puppet model.

That being said, there is a module called puppetlabs/transition that may work in this case. The module provides a new resource type, Transition, that establishes a single intermediate state between two resources.

Assuming both the SDK and the C++ libraries are manageable via Package resources, a Transition could be applied to your scenario:

transition {'temporarily remove CXX redist':
  resource   => Package['CXX Redist'],
  attributes => { ensure => absent },
  prior_to   => Package['Windows 7 SDK'],

package {'Windows 7 SDK':
  ensure => installed,
  before => Package['CXX Redist'],

package {'CXX Redist':
  ensure => installed,

If the SDK package has any pending changes, then the CXX package will be removed before the SDK is installed or upgraded and then re-installed afterwards. Note that the Transition will also fire if the SDK is being removed --- in that case you may want to use conditional logic to exclude the transition from a catalog that enforces the removal of the SDK.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2015-03-20 11:50:14 -0600

Seen: 1,773 times

Last updated: Mar 24 '15