Created
July 16, 2011 03:24
-
-
Save phlipper/1085967 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
:users => [ | |
{ | |
:username => "shasta", | |
:full_name => "Shasta Application", | |
:password => "$1$axBB.gQW$4MW2bY6Dd/5xAfKbJvJpx/", | |
:authorized_keys => [ | |
"ssh-rsa xxxVnvQB/bQOOrwKK8pfEeY3TFeW/BTC71skze9+YxBYuEoTZDhzpFY9N8gRLc567iOBTuvNKVsBnELgWd/g056ulCK3SMHpTrENWsdNEp0yS319BW5Kyr0xGXkzWH2Q/SKkVWqH6bW2hFTU23fGOema+WuKc41crlNwaQVbhchiAnJCJ7RpDqyNPZKQ8h5Kw9v96d261YWxuNA0ZDqkusbkFt5h3LUoRfC/foXy7M2+tMy9CuDmC5uLJU6UCAtWRwpmGj2oTEUeCagLcyEi/Y5DS32KzvEXXwFm1PsA6iRKxfDY0qYWlVG0JXz6hVrQWRJuh3DrwuLlw==", | |
"ssh-rsa xxx1yc2EAAAABJQAAAIEA13WvDodzAp9JN0YTR7F9NylTo7isVqtLssq7xlRbTjjSOfqTFMXj4hYoMaE03Y3IbwO1Zq4NPM7jT5Ulsfx5koNmOjH805n5w9Fcmhj5Ty7prXfEdfTU5jexUglR4Lq6N7bH+vDZEeoxIrGtV9lcnRpr9o7ulxK3dYrBSqKhi+k=" | |
], | |
:home => "/home/shasta", | |
:custom_files => [ | |
{ :name => ".bash_profile", :content => File.read("custom_files/shasta/bash_profile") }, | |
{ :name => ".toprc", :content => File.read("custom_files/shasta/toprc") } | |
] | |
}, | |
] |
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
# | |
# Cookbook Name:: users | |
# Recipe:: default | |
# | |
node[:users].each do |user| | |
# Setup group | |
group user[:username] do | |
gid user[:gid] if user[:gid] | |
action [ :create, :manage ] | |
end | |
# Setup user | |
user user[:username] do | |
comment user[:comment] if user[:comment] | |
uid user[:uid] if user[:uid] | |
gid user[:gid] || user[:username] | |
home user[:home] || "/home/#{user[:username]}" | |
shell user[:shell] || "/bin/bash" | |
password user[:password] if user[:password] | |
action [ :create, :manage ] | |
end | |
# Custom files | |
for custom_file in user[:custom_files] || [] | |
template (custom_file[:path] || "#{user[:home] || "/home/#{user[:username]}"}/#{custom_file[:name]}") do | |
owner user[:username] | |
group user[:username] | |
mode custom_file[:mode] || "0744" | |
variables :content => custom_file[:content] | |
source "custom.erb" | |
end | |
end | |
# local ssh directory | |
directory "/home/#{user[:username]}/.ssh" do | |
owner user[:username] | |
group user[:username] | |
mode "0700" | |
recursive true | |
end | |
# local ssh keys | |
template "/home/#{user[:username]}/.ssh/authorized_keys" do | |
owner user[:username] | |
group user[:username] | |
mode "0600" | |
source "authorized_keys.erb" | |
variables :user => user | |
end if user[:authorized_keys] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment