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.
24 search(:accounts, "*:*").each do |account|
26 details = node[:accounts][:users][name] || {}
29 group_members = details[:members] || account["members"] || []
30 user_home = details[:home] || account["home"] || "#{node[:accounts][:home]}/#{name}"
31 manage_user_home = details.fetch(:manage_home, account.fetch("manage_home", node[:accounts][:manage_home]))
33 group_members = group_members.collect(&:to_s).sort
37 user_shell = "/usr/sbin/nologin"
38 when "user", "administrator"
39 user_shell = details[:shell] || account["shell"] || node[:accounts][:shell]
43 gid account["uid"].to_i
44 members group_members & node[:etc][:passwd].keys
48 uid account["uid"].to_i
49 gid account["uid"].to_i
50 comment account["comment"] if account["comment"]
53 manage_home manage_user_home
56 remote_directory "/home/#{name}" do
67 cookbook = run_context.cookbook_collection[cookbook_name]
68 files = cookbook.relative_filenames_in_preferred_directory(node, :files, name.to_s)
70 rescue Chef::Exceptions::FileNotFound
76 administrators.push(name.to_s) if details[:status] == "administrator"
88 node[:accounts][:groups].each do |name, details|
91 members details[:members]
98 members administrators.sort
103 members administrators.sort
108 members administrators.sort