Permalink
Browse files

Merge branch 'COOK-517'

  • Loading branch information...
schisamo committed Apr 24, 2011
2 parents 1aaf6d6 + a0ce93b commit bf33af7b0d296e9176620a6317e940505b8ba9ac
Showing with 44 additions and 12 deletions.
  1. +19 −7 users/{README.rdoc → README.md}
  2. +8 −2 users/metadata.json
  3. +6 −2 users/metadata.rb
  4. +11 −1 users/recipes/sysadmins.rb
@@ -1,12 +1,22 @@
-= DESCRIPTION:
+Description
+===========
-Creates users with +authorized_keys+.
+Creates users from a databag search.
-= REQUIREMENTS:
+Requirements
+============
+
+Platform
+--------
+
+* Debian, Ubuntu
+* CentOS, Red Hat, Fedora
+* FreeBSD
Data bag named "users" must exist. See USAGE.
-= USAGE:
+Usage
+=====
This cookbook is specific for setting up sysadmin group and users for now.
@@ -21,7 +31,7 @@ Create a user.
knife data bag users bofh
{
"id": "bofh",
- "ssh_keys": "",
+ "ssh_keys": "ssh-rsa AAAAB3Nz...yhCw== bofh",
"groups": "sysadmin",
"uid": 2001,
"shell": "\/bin\/bash",
@@ -46,11 +56,13 @@ The sysadmin group will be created with GID 2300. This may become an attribute a
The Apache cookbook can set up authentication using OpenIDs, which is set up using the openid key here. See the Opscode 'apache2' cookbook for more information about this.
-= LICENSE and AUTHOR:
+License and Author
+==================
Author:: Joshua Timberman (<joshua@opscode.com>)
+Author:: Seth Chisamore (<schisamo@opscode.com>)
-Copyright:: 2009, Opscode, Inc
+Copyright:: 2009-2011, Opscode, Inc
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
View
@@ -1,11 +1,17 @@
{
"name": "users",
"description": "Creates users from a databag search",
- "long_description": "= DESCRIPTION:\n\nCreates users with +authorized_keys+.\n\n= REQUIREMENTS:\n\nData bag named \"users\" must exist. See USAGE.\n\n= USAGE:\n\nThis cookbook is specific for setting up sysadmin group and users for now.\n\n include_recipe \"users::sysadmins\"\n\nUse knife to create a data bag for users.\n\n knife data bag create users\n\nCreate a user.\n\n knife data bag users bofh\n {\n \"id\": \"bofh\",\n \"ssh_keys\": \"\",\n \"groups\": \"sysadmin\",\n \"uid\": 2001,\n \"shell\": \"\\/bin\\/bash\",\n \"comment\": \"BOFH\",\n \"nagios\": {\n \"pager\": \"8005551212@txt.att.net\",\n \"email\": \"bofh@example.com\"\n },\n \"openid\": \"bofh.myopenid.com\"\n }\n\nThe latest version of knife supports reading data bags from a file and automatically looks in a directory called +data_bags+ in the current directory. The \"bag\" should be a directory with JSON files of each item. For the above:\n\n mkdir data_bags/users\n $EDITOR data_bags/users/bofh.json\n\nPaste the user's public SSH key into the ssh_keys value. Also make sure the uid is unique, and if you're not using bash, that the shell is installed. Group must be sysadmin.\n\nThe recipe will also create the sysadmin group. If you're using the opscode sudo cookbook, they'll have sudo access in the default site-cookbooks template. They won't have passwords though, so the sudo cookbook's template needs to be adjusted so the sysadmin group has NOPASSWD.\n\nThe sysadmin group will be created with GID 2300. This may become an attribute at a later date.\n\nThe Apache cookbook can set up authentication using OpenIDs, which is set up using the openid key here. See the Opscode 'apache2' cookbook for more information about this.\n\n= LICENSE and AUTHOR:\n\nAuthor:: Joshua Timberman (<joshua@opscode.com>)\n\nCopyright:: 2009, Opscode, Inc\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n",
+ "long_description": "Description\n===========\n\nCreates users from a databag search.\n\nRequirements\n============\n\nPlatform\n--------\n\n* Debian, Ubuntu\n* CentOS, Red Hat, Fedora\n* FreeBSD\n\nData bag named \"users\" must exist. See USAGE.\n\nUsage\n=====\n\nThis cookbook is specific for setting up sysadmin group and users for now.\n\n include_recipe \"users::sysadmins\"\n\nUse knife to create a data bag for users.\n\n knife data bag create users\n\nCreate a user.\n\n knife data bag users bofh\n {\n \"id\": \"bofh\",\n \"ssh_keys\": \"ssh-rsa AAAAB3Nz...yhCw== bofh\",\n \"groups\": \"sysadmin\",\n \"uid\": 2001,\n \"shell\": \"\\/bin\\/bash\",\n \"comment\": \"BOFH\",\n \"nagios\": {\n \"pager\": \"8005551212@txt.att.net\",\n \"email\": \"bofh@example.com\"\n },\n \"openid\": \"bofh.myopenid.com\"\n }\n\nThe latest version of knife supports reading data bags from a file and automatically looks in a directory called +data_bags+ in the current directory. The \"bag\" should be a directory with JSON files of each item. For the above:\n\n mkdir data_bags/users\n $EDITOR data_bags/users/bofh.json\n\nPaste the user's public SSH key into the ssh_keys value. Also make sure the uid is unique, and if you're not using bash, that the shell is installed. Group must be sysadmin.\n\nThe recipe will also create the sysadmin group. If you're using the opscode sudo cookbook, they'll have sudo access in the default site-cookbooks template. They won't have passwords though, so the sudo cookbook's template needs to be adjusted so the sysadmin group has NOPASSWD.\n\nThe sysadmin group will be created with GID 2300. This may become an attribute at a later date.\n\nThe Apache cookbook can set up authentication using OpenIDs, which is set up using the openid key here. See the Opscode 'apache2' cookbook for more information about this.\n\nLicense and Author\n==================\n\nAuthor:: Joshua Timberman (<joshua@opscode.com>)\nAuthor:: Seth Chisamore (<schisamo@opscode.com>)\n\nCopyright:: 2009-2011, Opscode, Inc\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n",
"maintainer": "Opscode, Inc.",
"maintainer_email": "cookbooks@opscode.com",
"license": "Apache 2.0",
"platforms": {
+ "ubuntu": ">= 0.0.0",
+ "debian": ">= 0.0.0",
+ "redhat": ">= 0.0.0",
+ "centos": ">= 0.0.0",
+ "fedora": ">= 0.0.0",
+ "freebsd": ">= 0.0.0"
},
"dependencies": {
},
@@ -26,5 +32,5 @@
"recipes": {
"users::sysadmin": "searches users data bag for sysadmins and creates users"
},
- "version": "0.3.1"
+ "version": "1.0.0"
}
View
@@ -2,6 +2,10 @@
maintainer_email "cookbooks@opscode.com"
license "Apache 2.0"
description "Creates users from a databag search"
-long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc'))
-version "0.3.1"
+long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
+version "1.0.0"
recipe "users::sysadmin", "searches users data bag for sysadmins and creates users"
+
+%w{ ubuntu debian redhat centos fedora freebsd}.each do |os|
+ supports os
+end
View
@@ -2,7 +2,7 @@
# Cookbook Name:: users
# Recipe:: sysadmins
#
-# Copyright 2009, Opscode, Inc.
+# Copyright 2009-2011, Opscode, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+
sysadmin_group = Array.new
search(:users, 'groups:sysadmin') do |u|
@@ -29,13 +30,22 @@
home_dir = "/home/#{u['id']}"
+ # fixes CHEF-1699
+ ruby_block "reset group list" do
+ block do
+ Etc.endgrent
+ end
+ action :nothing
+ end
+
user u['id'] do
uid u['uid']
gid u['gid']
shell u['shell']
comment u['comment']
supports :manage_home => true
home home_dir
+ notifies :create, "ruby_block[reset group list]", :immediately
end
directory "#{home_dir}/.ssh" do

0 comments on commit bf33af7

Please sign in to comment.