2 # Cookbook Name:: accounts
5 # Copyright 2010, OpenStreetMap Foundation
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
11 # http://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
26 search(:accounts, "*:*").each do |account|
28 details = node[:accounts][:users][name] || {}
31 group_members = details[:members] || account["members"] || []
32 user_home = details[:home] || account["home"] || "#{node[:accounts][:home]}/#{name}"
33 manage_user_home = details.fetch(:manage_home, account.fetch("manage_home", node[:accounts][:manage_home]))
35 group_members = group_members.collect(&:to_s).sort
39 user_shell = "/usr/sbin/nologin"
40 when "user", "administrator"
41 user_shell = details[:shell] || account["shell"] || node[:accounts][:shell]
45 gid account["uid"].to_i
46 members group_members & node[:etc][:passwd].keys
50 uid account["uid"].to_i
51 gid account["uid"].to_i
52 comment account["comment"] if account["comment"]
55 manage_home manage_user_home
58 remote_directory "/home/#{name}" do
69 cookbook = run_context.cookbook_collection[cookbook_name]
70 files = cookbook.relative_filenames_in_preferred_directory(node, :files, name.to_s)
72 rescue Chef::Exceptions::FileNotFound
78 administrators.push(name.to_s) if details[:status] == "administrator"
90 node[:accounts][:groups].each do |name, details|
93 members details[:members]
100 members administrators.sort
105 members administrators.sort
110 members administrators.sort