Created
November 7, 2012 07:33
-
-
Save mpepping/4030022 to your computer and use it in GitHub Desktop.
facter, sysmgmt, users.rb
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
Facter.add("users") do | |
confine :kernel => %w{Linux FreeBSD OpenBSD} | |
setcode do | |
users = Array.new | |
if File.executable?('/usr/bin/getent') | |
if getent_output = %x{/usr/bin/getent passwd} | |
getent_output.split("\n").each do |line| | |
next if line =~ /^nobody/ | |
users << line.split(":")[0] if line.split(":")[2].to_i >= 1000 or line.split(":")[2].to_i == 0 | |
end | |
users.join(',') | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment