On Saturday, April 19, 2014 5:28:33 AM UTC-5, Jakov Sosic wrote: > > On 04/19/2014 04:09 AM, Alexander Gray II wrote: > > Is there a way in puppet to detect what version of python or ruby, or > > for that matter, any package which is installed? > > > > For instance: > > if python_version > x: > > do something > > else > > do something else > > > > It looks liek versioncmp is what I want, but I don't know how to get the > > version. > > Maybe do some sort of exec that gets this version? > > > > Sorry if this a newb question, > > You could write a custom fact, that would get you version number. > > One problem with that is the first puppet run, before the package is > installed, that fact would have to return something like '0', or 'nil', > so you would have to run puppet twice to get a node to a desired state. > > I haven't found more intelligent approach to this problem so far :-/ > >
It's a question of defining what you're actually after. If the question is "what version of Python (for example) is installed NOW?" then a custom fact is the right approach. If the question is what version of Python will be installed at some future time, then you need a fortune teller instead. Or else you need to *manage* that aspect of your node's configuration. Whenever possible it is better to tell Puppet what configuration you want to achieve than to inquire. So, if you want Python 2.7, for example, then *declare that* to Puppet, and rely on Puppet to make it so. In some cases that may require some knowledge of the possibilities -- e.g. RHEL 6's official packages are pegged to Python 2.6 -- but that's knowledge you (can) have. John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/43d7b224-c70a-4d44-a4ce-c86bbde7d140%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
