Skip to content

Instantly share code, notes, and snippets.

@pslobo
Forked from KartikTalwar/RPMpackages.rb
Last active September 3, 2015 14:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pslobo/1c53a34e6e273d2654c6 to your computer and use it in GitHub Desktop.
Save pslobo/1c53a34e6e273d2654c6 to your computer and use it in GitHub Desktop.
Create puppet facts for RPM packages
package_data = Facter::Util::Resolution.exec('rpm --query --all --qf "%{NAME}||%{VERSION}\n"')
package_data.split("\n").each do |line|
rpm_detail = line.split("||")
package_name = 'package_' + rpm_detail[0]
package_version = rpm_detail[1]
Facter.add(package_name) do
setcode do
Facter.value(package_version)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment