We will be upgrading our RHEL 6.5 machines to RHEL 6.6 in the coming week. I know how to create repos using Puppet, but instead of just using exec
to run a yum -y update
, is there a way to tell Puppet to bring (or keep) the OS to a certain release? Something like stating that it should change the sytem to reach or keep the following criteria:
operatingsystem => RedHat
operatingsystemmajrelease => 6
operatingsystemrelease => 6.6
TL;DR this is not a good idea. Do the update manually, or with a different form of automation.
Why it's a bad idea
I don't think that you should go down this path at all.
Generally, the idea to use Puppet to make sure that an update of the OS has been successfully completed is sound, at least from an academic standpoint. Puppet's goal is to allow you to define a state, and take care of the specifics of reaching this state.
That being said, Puppet would require a (fictional)
distro
type, so that you could specifyYou could conceivably go ahead and implement such a type, with the capability to try and perform a synchronization action to get from whatever your current release is to the one you have requested.
However, such a process can be infinitely complex and has virtually unlimited possibilities for failure and system corruption (of done wrong or at all). As such, it does not really lend itself very well to any form of automation.
As for Puppet specifically, you would want to add logic to your
distro
type/provider to recover from all sorts of weird states and achieve a clean one. The mere thought of such an endeavor is making me dizzy.What would be less painful
Write a shell script. If the number of machines is too large to do them in batches using
cssh
(as I would probably do for anything below a few hundred nodes), create a simple wrapper that will do all you need. Deploy it with Puppet, and yes, do use anexec
resource if you want Puppet to trigger the update. Considerso that the
puppet agent
process is not the parent of theyum
instance that will do all the work. This might prove disastrous.Still, I'd launch the
yum
commands manually if it is at all feasible.I agree that upgrading an OS through puppet looks like being too error-prone and at last unpredictable. But this isn't really true if you follow three rules:
No pets, only cattle!
I use the following puppet code for upgrading ubuntu machines from 12 to 14:
To meet point 4 you have to define a stage and make sure the above mentioned class is attributed correctly.
In
site.pp
: