Using plugins (e.g. custom types, facts, functions and providers) gives you even more control over the behaviour of puppet and extend what it can do. An example custom fact that exposes the version of Python installed is:
# From http://reductivelabs.com/trac/puppet/wiki/Recipes/PythonVersion
require 'facter'
pythonversion = nil
if FileTest.exists?("/usr/bin/python")
pythonversion = %x{python -V 2>&1}.split(" ")[1]
end
Facter.add("pythonversion") do
setcode do
pythonversion
end
end
Facter.add("pythonmmversion") do
pythonmmversion = nil
if pythonversion != nil
pythonversionsplit = pythonversion.split(".")
pythonmmversion = pythonversionsplit[0] + "." + pythonversionsplit[1]
end
setcode do
pythonmmversion
end
end
Using this new custom fact you can create conditional statements in manifests or templates using $pythonverion or $pythonmmversion.