Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added One-Shot role for setting [:one_shot][:recipe] attribute

  • Loading branch information...
commit af9b17d76a4fe03711a1c2ea6a686cd01c7ac149 1 parent 542fa25
Matt Ray authored February 01, 2011 jtimberman committed February 18, 2011
30  one-shot/README.md
Source Rendered
... ...
@@ -1,6 +1,6 @@
1 1
 Description
2 2
 ===========
3  
-This cookbook provides a framework for making single-use, one-shot recipes. By including the `one-shot` recipe in the node's run_list, on the next chef-client run the contents of the `one-shot::one-shot` recipe will be called. This is parameterized as an attribute, so you can change these out by setting the `["one_shot"]["recipe"]` to include different recipes.
  3
+This cookbook provides a framework for making single-use, one-shot recipes. By including the `one-shot` recipe in the node's run_list, on the next chef-client run the contents of the `one-shot::one-shot` recipe will be called. This is parameterized as an attribute, so you can change these out by setting the `["one_shot"]["recipe"]` to include different recipes. The file `roles/one-shot.rb` is included so you can simply change the role instead of changing the source directly.
4 4
 
5 5
 Requirements
6 6
 ============
@@ -12,10 +12,20 @@ Tested on Ubuntu 10.04 and 10.10 and tested with Chef 0.9.12.
12 12
 
13 13
 Attributes
14 14
 ==========
15  
-For now this attribute has to exist in a Role, you can edit the node or you can edit the cookbook. Ideally you could pass an attribute from the command line.
  15
+The attribute is set in `attributes/default.rb` and can be set via the `roles/one-shot.rb` Role as well (or you could edit the `default.rb` recipe directly).
16 16
 
17 17
 * `["one_shot"]["recipe"]` - Default is `one-shot::one-shot`, but may be set to alternate recipes so you may have multiple recipes to use, depending on this attribute.
18 18
 
  19
+Roles
  20
+=====
  21
+one-shot
  22
+--------
  23
+This role is provided by the `roles/one-shot.rb` for setting the `["one_shot"]["recipe"]` attribute. 
  24
+
  25
+    knife role from file cookbooks/one-shot/roles/one-shot.rb 
  26
+    knife node run_list add YOURNODE 'role[one-shot]'
  27
+
  28
+
19 29
 Recipes
20 30
 =======
21 31
 Default
@@ -24,11 +34,23 @@ The default recipe includes the recipe referred to by the `["one_shot"]["recipe"
24 34
 
25 35
 One-Shot
26 36
 --------
27  
-This is an example implementation of a one-shot recipe, it may be copied or modified as necessary. Access to additional recipes are made through the `["one_shot"]["recipe"]` attribute.
  37
+This is an example implementation of a one-shot recipe, it may be copied or modified as necessary. Access to additional recipes are made through the `["one_shot"]["recipe"]` attribute. This recipe is accessed by the `attributes/default.rb`.
  38
+
  39
+Two-Shot
  40
+--------
  41
+This is an example implementation of a one-shot recipe, it may be copied or modified as necessary. Access to additional recipes are made through the `["one_shot"]["recipe"]` attribute. This recipe is accessed by the `roles/one-shot.rb` Role.
28 42
 
29 43
 Usage
30 44
 =====
31  
-Add the `one-shot` recipe to a node's run_list. Next chef-client run, that node will execute the recipe designated by the `["one_shot"]["recipe"]` attribute, then remove itself from the node's run_list.
  45
+Add the `one-shot` recipe to a node's run_list. Next chef-client run, that node will execute the recipe designated by the `["one_shot"]["recipe"]` attribute, then remove itself from the node's run_list. The attribute may be set with a Role or directly in the source of the cookbook. You can update the `one-shot` Role with any changes for future runs, then add the `one-shot` recipe back to the run_list again. It could definitely be used within another Role and applied to a series of nodes if needed.
  46
+
  47
+    knife node run_list add YOURNODE 'recipe[one-shot]'
  48
+
  49
+optional
  50
+
  51
+    knife role from file cookbooks/one-shot/roles/one-shot.rb 
  52
+    knife node run_list add YOURNODE 'role[one-shot]'
  53
+
32 54
 
33 55
 License and Author
34 56
 ==================
7  one-shot/roles/one-shot.rb
... ...
@@ -0,0 +1,7 @@
  1
+name "one-shot"
  2
+description "One-Shot attribute for selecting recipe"
  3
+override_attributes(
  4
+                    "one_shot" => {
  5
+                      "recipe" => "one-shot::two-shot"
  6
+                      }
  7
+                    )

0 notes on commit af9b17d

Please sign in to comment.
Something went wrong with that request. Please try again.