With puppet, sometimes it is necessary to make case statements around what version of a package is installed rather than having puppet dictate what version is installed. Say "add x line to sshd config for x version." To do this we need to have fact with what package version is already installed on the system, here's a quick script to do that in bulk. To deploy, add this as a plugin in a module.

In this case we've got a regex with all the packages we care about, I know you could make this an array and loop over it but the performance is better to call the rpm command just once and then loop over the output. Technically you could do all packages but that seems pointless to me and would also be a ton of packages. Then the other trick was changing '-' to '_' because dashes aren't allowed in fact names but are quite common in package names.

Then in our manifests we can make case statements or if blocks on these new fancy facts.