summaryrefslogtreecommitdiff
path: root/examples/user_index.rb
blob: 485cff81b85f59a75d207f21a71f083abd10758c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/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