from-scratch 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/Berksfile +1 -7
  3. data/Berksfile.lock +6 -0
  4. data/README.md +8 -3
  5. data/bin/scratchify +1 -1
  6. data/cookbooks/ruby_build/CHANGELOG.md +72 -0
  7. data/cookbooks/ruby_build/README.md +338 -0
  8. data/cookbooks/ruby_build/attributes/default.rb +67 -0
  9. data/cookbooks/ruby_build/libraries/ruby_build_recipe_helpers.rb +40 -0
  10. data/cookbooks/ruby_build/metadata.json +39 -0
  11. data/cookbooks/ruby_build/providers/ruby.rb +88 -0
  12. data/cookbooks/ruby_build/recipes/default.rb +69 -0
  13. data/cookbooks/ruby_build/resources/ruby.rb +33 -0
  14. data/cookbooks/ruby_rbenv/CHANGELOG.md +221 -0
  15. data/cookbooks/ruby_rbenv/README.md +1059 -0
  16. data/cookbooks/ruby_rbenv/attributes/default.rb +73 -0
  17. data/cookbooks/ruby_rbenv/libraries/chef_provider_package_rbenvrubygems.rb +94 -0
  18. data/cookbooks/ruby_rbenv/libraries/chef_rbenv_mixin.rb +49 -0
  19. data/cookbooks/ruby_rbenv/libraries/chef_rbenv_recipe_helpers.rb +118 -0
  20. data/cookbooks/ruby_rbenv/libraries/chef_rbenv_script_helpers.rb +79 -0
  21. data/cookbooks/ruby_rbenv/libraries/matchers.rb +25 -0
  22. data/cookbooks/ruby_rbenv/metadata.json +1 -0
  23. data/cookbooks/ruby_rbenv/providers/global.rb +53 -0
  24. data/cookbooks/ruby_rbenv/providers/plugin.rb +55 -0
  25. data/cookbooks/ruby_rbenv/providers/rehash.rb +45 -0
  26. data/cookbooks/ruby_rbenv/providers/ruby.rb +123 -0
  27. data/cookbooks/ruby_rbenv/providers/script.rb +81 -0
  28. data/cookbooks/ruby_rbenv/recipes/default.rb +23 -0
  29. data/cookbooks/ruby_rbenv/recipes/system.rb +52 -0
  30. data/cookbooks/ruby_rbenv/recipes/system_install.rb +45 -0
  31. data/cookbooks/ruby_rbenv/recipes/user.rb +76 -0
  32. data/cookbooks/ruby_rbenv/recipes/user_install.rb +48 -0
  33. data/cookbooks/ruby_rbenv/resources/gem.rb +44 -0
  34. data/cookbooks/ruby_rbenv/resources/global.rb +33 -0
  35. data/cookbooks/ruby_rbenv/resources/plugin.rb +15 -0
  36. data/cookbooks/ruby_rbenv/resources/rehash.rb +29 -0
  37. data/cookbooks/ruby_rbenv/resources/ruby.rb +43 -0
  38. data/cookbooks/ruby_rbenv/resources/script.rb +39 -0
  39. data/cookbooks/ruby_rbenv/templates/default/rbenv.sh.erb +15 -0
  40. data/cookbooks/scratchify/Berksfile +1 -7
  41. data/cookbooks/scratchify/Berksfile.lock +6 -0
  42. data/cookbooks/scratchify/README.md +8 -3
  43. data/cookbooks/scratchify/bin/scratchify +1 -1
  44. data/cookbooks/scratchify/from-scratch.gemspec +1 -0
  45. data/cookbooks/scratchify/lib/from-scratch.rb +51 -9
  46. data/cookbooks/scratchify/lib/from-scratch/version.rb +2 -2
  47. data/cookbooks/scratchify/metadata.json +2 -1
  48. data/cookbooks/scratchify/spec/from/scratch_spec.rb +62 -5
  49. data/cookbooks/scratchify/spec/spec_helper.rb +8 -1
  50. data/cookbooks/scratchify/templates/node.json.erb +28 -7
  51. data/cookbooks/scratchify/templates/user.json.erb +1 -1
  52. data/from-scratch.gemspec +1 -0
  53. data/lib/from-scratch.rb +51 -9
  54. data/lib/from-scratch/version.rb +2 -2
  55. data/metadata.rb +1 -0
  56. data/templates/node.json.erb +28 -7
  57. data/templates/user.json.erb +1 -1
  58. metadata +50 -3
@@ -0,0 +1,1059 @@
1
+ # <a name="title"></a> ruby_rbenv Chef Cookbook
2
+
3
+ [![Build Status](https://travis-ci.org/chef-rbenv/ruby_rbenv.svg?branch=master)](https://travis-ci.org/chef-rbenv/ruby_rbenv)
4
+ [![Cookbook Version](https://img.shields.io/cookbook/v/ruby_rbenv.svg)](https://supermarket.chef.io/cookbooks/ruby_rbenv)
5
+
6
+ ## <a name="description"></a> Description
7
+
8
+ Manages [rbenv][rbenv_site] and its installed Rubies.
9
+ Several lightweight resources and providers ([LWRPs][lwrp]) are also defined.
10
+
11
+ **WARNING**: As of version 1.0 this cookbook was renamed from rbenv to ruby_rbenv so it could be uploaded to the Supermarket. Attributes and resources (LWRPs) retain the rbenv namespace for compatibility, but if you wrap this cookbook you'll need to update the recipes you include. Use 0.9.0 if you need the existing name.
12
+
13
+ ## <a name="requirements"></a> Requirements
14
+
15
+ ### <a name="requirements-chef"></a> Chef
16
+
17
+ This cookbook requires Chef 12.1+.
18
+
19
+ ### <a name="requirements-platform"></a> Platform
20
+
21
+ The following platforms have been tested with this cookbook, meaning that
22
+ the recipes and LWRPs run on these platforms without error:
23
+
24
+ * Arch
25
+ * Debian derivitives (Debian 7+, Ubuntu 10.04+, Linux Mint)
26
+ * Freebsd
27
+ * Fedora
28
+ * Gentoo
29
+ * Mac OS X
30
+ * RHEL deritivites (RHEL, CentOS, Amazon Linux, Oracle, Scientific Linux)
31
+
32
+ Please [report][issues] any additional platforms so they can be added.
33
+
34
+ ### <a name="requirements-cookbooks"></a> Cookbooks
35
+
36
+ * [ruby\_build cookbook][ruby_build_cb]
37
+ * java cookbook if installing jruby (recommended, but not required in the metadata)
38
+
39
+ ## <a name="usage"></a> Usage
40
+
41
+ ### <a name="usage-system-rubies"></a> rbenv Installed System-Wide with Rubies
42
+
43
+ Most likely, this is the typical case. Include `recipe[ruby_rbenv::system]` in your
44
+ run\_list and override the defaults you want changed. See [below](#attributes)
45
+ for more details.
46
+
47
+ If your platform is the Mac, you may need to modify your
48
+ [profile](#mac-system-note).
49
+
50
+ ### <a name="usage-user-rubies"></a> rbenv Installed For A Specific User with Rubies
51
+
52
+ If you want a per-user install (like on a Mac/Linux workstation for
53
+ development, CI, etc.), include `recipe[ruby_rbenv::user]` in your run\_list and
54
+ add a user hash to the `user_installs` attribute list. For example:
55
+
56
+ node.default['rbenv']['user_installs'] = [
57
+ { 'user' => 'tflowers',
58
+ 'rubies' => ['1.9.3-p0', 'jruby-1.6.5'],
59
+ 'global' => '1.9.3-p0',
60
+ 'gems' => {
61
+ '1.9.3-p0' => [
62
+ { 'name' => 'bundler',
63
+ 'version' => '1.1.rc.5'
64
+ },
65
+ { 'name' => 'rake' }
66
+ ],
67
+ 'jruby-1.6.5' => [
68
+ { 'name' => 'rest-client' }
69
+ ]
70
+ }
71
+ }
72
+ ]
73
+
74
+ See [below](#attributes) for more details.
75
+
76
+ ### <a name="usage-system"></a> rbenv Installed System-Wide and LWRPs Defined
77
+
78
+ If you want to manage your own rbenv environment with the provided
79
+ LWRPs, then include `recipe[ruby_rbenv::system_install]` in your run\_list
80
+ to prevent a default rbenv Ruby being installed. See the
81
+ [Resources and Providers](#lwrps) section for more details.
82
+
83
+ If your platform is the Mac, you may need to modify your
84
+ [profile](#mac-system-note).
85
+
86
+ ### <a name="usage-user"></a> rbenv Installed For A Specific User and LWRPs Defined
87
+
88
+ If you want to manage your own rbenv environment for users with the provided
89
+ LWRPs, then include `recipe[ruby_rbenv::user_install]` in your run\_list and add a
90
+ user hash to the `user_installs` attribute list. For example:
91
+
92
+ node.default['rbenv']['user_installs'] = [
93
+ { 'user' => 'tflowers' }
94
+ ]
95
+
96
+ See the [Resources and Providers](#lwrps) section for more details.
97
+
98
+ ### <a name="usage-minimal"></a> Ultra-Minimal Access To LWRPs
99
+
100
+ Simply include `recipe[ruby_rbenv]` in your run\_list and the LWRPs will be
101
+ available to use in other cookbooks. See the [Resources and Providers](#lwrps)
102
+ section for more details.
103
+
104
+ ## <a name="recipes"></a> Recipes
105
+
106
+ ### <a name="recipes-default"></a> default
107
+
108
+ Installs the rbenv gem and initializes Chef to use the Lightweight Resources
109
+ and Providers ([LWRPs][lwrp]).
110
+
111
+ Use this recipe explicitly if you only want access to the LWRPs provided.
112
+
113
+ ### <a name="recipes-system-install"></a> system_install
114
+
115
+ Installs the rbenv codebase system-wide (that is, into `/usr/local/rbenv`). This
116
+ recipe includes *default*.
117
+
118
+ Use this recipe by itself if you want rbenv installed system-wide but want
119
+ to handle installing Rubies, invoking LWRPs, etc..
120
+
121
+ ### <a name="recipes-system"></a> system
122
+
123
+ Installs the rbenv codebase system-wide (that is, into `/usr/local/rbenv`) and
124
+ installs rubies driven off attribute metadata. This recipe includes *default*
125
+ and *system_install*.
126
+
127
+ Use this recipe by itself if you want rbenv installed system-wide with rubies
128
+ installed.
129
+
130
+ ### <a name="recipes-user-install"></a> user_install
131
+
132
+ Installs the rbenv codebase for a list of users (selected from the
133
+ `node['rbenv']['user_installs']` hash). This recipe includes *default*.
134
+
135
+ Use this recipe by itself if you want rbenv installed for specific users in
136
+ isolation but want each user to handle installing Rubies, invoking LWRPs, etc.
137
+
138
+ ### <a name="recipes-user"></a> user
139
+
140
+ Installs the rbenv codebase for a list of users (selected from the
141
+ `node['rbenv']['user_installs']` hash) and installs rubies driven off attribte
142
+ metadata. This recipe includes *default* and *user_install*.
143
+
144
+ Use this recipe by itself if you want rbenv installed for specific users in
145
+ isolation with rubies installed.
146
+
147
+ ## <a name="attributes"></a> Attributes
148
+
149
+ ### <a name="attributes-git-url"></a> git_url
150
+
151
+ The Git URL which is used to install rbenv.
152
+
153
+ The default is `"git://github.com/sstephenson/rbenv.git"`.
154
+
155
+ ### <a name="attributes-git-ref"></a> git_ref
156
+
157
+ A specific Git branch/tag/reference to use when installing rbenv. For
158
+ example, to pin rbenv to a specific release:
159
+
160
+ node.default['ruby_build']['git_ref'] = "v0.2.1"
161
+
162
+ The default is `"v0.4.0"`.
163
+
164
+ ### <a name="attributes-upgrade"></a> upgrade
165
+
166
+ Determines how to handle installing updates to the rbenv. There are currently
167
+ 2 valid values:
168
+
169
+ * `"none"`, `false`, or `nil`: will not update rbenv and leave it in its
170
+ current state.
171
+ * `"sync"` or `true`: updates rbenv to the version specified by the
172
+ `git_ref` attribute or the head of the master branch by default.
173
+
174
+ The default is `"none"`.
175
+
176
+ ### <a name="attributes-root-path"></a> root_path
177
+
178
+ The path prefix to rbenv in a system-wide installation.
179
+
180
+ The default is `"/usr/local/rbenv"`.
181
+
182
+ ### <a name="attributes-patch_url"></a> patch_url
183
+
184
+ A url to a patch file for your ruby install.
185
+
186
+ The default is `nil`.
187
+
188
+ ### <a name="attributes-patch_file"></a> patch_file
189
+
190
+ A path to a patch file for your ruby install.
191
+
192
+ The default is `nil`.
193
+
194
+ ### <a name="attributes-rubies"></a> rubies
195
+
196
+ A list of additional system-wide rubies to be built and installed using the
197
+ [ruby\_build cookbook][ruby_build_cb]. You **must** include `recipe[ruby_build]`
198
+ in your run\_list for the `rbenv_ruby` LWRP to work properly. For example:
199
+
200
+ node.default['rbenv']['rubies'] = [ "1.9.3-p0", "jruby-1.6.5" ]
201
+
202
+ The default is an empty array: `[]`.
203
+
204
+ Additional environment variables can be passed to ruby_build via the environment variable.
205
+ For example:
206
+
207
+ node.default['rbenv']['rubies'] = [ "1.9.3-p0", "jruby-1.6.5",
208
+ {
209
+ :name => '1.9.3-327',
210
+ :environment => { 'CFLAGS' => '-march=native -O2 -pipe' }
211
+ }
212
+ ]
213
+
214
+ ### <a name="attributes-plugins"></a> plugins
215
+
216
+ A list of plugins to be installed into the system (or user) install of rbenv.
217
+ Provide a hash of name and git_url for each plugin to be installed, with optional revision.
218
+
219
+ node.default['rbenv']['plugins'] = [
220
+ {
221
+ :name => "rbenv-vars",
222
+ :git_url => 'git://github.com/sstephenson/rbenv-vars.git'
223
+ },
224
+ {
225
+ :name => 'rbenv-update',
226
+ :git_url => 'git://github.com/rkh/rbenv-update.git',
227
+ :revision => 'master'
228
+ } ]
229
+
230
+ The same applies for user_installs.
231
+
232
+ ### <a name="attributes-user-rubies"></a> user_rubies
233
+
234
+ A list of additional system-wide rubies to be built and installed (using the
235
+ [ruby\_build cookbook][ruby_build_cb]) per-user when not explicitly set.
236
+ For example:
237
+
238
+ node.default['rbenv']['user_rubies'] = [ "1.8.7-p352" ]
239
+
240
+ The default is an empty array: `[]`.
241
+
242
+ Additional environment variables can be passed to ruby_build via the environment variable.
243
+ For example:
244
+
245
+ node.default['rbenv']['user_rubies'] = [ "1.8.7-p352",
246
+ {
247
+ :name => '1.9.3-327',
248
+ :environment => { 'CFLAGS' => '-march=native -O2 -pipe' }
249
+ }
250
+ ]
251
+ ### <a name="attributes-gems"></a> gems
252
+
253
+ A hash of gems to be installed into arbitrary rbenv-managed rubies system wide.
254
+ See the [rbenv_gem](#lwrps-rbgem) resource for more details about the options
255
+ for each gem hash and target Ruby environment. For example:
256
+
257
+ node.default['rbenv']['gems'] = {
258
+ '1.9.3-p0' => [
259
+ { 'name' => 'vagrant' },
260
+ { 'name' => 'bundler'
261
+ 'version' => '1.1.rc.5'
262
+ }
263
+ ],
264
+ '1.8.7-p352' => [
265
+ { 'name' => 'nokogiri' }
266
+ ]
267
+ }
268
+
269
+ The default is an empty hash: `{}`.
270
+
271
+ ### <a name="attributes-user-gems"></a> user_gems
272
+
273
+ A hash of gems to be installed into arbitrary rbenv-managed rubies for each user
274
+ when not explicitly set. See the [rbenv_gem](#lwrps-rbgem) resource for more
275
+ details about the options for each gem hash and target Ruby environment. See
276
+ the [gems attribute](#attributes-gems) for an example.
277
+
278
+ The default is an empty hash: `{}`.
279
+
280
+ ### <a name="attributes-plugins"></a> plugins
281
+
282
+ A list of plugins to be installed system-wide. See the [rbenv_plugin](#lwrps-plugin)
283
+ resource for details about the options.
284
+
285
+ node.default['rbenv']['plugins'] = [
286
+ { 'name' => 'rbenv-vars',
287
+ 'git_url' => 'https://github.com/sstephenson/rbenv-vars.git' },
288
+ { 'name' => 'rbenv-gem-rehash',
289
+ 'git_url' => 'https://github.com/sstephenson/rbenv-gem-rehash.git',
290
+ 'git_ref' => '4d7b92de4' }
291
+ ]
292
+
293
+ The default is an empty array: `[]`.
294
+
295
+ ### <a name="attributes-user-gems"></a> user_plugins
296
+
297
+ As with user_gems, a list of plugins to be installed for each user when not explicitly set.
298
+
299
+ The default is an empty array: `[]`.
300
+
301
+ ### <a name="attributes-vagrant-system-chef-solo"></a> vagrant/system_chef_solo
302
+
303
+ If using the `vagrant` recipe, this sets the path to the package-installed
304
+ *chef-solo* binary.
305
+
306
+ The default is `"/opt/ruby/bin/chef-solo"`.
307
+
308
+ ### <a name="attributes-create-profiled"></a> create_profiled
309
+
310
+ The user's shell needs to know about rbenv's location and set up the
311
+ PATH environment variable. This is handled in the
312
+ [system_install](#recipes-system_install) and
313
+ [user_install](#recipes-user_install) recipes by dropping off
314
+ `/etc/profile.d/rbenv.sh`. However, this requires root privilege,
315
+ which means that a user cannot use a "user install" for only their
316
+ user.
317
+
318
+ Set this attribute to `false` to skip creation of the
319
+ `/etc/profile.d/rbenv.sh` template. For example:
320
+
321
+ node.default['rbenv']['create_profiled'] = false
322
+
323
+ The default is `true`.
324
+
325
+ ## <a name="lwrps"></a> Resources and Providers
326
+
327
+ ### <a name="lwrps-rg"></a> rbenv_global
328
+
329
+ This resource sets the global version of Ruby to be used in all shells, as per
330
+ the [rbenv global docs][rbenv_3_1].
331
+
332
+ #### <a name="lwrps-rg-actions"></a> Actions
333
+
334
+ <table>
335
+ <thead>
336
+ <tr>
337
+ <th>Action</th>
338
+ <th>Description</th>
339
+ <th>Default</th>
340
+ </tr>
341
+ </thead>
342
+ <tbody>
343
+ <tr>
344
+ <td>create</td>
345
+ <td>
346
+ Sets the global version of Ruby to be used in all shells. See 3.1
347
+ rbenv global<sup>(1)</sup> for more details.
348
+ </td>
349
+ <td>Yes</td>
350
+ </tr>
351
+ </tbody>
352
+ </table>
353
+
354
+ 1. [3.1 rbenv global][rbenv_3_1]
355
+
356
+ #### <a name="lwrps-rg-attributes"></a> Attributes
357
+
358
+ <table>
359
+ <thead>
360
+ <tr>
361
+ <th>Attribute</th>
362
+ <th>Description</th>
363
+ <th>Default Value</th>
364
+ </tr>
365
+ </thead>
366
+ <tbody>
367
+ <tr>
368
+ <td>rbenv_version</td>
369
+ <td>
370
+ <b>Name attribute:</b> a version of Ruby being managed by rbenv.
371
+ <b>Note:</b> the version of Ruby must already be installed--this LWRP
372
+ will not install it automatically.
373
+ </td>
374
+ <td><code>nil</code></td>
375
+ </tr>
376
+ <tr>
377
+ <td>user</td>
378
+ <td>
379
+ A users's isolated rbenv installation on which to apply an action. The
380
+ default value of <code>nil</code> denotes a system-wide rbenv
381
+ installation is being targeted. <b>Note:</b> if specified, the user
382
+ must already exist.
383
+ </td>
384
+ <td><code>nil</code></td>
385
+ </tr>
386
+ <tr>
387
+ <td>root_path</td>
388
+ <td>
389
+ The path prefix to rbenv installation, for example:
390
+ <code>/opt/rbenv</code>.
391
+ </td>
392
+ <td><code>nil</code></td>
393
+ </tr>
394
+ </tbody>
395
+ </table>
396
+
397
+ #### <a name="lwrps-rg-examples"></a> Examples
398
+
399
+ ##### Set A Ruby As Global
400
+
401
+ rbenv_global "1.8.7-p352"
402
+
403
+ ##### Set System Ruby As Global
404
+
405
+ rbenv_global "system"
406
+
407
+ ##### Set A Ruby As Global For A User
408
+
409
+ rbenv_global "jruby-1.7.0-dev" do
410
+ user "tflowers"
411
+ end
412
+
413
+ ### <a name="lwrps-rsc"></a> rbenv_script
414
+
415
+ This resource is a wrapper for the `script` resource which wraps the code block
416
+ in an rbenv-aware environment. See the Opscode
417
+ [script resource][script_resource] page and the [rbenv shell][rbenv_3_3]
418
+ documentation for more details.
419
+
420
+ #### <a name="lwrps-rsc-actions"></a> Actions
421
+
422
+ <table>
423
+ <thead>
424
+ <tr>
425
+ <th>Action</th>
426
+ <th>Description</th>
427
+ <th>Default</th>
428
+ </tr>
429
+ </thead>
430
+ <tbody>
431
+ <tr>
432
+ <td>run</td>
433
+ <td>Run the script</td>
434
+ <td>Yes</td>
435
+ </tr>
436
+ <tr>
437
+ <td>nothing</td>
438
+ <td>Do not run this command</td>
439
+ <td>&nbsp;</td>
440
+ </tr>
441
+ </tbody>
442
+ </table>
443
+
444
+ Use `action :nothing` to set a command to only run if another resource
445
+ notifies it.
446
+
447
+ #### <a name="lwrps-rsc-attributes"></a> Attributes
448
+
449
+ <table>
450
+ <thead>
451
+ <tr>
452
+ <th>Attribute</th>
453
+ <th>Description</th>
454
+ <th>Default Value</th>
455
+ </tr>
456
+ </thead>
457
+ <tbody>
458
+ <tr>
459
+ <td>name</td>
460
+ <td>
461
+ <b>Name attribute:</b> Name of the command to execute.
462
+ </td>
463
+ <td>name</td>
464
+ </tr>
465
+ <tr>
466
+ <td>rbenv_version</td>
467
+ <td>
468
+ A version of Ruby being managed by rbenv.
469
+ </td>
470
+ <td><code>nil</code></td>
471
+ </tr>
472
+ <tr>
473
+ <td>root_path</td>
474
+ <td>
475
+ The path prefix to rbenv installation, for example:
476
+ <code>/opt/rbenv</code>.
477
+ </td>
478
+ <td><code>nil</code></td>
479
+ </tr>
480
+ <tr>
481
+ <td>code</td>
482
+ <td>
483
+ Quoted script of code to execute.
484
+ </td>
485
+ <td><code>nil</code></td>
486
+ </tr>
487
+ <tr>
488
+ <td>creates</td>
489
+ <td>
490
+ A file this command creates - if the file exists, the command will not
491
+ be run.
492
+ </td>
493
+ <td><code>nil</code></td>
494
+ </tr>
495
+ <tr>
496
+ <td>cwd</td>
497
+ <td>
498
+ Current working director to run the command from.
499
+ </td>
500
+ <td><code>nil</code></td>
501
+ </tr>
502
+ <tr>
503
+ <td>environment</td>
504
+ <td>
505
+ A has of environment variables to set before running this command.
506
+ </td>
507
+ <td><code>nil</code></td>
508
+ </tr>
509
+ <tr>
510
+ <td>group</td>
511
+ <td>
512
+ A group or group ID that we should change to before running this
513
+ command.
514
+ </td>
515
+ <td><code>nil</code></td>
516
+ </tr>
517
+ <tr>
518
+ <td>path</td>
519
+ <td>
520
+ An array of paths to use when searching for the command.
521
+ </td>
522
+ <td><code>nil</code>, uses system path</td>
523
+ </tr>
524
+ <tr>
525
+ <td>returns</td>
526
+ <td>
527
+ The return value of the command (may be an array of accepted values) -
528
+ this resource raises an exception if the return value(s) do not match.
529
+ </td>
530
+ <td><code>0</code></td>
531
+ </tr>
532
+ <tr>
533
+ <td>timeout</td>
534
+ <td>
535
+ How many seconds to let the command run before timing out.
536
+ </td>
537
+ <td><code>nil</code></td>
538
+ </tr>
539
+ <tr>
540
+ <td>user</td>
541
+ <td>
542
+ A users's isolated rbenv installation on which to apply an action. The
543
+ default value of <code>nil</code> denotes a system-wide rbenv
544
+ installation is being targeted. <b>Note:</b> if specified, the user
545
+ must already exist.
546
+ </td>
547
+ <td><code>nil</code></td>
548
+ </tr>
549
+ <tr>
550
+ <td>umask</td>
551
+ <td>
552
+ Umask for files created by the command.
553
+ </td>
554
+ <td><code>nil</code></td>
555
+ </tr>
556
+ </tbody>
557
+ </table>
558
+
559
+ #### <a name="lwrps-rsc-examples"></a> Examples
560
+
561
+ ##### Run A Rake Task
562
+
563
+ rbenv_script "migrate_rails_database" do
564
+ rbenv_version "1.8.7-p352"
565
+ user "deploy"
566
+ group "deploy"
567
+ cwd "/srv/webapp/current"
568
+ code %{rake RAILS_ENV=production db:migrate}
569
+ end
570
+
571
+ ### <a name="lwrps-rbgem"></a> rbenv_gem
572
+
573
+ This resource is a close analog of the `gem_package` resource/provider which
574
+ is rbenv-aware. See the Opscode [package resource][package_resource] and
575
+ [gem package options][gem_package_options] pages for more details.
576
+
577
+ #### <a name="lwrps-rbgem-actions"></a> Actions
578
+
579
+ <table>
580
+ <thead>
581
+ <tr>
582
+ <th>Action</th>
583
+ <th>Description</th>
584
+ <th>Default</th>
585
+ </tr>
586
+ </thead>
587
+ <tbody>
588
+ <tr>
589
+ <td>install</td>
590
+ <td>
591
+ Install a gem - if version is provided, install that specific version.
592
+ </td>
593
+ <td>Yes</td>
594
+ </tr>
595
+ <tr>
596
+ <td><upgrade/td>
597
+ <td>
598
+ Upgrade a gem - if version is provided, upgrade to that specific
599
+ version.
600
+ </td>
601
+ <td>&nbsp;</td>
602
+ </tr>
603
+ <tr>
604
+ <td>remove</td>
605
+ <td>
606
+ Remove a gem.
607
+ </td>
608
+ <td>&nbsp;</td>
609
+ </tr>
610
+ <tr>
611
+ <td>purge</td>
612
+ <td>
613
+ Purge a gem.
614
+ </td>
615
+ <td>&nbsp;</td>
616
+ </tr>
617
+ </tbody>
618
+ </table>
619
+
620
+ #### <a name="lwrps-rbr-attributes"></a> Attributes
621
+
622
+ <table>
623
+ <thead>
624
+ <tr>
625
+ <th>Attribute</th>
626
+ <th>Description</th>
627
+ <th>Default Value</th>
628
+ </tr>
629
+ </thead>
630
+ <tbody>
631
+ <tr>
632
+ <td>package_name</td>
633
+ <td>
634
+ <b>Name attribute:</b> the name of the gem to install.
635
+ </td>
636
+ <td><code>nil</code></td>
637
+ </tr>
638
+ <tr>
639
+ <td>rbenv_version</td>
640
+ <td>
641
+ A version of Ruby being managed by rbenv.
642
+ </td>
643
+ <td><code>"global"</code></td>
644
+ </tr>
645
+ <tr>
646
+ <td>root_path</td>
647
+ <td>
648
+ The path prefix to rbenv installation, for example:
649
+ <code>/opt/rbenv</code>.
650
+ </td>
651
+ <td><code>nil</code></td>
652
+ </tr>
653
+ <tr>
654
+ <td>version</td>
655
+ <td>
656
+ The specific version of the gem to install/upgrade.
657
+ </td>
658
+ <td><code>nil</code></td>
659
+ </tr>
660
+ <tr>
661
+ <td>options</td>
662
+ <td>
663
+ Add additional options to the underlying gem command.
664
+ </td>
665
+ <td><code>nil</code></td>
666
+ </tr>
667
+ <tr>
668
+ <td>source</td>
669
+ <td>
670
+ Provide an additional source for gem providers (such as RubyGems).
671
+ This can also include a file system path to a <code>.gem</code> file
672
+ such as <code>/tmp/json-1.5.1.gem</code>.
673
+ </td>
674
+ <td><code>nil</code></td>
675
+ </tr>
676
+ <tr>
677
+ <td>user</td>
678
+ <td>
679
+ A users's isolated rbenv installation on which to apply an action. The
680
+ default value of <code>nil</code> denotes a system-wide rbenv
681
+ installation is being targeted. <b>Note:</b> if specified, the user
682
+ must already exist.
683
+ </td>
684
+ <td><code>nil</code></td>
685
+ </tr>
686
+ </tbody>
687
+ </table>
688
+
689
+ #### <a name="lwrps-rbgem-examples"></a> Examples
690
+
691
+ ##### Install A Gem
692
+
693
+ rbenv_gem "thor" do
694
+ rbenv_version "1.8.7-p352"
695
+ action :install
696
+ end
697
+
698
+ rbenv_gem "json" do
699
+ rbenv_version "1.8.7-p330"
700
+ end
701
+
702
+ rbenv_gem "nokogiri" do
703
+ rbenv_version "jruby-1.5.6"
704
+ version "1.5.0.beta.4"
705
+ action :install
706
+ end
707
+
708
+ **Note:** the install action is default, so the second example is a more common
709
+ usage.
710
+
711
+ ##### Install A Gem From A Local File
712
+
713
+ rbenv_gem "json" do
714
+ rbenv_version "ree-1.8.7-2011.03"
715
+ source "/tmp/json-1.5.1.gem"
716
+ version "1.5.1"
717
+ end
718
+
719
+ ##### Keep A Gem Up To Date
720
+
721
+ rbenv_gem "homesick" do
722
+ action :upgrade
723
+ end
724
+
725
+ **Note:** the global rbenv Ruby will be targeted if no `rbenv_version` attribute
726
+ is given.
727
+
728
+ ##### Remove A Gem
729
+
730
+ rbenv_gem "nokogiri" do
731
+ rbenv_version "jruby-1.5.6"
732
+ version "1.4.4.2"
733
+ action :remove
734
+ end
735
+
736
+ ### <a name="lwrps-plugin"></a> rbenv_plugin
737
+
738
+ Installs rbenv plugins.
739
+
740
+ #### <a name="lwrps-plugin-attributes"></a> Attributes
741
+
742
+ <table>
743
+ <thead>
744
+ <tr>
745
+ <th>Attribute</th>
746
+ <th>Description</th>
747
+ <th>Default Value</th>
748
+ </tr>
749
+ </thead>
750
+ <tbody>
751
+ <tr>
752
+ <td>name</td>
753
+ <td>
754
+ <b>Name attribute:</b> the name of the plugin to install.
755
+ </td>
756
+ <td><code>nil</code></td>
757
+ </tr>
758
+ <tr>
759
+ <td>root_path</td>
760
+ <td>
761
+ The path prefix to rbenv installation, for example:
762
+ <code>/opt/rbenv</code>.
763
+ </td>
764
+ <td><code>nil</code></td>
765
+ </tr>
766
+ <tr>
767
+ <td>git_url</td>
768
+ <td>
769
+ The git URL of the plugin repository to clone.
770
+ </td>
771
+ <td><code>nil</code></td>
772
+ </tr>
773
+ <tr>
774
+ <td>git_ref</td>
775
+ <td>
776
+ The git revision (branch name or SHA) of the repository to checkout.
777
+ </td>
778
+ <td><code>'master'</code></td>
779
+ </tr>
780
+ <tr>
781
+ <td>user</td>
782
+ <td>
783
+ A users's isolated rbenv installation on which to apply an action. The
784
+ default value of <code>nil</code> denotes a system-wide rbenv
785
+ installation is being targeted. <b>Note:</b> if specified, the user
786
+ must already exist.
787
+ </td>
788
+ <td><code>nil</code></td>
789
+ </tr>
790
+ </tbody>
791
+ </table>
792
+
793
+ ##### Install a plugin
794
+
795
+ rbenv_plugin 'rbenv-vars' do
796
+ git_url 'https://github.com/sstephenson/rbenv-vars.git'
797
+ user 'deploy'
798
+ end
799
+
800
+ ### <a name="lwrps-rrh"></a> rbenv_rehash
801
+
802
+ This resource installs shims for all Ruby binaries known to rbenv, as per
803
+ the [rbenv rehash docs][rbenv_3_6].
804
+
805
+ #### <a name="lwrps-rrh-actions"></a> Actions
806
+
807
+ <table>
808
+ <thead>
809
+ <tr>
810
+ <th>Action</th>
811
+ <th>Description</th>
812
+ <th>Default</th>
813
+ </tr>
814
+ </thead>
815
+ <tbody>
816
+ <tr>
817
+ <td>run</td>
818
+ <td>Run the script</td>
819
+ <td>Yes</td>
820
+ </tr>
821
+ <tr>
822
+ <td>nothing</td>
823
+ <td>Do not run this command</td>
824
+ <td>&nbsp;</td>
825
+ </tr>
826
+ </tbody>
827
+ </table>
828
+
829
+ Use `action :nothing` to set a command to only run if another resource
830
+ notifies it.
831
+
832
+ #### <a name="lwrps-rrh-attributes"></a> Attributes
833
+
834
+ <table>
835
+ <thead>
836
+ <tr>
837
+ <th>Attribute</th>
838
+ <th>Description</th>
839
+ <th>Default Value</th>
840
+ </tr>
841
+ </thead>
842
+ <tbody>
843
+ <tr>
844
+ <td>name</td>
845
+ <td>
846
+ <b>Name attribute:</b> Name of the command to execute.
847
+ </td>
848
+ <td>name</td>
849
+ </tr>
850
+ <tr>
851
+ <td>user</td>
852
+ <td>
853
+ A users's isolated rbenv installation on which to apply an action. The
854
+ default value of <code>nil</code> denotes a system-wide rbenv
855
+ installation is being targeted. <b>Note:</b> if specified, the user
856
+ must already exist.
857
+ </td>
858
+ <td><code>nil</code></td>
859
+ </tr>
860
+ <tr>
861
+ <td>root_path</td>
862
+ <td>
863
+ The path prefix to rbenv installation, for example:
864
+ <code>/opt/rbenv</code>.
865
+ </td>
866
+ <td><code>nil</code></td>
867
+ </tr>
868
+ </tbody>
869
+ </table>
870
+
871
+ #### <a name="lwrps-rrh-examples"></a> Examples
872
+
873
+ ##### Rehash A System-Wide rbenv
874
+
875
+ rbenv_rehash "Doing the rehash dance"
876
+
877
+ ##### Rehash A User's rbenv
878
+
879
+ rbenv_rehash "Rehashing tflowers' rbenv" do
880
+ user "tflowers"
881
+ end
882
+
883
+ ### <a name="lwrps-rbr"></a> rbenv_ruby
884
+
885
+ This resource uses the [ruby-build][ruby_build_site] framework to build and install
886
+ Ruby versions from definition files.
887
+
888
+ **Note:** this LWRP requires the [ruby\_build cookbook][ruby_build_cb] to be
889
+ in the run list to perform the builds.
890
+
891
+ #### <a name="lwrps-rbr-actions"></a> Actions
892
+
893
+ <table>
894
+ <thead>
895
+ <tr>
896
+ <th>Action</th>
897
+ <th>Description</th>
898
+ <th>Default</th>
899
+ </tr>
900
+ </thead>
901
+ <tbody>
902
+ <tr>
903
+ <td>install</td>
904
+ <td>
905
+ Build and install a Ruby from a definition file. See the ruby-build
906
+ readme<sup>(1)</sup> for more details.
907
+ </td>
908
+ <td>Yes</td>
909
+ </tr>
910
+ <tr>
911
+ <td>reinstall</td>
912
+ <td>
913
+ Force a recompiliation of the Ruby from source. The :install action
914
+ will skip a build if the target install directory already exists.
915
+ </td>
916
+ <td>&nbsp;</td>
917
+ </tr>
918
+ </tbody>
919
+ </table>
920
+
921
+ 1. [ruby-build readme][rb_readme]
922
+
923
+ #### <a name="lwrps-rbr-attributes"></a> Attributes
924
+
925
+ <table>
926
+ <thead>
927
+ <tr>
928
+ <th>Attribute</th>
929
+ <th>Description</th>
930
+ <th>Default Value</th>
931
+ </tr>
932
+ </thead>
933
+ <tbody>
934
+ <tr>
935
+ <td>definition</td>
936
+ <td>
937
+ <b>Name attribute:</b> the name of a built-in definition<sup>(1)</sup>
938
+ or the name of the ruby installed by a ruby-build defintion file<sup>(2)</sup>
939
+ </td>
940
+ <td><code>nil</code></td>
941
+ </tr>
942
+ <tr>
943
+ <td>definition_file</td>
944
+ <td>
945
+ The path to a ruby-build definition file.
946
+ </td>
947
+ <td><code>nil</code></td>
948
+ </tr>
949
+ <tr>
950
+ <td>user</td>
951
+ <td>
952
+ A users's isolated rbenv installation on which to apply an action. The
953
+ default value of <code>nil</code> denotes a system-wide rbenv
954
+ installation is being targeted. <b>Note:</b> if specified, the user
955
+ must already exist.
956
+ </td>
957
+ <td><code>nil</code></td>
958
+ </tr>
959
+ <tr>
960
+ <td>root_path</td>
961
+ <td>
962
+ The path prefix to rbenv installation, for example:
963
+ <code>/opt/rbenv</code>.
964
+ </td>
965
+ <td><code>nil</code></td>
966
+ </tr>
967
+ <tr>
968
+ <td>rbenv_action</td>
969
+ <td>
970
+ The action that rbenv takes to install ruby via the command line. By default this is 'install' which results in a command such as <code>rbenv install ruby 2.2.0</code>. When using the rvm-download rbenv plugin use 'download' to have the provider execute a command such as <code>rbenv download 2.2.0</code>.
971
+ </td>
972
+ <td><code>install</code></td>
973
+ </tr>
974
+ </tbody>
975
+ </table>
976
+
977
+ 1. [built-in definition][rb_definitions]
978
+ 2. the recipe checks for the existence of the naming attribute under the root_path, and if not found invokes ruby-build with the definition file as an argument
979
+
980
+ #### <a name="lwrps-rbr-examples"></a> Examples
981
+
982
+ ##### Install Ruby From ruby-build
983
+
984
+ rbenv_ruby "ree-1.8.7-2011.03" do
985
+ action :install
986
+ end
987
+
988
+ rbenv_ruby "jruby-1.6.5"
989
+
990
+ **Note:** the install action is default, so the second example is a more common
991
+ usage.
992
+
993
+ ##### Reinstall Ruby
994
+
995
+ rbenv_ruby "ree-1.8.7-2011.03" do
996
+ action :reinstall
997
+ end
998
+
999
+ ##### Install a custom ruby
1000
+
1001
+ rbenv_ruby "2.0.0p116" do
1002
+ definition_file "/usr/local/rbenv/custom/2.0.0p116"
1003
+ end
1004
+
1005
+ ## <a name="mac-system-note"></a> System-Wide Mac Installation Note
1006
+
1007
+ This cookbook takes advantage of managing profile fragments in an
1008
+ `/etc/profile.d` directory, common on most Unix-flavored platforms.
1009
+ Unfortunately, Mac OS X does not support this idiom out of the box,
1010
+ so you may need to [modify][mac_profile_d] your user profile.
1011
+
1012
+ ## <a name="development"></a> Development
1013
+
1014
+ * Source hosted at [GitHub][repo]
1015
+ * Report issues/Questions/Feature requests on [GitHub Issues][issues]
1016
+
1017
+ Pull requests are very welcome! Make sure your patches are well tested.
1018
+ Ideally create a topic branch for every separate change you make.
1019
+
1020
+ ## <a name="license"></a> License and Author
1021
+
1022
+ Author:: [Fletcher Nichol][fnichol] (<fnichol@nichol.ca>) [![endorse](http://api.coderwall.com/fnichol/endorsecount.png)](http://coderwall.com/fnichol)
1023
+
1024
+ Copyright 2011, Fletcher Nichol
1025
+
1026
+ Licensed under the Apache License, Version 2.0 (the "License");
1027
+ you may not use this file except in compliance with the License.
1028
+ You may obtain a copy of the License at
1029
+
1030
+ http://www.apache.org/licenses/LICENSE-2.0
1031
+
1032
+ Unless required by applicable law or agreed to in writing, software
1033
+ distributed under the License is distributed on an "AS IS" BASIS,
1034
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1035
+ See the License for the specific language governing permissions and
1036
+ limitations under the License.
1037
+
1038
+ [berkshelf]: http://berkshelf.com/
1039
+ [chef_repo]: https://github.com/chef/chef-repo
1040
+ [cheffile]: https://github.com/applicationsonline/librarian/blob/master/lib/librarian/chef/templates/Cheffile
1041
+ [gem_package_options]: https://docs.chef.io/resource_gem_package.html#attributes
1042
+ [kgc]: https://github.com/websterclay/knife-github-cookbooks#readme
1043
+ [librarian]: https://github.com/applicationsonline/librarian#readme
1044
+ [lwrp]: https://docs.chef.io/lwrp_custom.html
1045
+ [mac_profile_d]: http://hints.macworld.com/article.php?story=20011221192012445
1046
+ [package_resource]: https://docs.chef.io/resource_package.html
1047
+ [rb_readme]: https://github.com/sstephenson/ruby-build#readme
1048
+ [rb_definitions]: https://github.com/sstephenson/ruby-build/tree/master/share/ruby-build
1049
+ [rbenv_site]: https://github.com/sstephenson/rbenv
1050
+ [rbenv_3_1]: https://github.com/sstephenson/rbenv#section_3.1
1051
+ [rbenv_3_3]: https://github.com/sstephenson/rbenv#section_3.3
1052
+ [rbenv_3_6]: https://github.com/sstephenson/rbenv#section_3.6
1053
+ [ruby_build_cb]: https://supermarket.chef.io/cookbooks/ruby_build
1054
+ [ruby_build_site]: https://github.com/sstephenson/ruby-build
1055
+ [script_resource]: http://docs.chef.io/resource_script.html
1056
+
1057
+ [fnichol]: https://github.com/fnichol
1058
+ [repo]: https://github.com/chef-rbenv/ruby-rbenv
1059
+ [issues]: https://github.com/chef-rbenv/ruby-rbenv/issues