Created
September 8, 2014 15:31
-
-
Save mwohlgemuth/aa1c1540688d31a02573 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# 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