Skip to content

Instantly share code, notes, and snippets.

@dholth
Created May 19, 2011 20:37
Show Gist options
  • Save dholth/981685 to your computer and use it in GitHub Desktop.
Save dholth/981685 to your computer and use it in GitHub Desktop.
Facter.add('yum_installed_groups') do
setcode do
state = -1
groups = [[], []]
%x{/usr/bin/yum grouplist -v}.each_line do |line|
if line.match('Installed Groups')
state = 0
elsif line.match('Available Groups')
state = 1
end
if state >= 0
q = line.match('\(([^\)]*)\)')
if q
groups[state].push(q.captures[0])
end
end
end
# installed groups
groups[0].join(',')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment