Skip to content

Instantly share code, notes, and snippets.

@Drewzar
Created March 29, 2013 15:38
Show Gist options
  • Save Drewzar/5271597 to your computer and use it in GitHub Desktop.
Save Drewzar/5271597 to your computer and use it in GitHub Desktop.
search(:users, 'groups:dev') do |u|
ssh_keys << u['ssh_keys']
end
search(:users, 'id:deploy') do |u|
home_dir = "/home/#{u['id']}"
user u['id'] do
uid u['uid']
gid u['gid']
shell u['shell']
comment u['comment']
supports :manage_home => true
home home_dir
end
directory "#{home_dir}/.ssh" do
owner u['id']
group u['gid'] || u['id']
mode "0700"
end
template "#{home_dir}/.ssh/authorized_keys" do
source "authorized_keys.erb"
owner u['id']
group u['gid'] || u['id']
mode "0600"
variables :ssh_keys => ssh_keys
end
cookbook_file "#{home_dir}/.ssh/config" do
owner u['id']
group u['group']
mode 0600
source "config"
backup false
end
cookbook_file "#{home_dir}/.ssh/id_rsa" do
source "id_rsa"
mode "0600"
owner "deploy"
group "deploy"
backup false
end
end
group "sysadmin" do
gid 2300
members 'deploy'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment