Skip to content

Instantly share code, notes, and snippets.

@mwohlgemuth
Created September 8, 2014 15:31
Show Gist options
  • Save mwohlgemuth/aa1c1540688d31a02573 to your computer and use it in GitHub Desktop.
Save mwohlgemuth/aa1c1540688d31a02573 to your computer and use it in GitHub Desktop.
# printers.rb
Facter.add('printers') do
confine :kernel => %w{Linux FreeBSD OpenBSD SunOS Darwin}
confine do
Facter::Core::Execution.which('lpstat')
end
setcode do
output = Array.new
printers = Facter::Core::Execution.exec('/usr/bin/lpstat -a')
printers.each_line { |line| output.push(line.split.first)}
output
end
end
Facter.add('printers_foreign') do
confine :printers
setcode do
house_printers = ["PrintFollowMe"]
printers = Array.new
Facter.value("printers").each { |printer| printers.push(printer) }
res = house_printers & printers
output = printers.count - res.count
output
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment