Skip to content

Instantly share code, notes, and snippets.

@adamhjk
Created April 13, 2009 18:18
Show Gist options
  • Save adamhjk/94593 to your computer and use it in GitHub Desktop.
Save adamhjk/94593 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
#
# Create a users index, based on /etc/passwd
require 'etc'
require File.join(File.dirname(__FILE__), "..", "lib", "chef")
Chef::Config[:log_level] = :info
r = Chef::REST.new("http://localhost:4000")
users = Array.new
Etc.passwd do |passwd|
Chef::Log.info("Ensuring we have #{passwd.name}")
r.post_rest("search/user/entries",
{
:id => passwd.name,
:name => passwd.name,
:uid => passwd.uid,
:gid => passwd.gid,
:gecos => passwd.gecos,
:dir => passwd.dir,
:shell => passwd.shell,
:change => passwd.change,
:expire => passwd.expire
}
)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment