Skip to content

Instantly share code, notes, and snippets.

@mpepping
Created November 7, 2012 07:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mpepping/4030022 to your computer and use it in GitHub Desktop.
Save mpepping/4030022 to your computer and use it in GitHub Desktop.
facter, sysmgmt, users.rb
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