Created
May 30, 2012 21:26
-
-
Save ryanycoleman/2839067 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generates facts of the version pkg_foo => 'version' | |
begin | |
require 'puppet' | |
pkgs = Puppet::Type.type(:package).instances | |
pkgs.each do |pkg| | |
Facter.add("pkg_#{pkg[:name]}") do | |
value = pkg.provider.properties[:ensure] | |
if value != :absent | |
setcode { value } | |
end | |
end | |
end | |
rescue => LoadError | |
Facter.warn 'Unable to load puppet; cannot generate pkg facts.' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment