1 # -*- coding: utf-8 -*-
 
   3 # Cookbook Name:: accounts
 
   6 # Copyright 2010, OpenStreetMap Foundation
 
   8 # Licensed under the Apache License, Version 2.0 (the "License");
 
   9 # you may not use this file except in compliance with the License.
 
  10 # You may obtain a copy of the License at
 
  12 #     http://www.apache.org/licenses/LICENSE-2.0
 
  14 # Unless required by applicable law or agreed to in writing, software
 
  15 # distributed under the License is distributed on an "AS IS" BASIS,
 
  16 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  17 # See the License for the specific language governing permissions and
 
  18 # limitations under the License.
 
  27 search(:accounts, "*:*").each do |account|
 
  29   details = node[:accounts][:users][name] || {}
 
  32     group_members = details[:members] || account["members"] || []
 
  33     user_home = details[:home] || account["home"] || "#{node[:accounts][:home]}/#{name}"
 
  34     manage_user_home = details.fetch(:manage_home, account.fetch("manage_home", node[:accounts][:manage_home]))
 
  36     group_members = group_members.collect(&:to_s).sort
 
  40       user_shell = "/usr/sbin/nologin"
 
  41     when "user", "administrator"
 
  42       user_shell = details[:shell] || account["shell"] || node[:accounts][:shell]
 
  47       gid account["uid"].to_i
 
  48       members group_members & node[:etc][:passwd].keys
 
  53       uid account["uid"].to_i
 
  54       gid account["uid"].to_i
 
  55       comment account["comment"] if account["comment"]
 
  58       manage_home manage_user_home
 
  61     remote_directory "/home/#{name}" do
 
  72           cookbook = run_context.cookbook_collection[cookbook_name]
 
  73           files = cookbook.relative_filenames_in_preferred_directory(node, :files, name.to_s)
 
  75         rescue Chef::Exceptions::FileNotFound
 
  81     administrators.push(name.to_s) if details[:status] == "administrator"
 
  93 node[:accounts][:groups].each do |name, details|
 
  96     members details[:members]
 
 103   members administrators.sort
 
 108   members administrators.sort
 
 113   members administrators.sort