Created
August 5, 2010 22:51
-
-
Save adamhjk/510538 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sysadmins = search(:users, 'groups:sysadmin') | |
sysadmin_group = Array.new | |
sysadmins.each do |u| | |
sysadmin_group << u['id'] | |
u['openid'].each do |oid| | |
node[:apache][:allowed_openids] << oid unless node[:apache][:allowed_openids].include?(oid) | |
end if u['openid'] | |
home_dir = "/home/#{u['id']}" | |
user u['id'] do | |
uid u['uid'] | |
shell u['shell'] | |
comment u['comment'] | |
supports :manage_home => true | |
home home_dir | |
end | |
directory "#{home_dir}/.ssh" do | |
owner u['id'] | |
group u['id'] | |
mode "0700" | |
end | |
template "#{home_dir}/.ssh/authorized_keys" do | |
source "authorized_keys.erb" | |
owner u['uid'] | |
group u['id'] | |
mode "0600" | |
variables :ssh_keys => u['ssh_keys'] | |
end | |
if u.has_key?("files") | |
u["files"].each do |filename, file_data| | |
cookbook_file "#{home_dir}/#{filename}" do | |
source "#{u['id']}/#{file_data['source']}" | |
owner u['id'] | |
group u['id'] | |
mode file_data['mode'] | |
ignore_failure true | |
end | |
end | |
end | |
end | |
group "sysadmin" do | |
gid 2300 | |
members sysadmin_group | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
adam@latte% knife data bag show users adam
{
"groups": "sysadmin",
"comment": "Adam Jacob",
"files": {
".zshrc": {
"mode": "0644",
"source": "dot-zshrc"
},
".vimrc": {
"mode": "0644",
"source": "dot-vimrc"
}
},
"id": "adam",
"uid": 7000,
"shell": "/usr/bin/zsh",
"openid": "http://adamhjk.myopenid.com/"
}