-
-
Save pslobo/1c53a34e6e273d2654c6 to your computer and use it in GitHub Desktop.
Create puppet facts for RPM packages
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
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