Temporarily removing one package to install another

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:

If C++ redist more recent than 10.0.30319 is installed, remove it

Install SDK

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?

1 Answer

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:

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.