Is there a way to force puppet to do certain things first? For instance, I need it to install an RPM on all servers to add a yum repository (IUS Community) before I install any of the packages.
Is there a way to force puppet to do certain things first? For instance, I need it to install an RPM on all servers to add a yum repository (IUS Community) before I install any of the packages.
If you want to make sure a repository is installed on all your server then I would suggest something like this
Then, for any node that extends
base
you can sayThis will ensure that
bar
will not be installed unless the IUS repository is definedAlthough stages can handle this and so can specific yum repo dependencies, better is to declare the relationship generically.
Just put
Yumrepo <| |> -> Package <| provider != 'rpm' |>
in your puppet manifest.This makes it so that all yumrepo types will get processed before any packages that don't have 'rpm' as their provider. That latter exclusion is so that I can use the (for example) epel-release RPM package to help install the yum repo.
(I found this question after I replied almost the same.. so thought my answer applies here as well and it's worth repeating it (it's safer to have an answer in two places..)
As far as I understand, this is exactly what stages are for -- they let you group and order class executions. I use "stages" to update and configure APT at Debian servers, which should be very similar to what you are going to do with YUM.
First of all, you declare "yum" stage at top level (above "nodes"), so that classes in "yum" stage will be executed before "main" ones:
Then, you assign stage to the classes. You can do this right in your node definition:
You could use Tags. This would allow you to tag the repo installer with
firstrun
or something,then run
and it would only execute the modules/statements matching the tag.
The key thing you need to use is the require keyword - "Evaluate one or more classes, adding the required class as a dependency."
An example using an apt repository could be:
(Adapted from this example of puppet bootstrapping).
So you can see how each stage requires that the previous one be done first. I'll leave you to work out how to apply this to yum as I'm not familiar with where it stores it's files.
Puppet reads the config from top to bottom, so if you include a class with the yum repo first in that class, this repo will be added before anything else.
If you use the require settings on a package, you will ensure that the required resource type is present before adding the package, as such:
This code above will add the repo before adding the package.
Something like this worked for me:
I included something like this on mysite.pp. In this way, your puppet modules, are free of references to yum repos.