Skip to content

Instantly share code, notes, and snippets.

@petems
Forked from KartikTalwar/RPMpackages.rb
Created April 11, 2016 11:09
Show Gist options
  • Save petems/7ba3e432be727bf4201e2da988cea4bb to your computer and use it in GitHub Desktop.
Save petems/7ba3e432be727bf4201e2da988cea4bb 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