-
-
Save dholth/981682 to your computer and use it in GitHub Desktop.
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
centauri :: ~/test » cat x.txt | |
lkdjafs | |
lsjdkflkasjdf;lkajsdf | |
ajdsf | |
akjsdf | |
dsjflkasdfj | |
Installed Groups | |
a | |
b | |
c | |
Available Groups | |
d | |
e | |
f |
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
require 'facter' | |
Facter.add("group_names") do | |
setcode do | |
file = "x.txt" | |
start = false | |
finish = false | |
data = [] | |
return nil unless File.exists?(file) | |
File.read(file).each_line do |l| | |
finish = true if l =~ /^Available Groups/ | |
data << l.chomp if start and not finish | |
start = true if l =~ /^Installed Groups/ | |
end | |
require 'pp' | |
data.reject { |item| item.empty? }.join(",") | |
end | |
end |
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
centauri :: ~/test » facter group_names | |
a,b,c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment