Created
December 23, 2011 18:48
-
-
Save btm/1515049 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
| # Opscode Chef recipe for configuring users that can also push configuration files and ssh keys | |
| admin_users = search(:users, 'groups:admin') | |
| admin_group = Array.new | |
| admin_users.each do |u| | |
| admin_group << u['id'] | |
| 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['id'] | |
| 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 "admin" do | |
| gid 5000 | |
| members admin_group | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment