solokit 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. data/README.markdown +29 -0
  2. data/chef/roles/base.json +13 -0
  3. data/chef/server.json +5 -0
  4. data/chef/solo.rb +6 -0
  5. data/cookbooks/site/users/definitions/add_keys.rb +45 -0
  6. data/cookbooks/site/users/recipes/default.rb +34 -0
  7. data/cookbooks/upstream/apt/files/default/apt-cacher +9 -0
  8. data/cookbooks/upstream/apt/files/default/apt-cacher.conf +144 -0
  9. data/cookbooks/upstream/apt/files/default/apt-proxy-v2.conf +50 -0
  10. data/cookbooks/upstream/apt/metadata.json +51 -0
  11. data/cookbooks/upstream/apt/metadata.rb +11 -0
  12. data/cookbooks/upstream/apt/recipes/cacher.rb +42 -0
  13. data/cookbooks/upstream/apt/recipes/default.rb +33 -0
  14. data/cookbooks/upstream/apt/recipes/proxy.rb +34 -0
  15. data/cookbooks/upstream/ruby-shadow/attributes/ruby-shadow.rb +1 -0
  16. data/cookbooks/upstream/ruby-shadow/files/default/shadow-1.4.1/HISTORY +34 -0
  17. data/cookbooks/upstream/ruby-shadow/files/default/shadow-1.4.1/MANIFEST +7 -0
  18. data/cookbooks/upstream/ruby-shadow/files/default/shadow-1.4.1/README +79 -0
  19. data/cookbooks/upstream/ruby-shadow/files/default/shadow-1.4.1/README.euc +80 -0
  20. data/cookbooks/upstream/ruby-shadow/files/default/shadow-1.4.1/depend +1 -0
  21. data/cookbooks/upstream/ruby-shadow/files/default/shadow-1.4.1/extconf.rb +26 -0
  22. data/cookbooks/upstream/ruby-shadow/files/default/shadow-1.4.1/shadow.c +281 -0
  23. data/cookbooks/upstream/ruby-shadow/recipes/default.rb +15 -0
  24. data/cookbooks/upstream/sudo/attributes/sudoers.rb +21 -0
  25. data/cookbooks/upstream/sudo/metadata.json +96 -0
  26. data/cookbooks/upstream/sudo/metadata.rb +31 -0
  27. data/cookbooks/upstream/sudo/recipes/default.rb +33 -0
  28. data/cookbooks/upstream/sudo/templates/default/sudoers.erb +22 -0
  29. data/cookbooks/upstream/users/attributes/default.rb +4 -0
  30. data/cookbooks/upstream/users/definitions/add_keys.rb +38 -0
  31. data/cookbooks/upstream/users/libraries/roles.rb +17 -0
  32. data/cookbooks/upstream/users/metadata.json +38 -0
  33. data/cookbooks/upstream/users/metadata.rb +4 -0
  34. data/cookbooks/upstream/users/recipes/default.rb +17 -0
  35. data/cookbooks/upstream/users/templates/default/authorized_keys.erb +5 -0
  36. data/lib/chef.rb +11 -10
  37. data/lib/solokit/version.rb +1 -1
  38. metadata +38 -4
  39. data/README +0 -1
@@ -0,0 +1,80 @@
1
+ Shadow Password module
2
+
3
+ Copyright (C) 1998-1999 Takaaki Tateishi <ttate@jaist.ac.jp>
4
+ Modified at: <1999/8/19 06:48:01 by ttate>
5
+ License: Free for any use with your own risk!
6
+
7
+
8
+ 1. ����
9
+
10
+ linux�ˤ�����shadow password�ե�����򰷤�����
11
+ �Υ⥸�塼�롣
12
+
13
+
14
+ 2. ���󥹥ȡ���
15
+
16
+ ruby extconf.rb
17
+ make
18
+ make install
19
+
20
+ * ����
21
+ shadow-1.3�Ǥ�ruby-1.3�⤷���Ϥ���ʹߤΥС������
22
+ ��ɬ�פǤ���
23
+
24
+ 3. Shadow::Passwd�⥸�塼��Υ᥽�å�ã
25
+
26
+ getspent
27
+ getspnam(name)
28
+ setspent
29
+ endspent
30
+ fgetspent(file)
31
+ sgetspent(str)
32
+ putspent(entry,file)
33
+ lckpwdf,lock
34
+ ulckpwdf,unlock
35
+ lock?
36
+
37
+ 4. Structure
38
+
39
+ Shadow::Passwd::Entry (Struct::PasswdEntry)
40
+ sp_namp - pointer to null-terminated user name.
41
+ sp_pwdp - pointer to null-terminated password.
42
+ sp_lstchg - days since Jan 1, 1970 password was last
43
+ changed.
44
+ sp_min - days before which password may not be changed.
45
+ sp_max - days after which password must be changed.
46
+ sp_warn - days before password is to expire that user is
47
+ warned of pending password expiration.
48
+ sp_inact - days after password expires that account is
49
+ considered inactive and disabled.
50
+ sp_expire - days since Jan 1, 1970 when account will be
51
+
52
+
53
+ 5. ����
54
+
55
+ getspent, getspname, fgetspent, sgetspent��Shadow::Passwd::Entry
56
+ ���ȥ饯������֤��ޤ���getspent �ϥե����뤫�鼡�Υѥ���
57
+ ���ɥ���ȥ���֤���fgetspent ��Ϳ����줿IO���鼡�Υ����
58
+ ����֤��ޤ���sgetspent��Ϳ����줿ʸ���󤫤�Shadow::Passwd::Entry
59
+ ���ȥ饯������֤��ޤ���getspnam�ϥ桼��̾��Ϳ�����/etc/shadow
60
+ ���餽�Υ桼����Shadow::Passwd::Entry���ȥ饯������֤��ޤ���
61
+ �ե�����ν�ü��ã�����nil���ͤ��֤��ޤ���
62
+
63
+ setspent,endspent�Ϥ��줾�졢�ե�����ؤΥ��������ΤϤ����
64
+ �����˻Ȥ��ޤ���
65
+
66
+ lckpwdf(lock),ulckpwdf(unlock)��/etc/shadow�ؤ���¾Ū��������
67
+ ��¸����뤿��ˤ���ޤ���
68
+ lock�˼��Ԥ����Shadow::FileLock�Ȥ����㳰��ȯ�������ޤ���
69
+ lock�򥤥ƥ졼���Ȥ��ƻȤ����Ȥˤ�äơ����ƥ졼���֥��å���ȴ����
70
+ �Ȥ��˼�ưŪ��unlock��Ԥʤ��ޤ���
71
+
72
+
73
+ 6. ����
74
+
75
+ * man shadow
76
+ * /usr/include/shadow.h
77
+
78
+
79
+
80
+ ttate@jaist.ac.jp
@@ -0,0 +1 @@
1
+ shadow.o : shadow.c $(hdrdir)/ruby.h $(hdrdir)/rubyio.h
@@ -0,0 +1,26 @@
1
+ # -*- ruby -*-
2
+ # extconf.rb
3
+ #
4
+ # Modified at: <1999/8/19 06:38:55 by ttate>
5
+ #
6
+
7
+ require 'mkmf'
8
+
9
+ $CFLAGS = ""
10
+ $LDFLAGS = "-lshadow"
11
+
12
+ if( ! (ok = have_library("shadow","getspent")) )
13
+ $LDFLAGS = ""
14
+ ok = have_func("getspent")
15
+ end
16
+
17
+ ok &= have_func("sgetspent")
18
+ ok &= have_func("fgetspent")
19
+ ok &= have_func("setspent")
20
+ ok &= have_func("endspent")
21
+ ok &= have_func("lckpwdf")
22
+ ok &= have_func("ulckpwdf")
23
+
24
+ if ok
25
+ create_makefile("shadow")
26
+ end
@@ -0,0 +1,281 @@
1
+ /*
2
+ * shadow.c
3
+ *
4
+ * Ruby extention module for using Linux shadow password.
5
+ *
6
+ * Copyright (C) 1998-1999 by Takaaki.Tateishi(ttate@jaist.ac.jp)
7
+ * License: Free for any use with your own risk!
8
+ * Modified at: <1999/8/19 06:48:18 by ttate>
9
+ */
10
+
11
+ #include <shadow.h>
12
+ #include "ruby.h"
13
+ #include "rubyio.h"
14
+
15
+ static VALUE rb_mShadow;
16
+ static VALUE rb_mPasswd;
17
+ static VALUE rb_sPasswdEntry;
18
+ static VALUE rb_mGroup;
19
+ static VALUE rb_sGroupEntry;
20
+ static VALUE rb_eFileLock;
21
+
22
+
23
+ static VALUE
24
+ rb_shadow_setspent(VALUE self)
25
+ {
26
+ setspent();
27
+ return Qnil;
28
+ };
29
+
30
+
31
+ static VALUE
32
+ rb_shadow_endspent(VALUE self)
33
+ {
34
+ endspent();
35
+ return Qnil;
36
+ };
37
+
38
+
39
+ static VALUE
40
+ rb_shadow_sgetspent(VALUE self, VALUE str)
41
+ {
42
+ struct spwd *entry;
43
+ VALUE result;
44
+
45
+ if( TYPE(str) != T_STRING )
46
+ rb_raise(rb_eException,"argument must be a string.");
47
+
48
+ entry = sgetspent(STR2CSTR(str));
49
+
50
+ if( entry == NULL )
51
+ return Qnil;
52
+
53
+ result = rb_struct_new(rb_sPasswdEntry,
54
+ rb_tainted_str_new2(entry->sp_namp),
55
+ rb_tainted_str_new2(entry->sp_pwdp),
56
+ INT2FIX(entry->sp_lstchg),
57
+ INT2FIX(entry->sp_min),
58
+ INT2FIX(entry->sp_max),
59
+ INT2FIX(entry->sp_warn),
60
+ INT2FIX(entry->sp_inact),
61
+ INT2FIX(entry->sp_expire),
62
+ INT2FIX(entry->sp_flag),
63
+ 0);
64
+ free(entry);
65
+ return result;
66
+ };
67
+
68
+ static VALUE
69
+ rb_shadow_fgetspent(VALUE self, VALUE file)
70
+ {
71
+ struct spwd *entry;
72
+ VALUE result;
73
+
74
+ if( TYPE(file) != T_FILE )
75
+ rb_raise(rb_eTypeError,"argument must be a File.");
76
+
77
+ entry = fgetspent((RFILE(file)->fptr)->f);
78
+
79
+ if( entry == NULL )
80
+ return Qnil;
81
+
82
+ result = rb_struct_new(rb_sPasswdEntry,
83
+ rb_tainted_str_new2(entry->sp_namp),
84
+ rb_tainted_str_new2(entry->sp_pwdp),
85
+ INT2FIX(entry->sp_lstchg),
86
+ INT2FIX(entry->sp_min),
87
+ INT2FIX(entry->sp_max),
88
+ INT2FIX(entry->sp_warn),
89
+ INT2FIX(entry->sp_inact),
90
+ INT2FIX(entry->sp_expire),
91
+ INT2FIX(entry->sp_flag),
92
+ 0);
93
+ return result;
94
+ };
95
+
96
+ static VALUE
97
+ rb_shadow_getspent(VALUE self)
98
+ {
99
+ struct spwd *entry;
100
+ VALUE result;
101
+
102
+ entry = getspent();
103
+
104
+ if( entry == NULL )
105
+ return Qnil;
106
+
107
+ result = rb_struct_new(rb_sPasswdEntry,
108
+ rb_tainted_str_new2(entry->sp_namp),
109
+ rb_tainted_str_new2(entry->sp_pwdp),
110
+ INT2FIX(entry->sp_lstchg),
111
+ INT2FIX(entry->sp_min),
112
+ INT2FIX(entry->sp_max),
113
+ INT2FIX(entry->sp_warn),
114
+ INT2FIX(entry->sp_inact),
115
+ INT2FIX(entry->sp_expire),
116
+ INT2FIX(entry->sp_flag),
117
+ 0);
118
+ return result;
119
+ };
120
+
121
+ static VALUE
122
+ rb_shadow_getspnam(VALUE self, VALUE name)
123
+ {
124
+ struct spwd *entry;
125
+ VALUE result;
126
+
127
+ if( TYPE(name) != T_STRING )
128
+ rb_raise(rb_eException,"argument must be a string.");
129
+
130
+ entry = getspnam(STR2CSTR(name));
131
+
132
+ if( entry == NULL )
133
+ return Qnil;
134
+
135
+ result = rb_struct_new(rb_sPasswdEntry,
136
+ rb_tainted_str_new2(entry->sp_namp),
137
+ rb_tainted_str_new2(entry->sp_pwdp),
138
+ INT2FIX(entry->sp_lstchg),
139
+ INT2FIX(entry->sp_min),
140
+ INT2FIX(entry->sp_max),
141
+ INT2FIX(entry->sp_warn),
142
+ INT2FIX(entry->sp_inact),
143
+ INT2FIX(entry->sp_expire),
144
+ INT2FIX(entry->sp_flag),
145
+ 0);
146
+ return result;
147
+ };
148
+
149
+
150
+ static VALUE
151
+ rb_shadow_putspent(VALUE self, VALUE entry, VALUE file)
152
+ {
153
+ struct spwd centry;
154
+ FILE* cfile;
155
+ VALUE val[9];
156
+ int i;
157
+ int result;
158
+
159
+ for(i=0; i<=8; i++)
160
+ val[i] = RSTRUCT(entry)->ptr[i];
161
+ cfile = RFILE(file)->fptr->f;
162
+
163
+ centry.sp_namp = STR2CSTR(val[0]);
164
+ centry.sp_pwdp = STR2CSTR(val[1]);
165
+ centry.sp_lstchg = FIX2INT(val[2]);
166
+ centry.sp_min = FIX2INT(val[3]);
167
+ centry.sp_max = FIX2INT(val[4]);
168
+ centry.sp_warn = FIX2INT(val[5]);
169
+ centry.sp_inact = FIX2INT(val[6]);
170
+ centry.sp_expire = FIX2INT(val[7]);
171
+ centry.sp_flag = FIX2INT(val[8]);
172
+
173
+ result = putspent(&centry,cfile);
174
+
175
+ if( result == -1 )
176
+ rb_raise(rb_eStandardError,"can't change password");
177
+
178
+ return Qtrue;
179
+ };
180
+
181
+
182
+ static VALUE
183
+ rb_shadow_lckpwdf(VALUE self)
184
+ {
185
+ int result;
186
+ result = lckpwdf();
187
+ if( result == -1 )
188
+ rb_raise(rb_eFileLock,"password file was locked");
189
+ else
190
+ return Qtrue;
191
+ };
192
+
193
+ static int in_lock;
194
+
195
+ static VALUE
196
+ rb_shadow_lock(VALUE self)
197
+ {
198
+ int result;
199
+
200
+ if( rb_iterator_p() ){
201
+ result = lckpwdf();
202
+ if( result == -1 ){
203
+ rb_raise(rb_eFileLock,"password file was locked");
204
+ }
205
+ else{
206
+ in_lock++;
207
+ rb_yield(Qnil);
208
+ in_lock--;
209
+ ulckpwdf();
210
+ };
211
+ return Qtrue;
212
+ }
213
+ else{
214
+ return rb_shadow_lckpwdf(self);
215
+ };
216
+ };
217
+
218
+
219
+ static VALUE
220
+ rb_shadow_ulckpwdf(VALUE self)
221
+ {
222
+ if( in_lock ){
223
+ rb_raise(rb_eFileLock,"you call unlock method in lock iterator.");
224
+ };
225
+ ulckpwdf();
226
+ return Qtrue;
227
+ };
228
+
229
+ static VALUE
230
+ rb_shadow_unlock(VALUE self)
231
+ {
232
+ return rb_shadow_ulckpwdf(self);
233
+ };
234
+
235
+ static VALUE
236
+ rb_shadow_lock_p(VALUE self)
237
+ {
238
+ int result;
239
+
240
+ result = lckpwdf();
241
+ if( result == -1 ){
242
+ return Qtrue;
243
+ }
244
+ else{
245
+ ulckpwdf();
246
+ return Qfalse;
247
+ };
248
+ };
249
+
250
+
251
+ void
252
+ Init_shadow()
253
+ {
254
+ rb_sPasswdEntry = rb_struct_define("PasswdEntry",
255
+ "sp_namp","sp_pwdp","sp_lstchg",
256
+ "sp_min","sp_max","sp_warn",
257
+ "sp_inact","sp_expire","sp_flag",0);
258
+ rb_sGroupEntry = rb_struct_define("GroupEntry",
259
+ "sg_name","sg_passwd",
260
+ "sg_adm","sg_mem",0);
261
+
262
+ rb_mShadow = rb_define_module("Shadow");
263
+ rb_eFileLock = rb_define_class_under(rb_mShadow,"FileLock",rb_eException);
264
+ rb_mPasswd = rb_define_module_under(rb_mShadow,"Passwd");
265
+ rb_define_const(rb_mPasswd,"Entry",rb_sPasswdEntry);
266
+ rb_mGroup = rb_define_module_under(rb_mShadow,"Group");
267
+ rb_define_const(rb_mGroup,"Entry",rb_sGroupEntry);
268
+
269
+ rb_define_module_function(rb_mPasswd,"setspent",rb_shadow_setspent,0);
270
+ rb_define_module_function(rb_mPasswd,"endspent",rb_shadow_endspent,0);
271
+ rb_define_module_function(rb_mPasswd,"sgetspent",rb_shadow_sgetspent,1);
272
+ rb_define_module_function(rb_mPasswd,"fgetspent",rb_shadow_fgetspent,1);
273
+ rb_define_module_function(rb_mPasswd,"getspent",rb_shadow_getspent,0);
274
+ rb_define_module_function(rb_mPasswd,"getspnam",rb_shadow_getspnam,1);
275
+ rb_define_module_function(rb_mPasswd,"putspent",rb_shadow_putspent,2);
276
+ rb_define_module_function(rb_mPasswd,"lckpwdf",rb_shadow_lckpwdf,0);
277
+ rb_define_module_function(rb_mPasswd,"lock",rb_shadow_lock,0);
278
+ rb_define_module_function(rb_mPasswd,"ulckpwdf",rb_shadow_ulckpwdf,0);
279
+ rb_define_module_function(rb_mPasswd,"unlock",rb_shadow_unlock,0);
280
+ rb_define_module_function(rb_mPasswd,"lock?",rb_shadow_lock_p,0);
281
+ };
@@ -0,0 +1,15 @@
1
+ remote_directory "/usr/local/src/shadow-1.4.1" do
2
+ source 'shadow-1.4.1'
3
+ not_if { File.exists?(File.join(node[:ruby_shadow][:site_ruby], "#{node[:languages][:ruby][:platform]}/shadow.so")) }
4
+ end
5
+
6
+ bash "install ruby shadow library" do
7
+ user "root"
8
+ cwd "/usr/local/src"
9
+ code <<-EOH
10
+ cd shadow-1.4.1
11
+ ruby extconf.rb
12
+ make install
13
+ EOH
14
+ not_if { File.exists?(File.join(node[:ruby_shadow][:site_ruby], "/#{node[:languages][:ruby][:platform]}/shadow.so")) }
15
+ end
@@ -0,0 +1,21 @@
1
+ #
2
+ # Cookbook Name:: sudo
3
+ # Attribute File:: sudoers
4
+ #
5
+ # Copyright 2008-2009, Opscode, Inc.
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+
20
+ set_unless[:authorization][:sudo][:groups] = Array.new
21
+ set_unless[:authorization][:sudo][:users] = Array.new
@@ -0,0 +1,96 @@
1
+ {
2
+ "maintainer": "Opscode, Inc.",
3
+ "description": "Installs and configures sudo",
4
+ "recommendations": {
5
+
6
+ },
7
+ "maintainer_email": "cookbooks@opscode.com",
8
+ "recipes": {
9
+ "sudo": ""
10
+ },
11
+ "suggestions": {
12
+
13
+ },
14
+ "platforms": {
15
+ "freebsd": [
16
+
17
+ ],
18
+ "ubuntu": [
19
+
20
+ ],
21
+ "fedora": [
22
+
23
+ ],
24
+ "centos": [
25
+
26
+ ],
27
+ "debian": [
28
+
29
+ ],
30
+ "redhat": [
31
+
32
+ ]
33
+ },
34
+ "version": "0.7.0",
35
+ "name": "sudo",
36
+ "conflicting": {
37
+
38
+ },
39
+ "attributes": {
40
+ "authorization\/sudoers\/groups": {
41
+ "default": "",
42
+ "type": "array",
43
+ "multiple_values": false,
44
+ "description": "Groups who are allowed sudo ALL",
45
+ "display_name": "Sudo Groups",
46
+ "recipes": [
47
+
48
+ ],
49
+ "required": false
50
+ },
51
+ "authorization\/sudoers\/users": {
52
+ "default": "",
53
+ "type": "array",
54
+ "multiple_values": false,
55
+ "description": "Users who are allowed sudo ALL",
56
+ "display_name": "Sudo Users",
57
+ "recipes": [
58
+
59
+ ],
60
+ "required": false
61
+ },
62
+ "authorization\/sudoers": {
63
+ "type": "hash",
64
+ "multiple_values": false,
65
+ "description": "Hash of Authorization\/Sudoers attributes",
66
+ "display_name": "Authorization Sudoers",
67
+ "recipes": [
68
+
69
+ ],
70
+ "required": false
71
+ },
72
+ "authorization": {
73
+ "type": "hash",
74
+ "multiple_values": false,
75
+ "description": "Hash of Authorization attributes",
76
+ "display_name": "Authorization",
77
+ "recipes": [
78
+
79
+ ],
80
+ "required": false
81
+ }
82
+ },
83
+ "providing": {
84
+ "sudo": [
85
+
86
+ ]
87
+ },
88
+ "license": "Apache 2.0",
89
+ "long_description": "",
90
+ "replacing": {
91
+
92
+ },
93
+ "dependencies": {
94
+
95
+ }
96
+ }
@@ -0,0 +1,31 @@
1
+ maintainer "Opscode, Inc."
2
+ maintainer_email "cookbooks@opscode.com"
3
+ license "Apache 2.0"
4
+ description "Installs and configures sudo"
5
+ version "0.7"
6
+
7
+ %w{redhat centos fedora ubuntu debian freebsd}.each do |os|
8
+ supports os
9
+ end
10
+
11
+ attribute "authorization",
12
+ :display_name => "Authorization",
13
+ :description => "Hash of Authorization attributes",
14
+ :type => "hash"
15
+
16
+ attribute "authorization/sudoers",
17
+ :display_name => "Authorization Sudoers",
18
+ :description => "Hash of Authorization/Sudoers attributes",
19
+ :type => "hash"
20
+
21
+ attribute "authorization/sudoers/users",
22
+ :display_name => "Sudo Users",
23
+ :description => "Users who are allowed sudo ALL",
24
+ :type => "array",
25
+ :default => ""
26
+
27
+ attribute "authorization/sudoers/groups",
28
+ :display_name => "Sudo Groups",
29
+ :description => "Groups who are allowed sudo ALL",
30
+ :type => "array",
31
+ :default => ""
@@ -0,0 +1,33 @@
1
+ #
2
+ # Cookbook Name:: sudo
3
+ # Recipe:: default
4
+ #
5
+ # Copyright 2008-2009, Opscode, Inc.
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+
20
+ package "sudo" do
21
+ action :upgrade
22
+ end
23
+
24
+ template "/etc/sudoers" do
25
+ source "sudoers.erb"
26
+ mode 0440
27
+ owner "root"
28
+ group "root"
29
+ variables(
30
+ :sudoers_groups => node[:authorization][:sudo][:groups],
31
+ :sudoers_users => node[:authorization][:sudo][:users]
32
+ )
33
+ end
@@ -0,0 +1,22 @@
1
+ #
2
+ # /etc/sudoers
3
+ #
4
+ # Generated by Chef for <%= @node[:fqdn] %>
5
+ #
6
+
7
+ Defaults !lecture,tty_tickets,!fqdn
8
+
9
+ # User privilege specification
10
+ root ALL=(ALL) ALL
11
+
12
+ <% @sudoers_users.each do |user| -%>
13
+ <%= user %> ALL=(ALL) ALL
14
+ <% end -%>
15
+
16
+ # Members of the sysadmin group may gain root privileges
17
+ %sysadmin ALL=(ALL) ALL
18
+
19
+ <% @sudoers_groups.each do |group| -%>
20
+ # Members of the group '<%= group %>' may gain root privileges
21
+ %<%= group %> ALL=(ALL) ALL
22
+ <% end -%>
@@ -0,0 +1,4 @@
1
+ users Mash.new unless attribute?("users")
2
+
3
+ # passwords must be in shadow password format with a salt. To generate: openssl passwd -1
4
+ # users[:jose] = {:password => "shadowpass", :comment => "José Amador", :ssh_key => "..." }
@@ -0,0 +1,38 @@
1
+ define :add_keys, :conf => {} do
2
+ config = params[:conf]
3
+ name = params[:name]
4
+ keys = Mash.new
5
+ keys[name] = node[:ssh_keys][name]
6
+
7
+ if config[:ssh_key_groups]
8
+ config[:ssh_key_groups].each do |group|
9
+ node[:users].find_all { |u| u.last[:groups].include?(group) }.each do |user|
10
+ keys[user.first] = node[:ssh_keys][user.first]
11
+ end
12
+ end
13
+ end
14
+
15
+ if config[:extra_ssh_keys]
16
+ config[:extra_ssh_keys].each do |username|
17
+ keys[username] = node[:ssh_keys][username]
18
+ end
19
+ end
20
+
21
+ directory "/home/#{name}/.ssh" do
22
+ action :create
23
+ owner name
24
+ group config[:groups] ? config[:groups].first.to_s : name
25
+ mode 0755
26
+ not_if { File.exists? "/home/#{name}/.ssh" }
27
+ end
28
+
29
+ template "/home/#{name}/.ssh/authorized_keys" do
30
+ source "authorized_keys.erb"
31
+ action :create
32
+ owner name
33
+ group config[:groups] ? config[:groups].first.to_s : name
34
+ variables(:keys => keys)
35
+ mode 0600
36
+ not_if { defined?(node[:users][name][:preserve_keys]) ? node[:users][name][:preserve_keys] : false }
37
+ end
38
+ end
@@ -0,0 +1,17 @@
1
+ def user_is_in_role?(username)
2
+ return false if !@node[:role]
3
+ Chef::Log.info role[:groups].inspect
4
+ role[:groups].include? get_user(username)[:group]
5
+ end
6
+
7
+ def role
8
+ @node[:roles][@node[:role]]
9
+ end
10
+
11
+ # method name 'user' conflicts with chef, so we use 'get_user'
12
+ def get_user(username)
13
+ Chef::Log.info username
14
+ user = @node[:users][username]
15
+ Chef::Log.info user.inspect
16
+ user
17
+ end