Slackbot
06/05/2023, 4:46 PMma_garvo
06/05/2023, 4:59 PMFacter.add(:rpm) do
confine :osfamily => "RedHat"
setcode do
rpm_hash = {}
# Grab rpm facts
if Facter::Core::Execution.which('rpm')
# Pull the rpm facts and parse
rpm_output = Facter::Core::Execution.execute('rpm --query --all --qf "%{NAME}||%{VERSION}\n"')
# Split by line
rpm_output.split("\n").each do |line|
# Split by ||
rpm_detail = line.split("||")
# Populate hash with package name [0] and package version [1]
rpm_hash[rpm_detail[0]] = rpm_detail[1]
end
# Return the fact hash
rpm_hash
end
end
endLumiere
06/05/2023, 5:00 PMma_garvo
06/05/2023, 5:01 PMma_garvo
06/05/2023, 5:01 PMLumiere
06/05/2023, 5:01 PMma_garvo
06/05/2023, 5:03 PMbastelfreak
06/05/2023, 6:10 PM