ridley 0.10.2 → 0.11.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. data/README.md +147 -216
  2. data/lib/ridley.rb +2 -0
  3. data/lib/ridley/bootstrap_bindings/unix_template_binding.rb +21 -25
  4. data/lib/ridley/bootstrap_bindings/windows_template_binding.rb +29 -34
  5. data/lib/ridley/bootstrapper.rb +2 -2
  6. data/lib/ridley/bootstrapper/context.rb +5 -5
  7. data/lib/ridley/chef.rb +0 -1
  8. data/lib/ridley/chef/cookbook.rb +0 -9
  9. data/lib/ridley/chef_object.rb +128 -0
  10. data/lib/ridley/chef_objects.rb +3 -0
  11. data/lib/ridley/chef_objects/client_object.rb +55 -0
  12. data/lib/ridley/chef_objects/cookbook_object.rb +190 -0
  13. data/lib/ridley/chef_objects/data_bag_item_obect.rb +104 -0
  14. data/lib/ridley/chef_objects/data_bag_object.rb +31 -0
  15. data/lib/ridley/chef_objects/environment_object.rb +59 -0
  16. data/lib/ridley/chef_objects/node_object.rb +161 -0
  17. data/lib/ridley/chef_objects/role_object.rb +62 -0
  18. data/lib/ridley/chef_objects/sandbox_object.rb +58 -0
  19. data/lib/ridley/client.rb +76 -45
  20. data/lib/ridley/connection.rb +1 -1
  21. data/lib/ridley/errors.rb +8 -1
  22. data/lib/ridley/host_connector.rb +26 -6
  23. data/lib/ridley/host_connector/ssh.rb +3 -3
  24. data/lib/ridley/host_connector/ssh/worker.rb +7 -9
  25. data/lib/ridley/host_connector/winrm/worker.rb +4 -5
  26. data/lib/ridley/mixin/bootstrap_binding.rb +1 -12
  27. data/lib/ridley/resource.rb +51 -171
  28. data/lib/ridley/resources/client_resource.rb +18 -68
  29. data/lib/ridley/resources/cookbook_resource.rb +181 -381
  30. data/lib/ridley/resources/data_bag_item_resource.rb +55 -161
  31. data/lib/ridley/resources/data_bag_resource.rb +20 -61
  32. data/lib/ridley/resources/environment_resource.rb +9 -64
  33. data/lib/ridley/resources/node_resource.rb +135 -311
  34. data/lib/ridley/resources/role_resource.rb +1 -57
  35. data/lib/ridley/resources/sandbox_resource.rb +80 -65
  36. data/lib/ridley/resources/search_resource.rb +99 -0
  37. data/lib/ridley/sandbox_uploader.rb +12 -52
  38. data/lib/ridley/version.rb +1 -1
  39. data/spec/acceptance/bootstrapping_spec.rb +1 -1
  40. data/spec/acceptance/client_resource_spec.rb +15 -37
  41. data/spec/acceptance/data_bag_item_resource_spec.rb +8 -14
  42. data/spec/acceptance/data_bag_resource_spec.rb +1 -1
  43. data/spec/acceptance/environment_resource_spec.rb +13 -22
  44. data/spec/acceptance/node_resource_spec.rb +10 -29
  45. data/spec/acceptance/role_resource_spec.rb +14 -13
  46. data/spec/acceptance/sandbox_resource_spec.rb +2 -2
  47. data/spec/support/shared_examples/ridley_resource.rb +2 -23
  48. data/spec/unit/ridley/bootstrap_bindings/unix_template_binding_spec.rb +3 -4
  49. data/spec/unit/ridley/bootstrap_bindings/windows_template_binding_spec.rb +3 -5
  50. data/spec/unit/ridley/bootstrapper/context_spec.rb +2 -3
  51. data/spec/unit/ridley/bootstrapper_spec.rb +1 -1
  52. data/spec/unit/ridley/chef_object_spec.rb +240 -0
  53. data/spec/unit/ridley/chef_objects/client_object_spec.rb +11 -0
  54. data/spec/unit/ridley/chef_objects/cookbook_object_spec.rb +93 -0
  55. data/spec/unit/ridley/chef_objects/data_bag_item_object_spec.rb +74 -0
  56. data/spec/unit/ridley/chef_objects/data_bag_object_spec.rb +9 -0
  57. data/spec/unit/ridley/chef_objects/environment_object_spec.rb +57 -0
  58. data/spec/unit/ridley/chef_objects/node_object_spec.rb +252 -0
  59. data/spec/unit/ridley/chef_objects/role_object_spec.rb +57 -0
  60. data/spec/unit/ridley/chef_objects/sandbox_object_spec.rb +66 -0
  61. data/spec/unit/ridley/client_spec.rb +51 -51
  62. data/spec/unit/ridley/host_connector/ssh/worker_spec.rb +4 -4
  63. data/spec/unit/ridley/host_connector/ssh_spec.rb +26 -24
  64. data/spec/unit/ridley/host_connector/winrm/worker_spec.rb +3 -4
  65. data/spec/unit/ridley/host_connector/winrm_spec.rb +4 -4
  66. data/spec/unit/ridley/host_connector_spec.rb +40 -3
  67. data/spec/unit/ridley/mixin/bootstrap_binding_spec.rb +1 -1
  68. data/spec/unit/ridley/resource_spec.rb +81 -109
  69. data/spec/unit/ridley/resources/client_resource_spec.rb +18 -33
  70. data/spec/unit/ridley/resources/cookbook_resource_spec.rb +56 -230
  71. data/spec/unit/ridley/resources/data_bag_item_resource_spec.rb +2 -57
  72. data/spec/unit/ridley/resources/data_bag_resource_spec.rb +12 -7
  73. data/spec/unit/ridley/resources/environment_resource_spec.rb +10 -118
  74. data/spec/unit/ridley/resources/node_resource_spec.rb +83 -394
  75. data/spec/unit/ridley/resources/role_resource_spec.rb +2 -56
  76. data/spec/unit/ridley/resources/sandbox_resource_spec.rb +139 -136
  77. data/spec/unit/ridley/resources/search_resource_spec.rb +234 -0
  78. data/spec/unit/ridley/sandbox_uploader_spec.rb +13 -58
  79. metadata +36 -17
  80. data/lib/ridley/chef/chefignore.rb +0 -76
  81. data/lib/ridley/resources/encrypted_data_bag_item_resource.rb +0 -55
  82. data/lib/ridley/resources/search.rb +0 -101
  83. data/spec/fixtures/chefignore +0 -8
  84. data/spec/unit/ridley/chef/chefignore_spec.rb +0 -40
  85. data/spec/unit/ridley/resources/search_spec.rb +0 -221
data/README.md CHANGED
@@ -10,12 +10,6 @@ A reliable Chef API client with a clean syntax
10
10
 
11
11
  $ gem install ridley
12
12
 
13
- ## Known Issues
14
-
15
- * Sandboxes has not been implemented
16
- * Full support for Cookbooks is not included
17
- * Acceptance test suite needs to be refactored
18
-
19
13
  ## Usage
20
14
 
21
15
  Require Ridley into your application
@@ -24,42 +18,25 @@ Require Ridley into your application
24
18
 
25
19
  ## Creating a new Ridley client
26
20
 
27
- conn = Ridley.new(
28
- server_url: "https://api.opscode.com",
21
+ ridley = Ridley.new(
22
+ server_url: "https://api.opscode.com/organizations/ridley",
29
23
  client_name: "reset",
30
- client_key: "/Users/reset/.chef/reset.pem",
31
- organization: "ridley"
24
+ client_key: "/Users/reset/.chef/reset.pem"
32
25
  )
33
26
 
34
- Creating a new connection requires you to specify at minimum:
27
+ Creating a new instance of Ridley requires the following options:
35
28
 
36
29
  * server_url
37
30
  * client_name
38
31
  * client_key
39
32
 
40
- An optional organization option can be specified if you are working with Hosted or Private Chef (OHC/OPC). For a full list of available options see the [yard documentation](http://rubydoc.info/gems/ridley).
41
-
42
- Connections can also be instantiated by a helper function: `Ridley.new`
43
-
44
- Ridley.new(
45
- server_url: "https://api.opscode.com",
46
- client_name: "reset",
47
- client_key: "/Users/reset/.chef/reset.pem"
48
- )
49
-
50
- Using a connection object you can interact with collections of resources on a Chef server. Resources are:
51
-
52
- * Nodes
53
- * Roles
54
- * Environments
55
- * Clients
56
- * Cookbooks
57
- * Data Bags
33
+ Ridley exposes a number of functions that return resources which you can use to retrieve or create objects on your Chef server. Here is a simple example of getting a list of all the roles on your Chef server.
58
34
 
59
- Here is a simple example of instantiating a new connection and listing all of the roles on a Chef server.
60
-
61
- conn = Ridley.new(...)
62
- conn.role.all => []
35
+ ridley = Ridley.new(...)
36
+ ridley.role.all #=> [
37
+ #<Ridley::RoleObject chef_id:motherbrain_srv ...>,
38
+ #<Ridley::RoleObject chef_id:motherbrain_proxy ...>
39
+ ]
63
40
 
64
41
  For more information scroll down to the Manipulating Chef Resources section of this README.
65
42
 
@@ -67,9 +44,8 @@ For more information scroll down to the Manipulating Chef Resources section of t
67
44
 
68
45
  An alternative syntax is provided if you want to perform multiple requests, in order, on a connection.
69
46
 
70
- conn = Ridley.new(...)
71
-
72
- conn.sync do
47
+ ridley = Ridley.new(...)
48
+ ridley.sync do
73
49
  role.all
74
50
  role.find("reset")
75
51
  role.create(name: "ridley-test")
@@ -78,170 +54,157 @@ An alternative syntax is provided if you want to perform multiple requests, in o
78
54
 
79
55
  The `sync` function on the connection object takes a block with no arguments and allows you to access the DSL within the block. You can address any one of the resources within the sync block:
80
56
 
81
- conn.sync do
57
+ ridley.sync do
82
58
  environment.all
83
59
  node.all
84
60
  ...
85
61
  end
86
62
 
87
- A helper function exists to allow you to express yourself in a one-liner: `Ridley.sync`
63
+ For one-liner requests you can create a new instance of Ridley and dispose of it with `Ridley.open`
88
64
 
89
- Ridley.sync(server_url: "https://api.opscode.com", ...) do
90
- role.all => []
65
+ Ridley.open(server_url: "https://api.opscode.com", ...) do
66
+ role.all
91
67
  end
92
68
 
93
- ### Asynchronous execution
94
-
95
- __COMING SOON__
96
-
97
69
  ## Manipulating Chef Resources
98
70
 
99
- All resource can be listed, created, retrieved, updated, or destroyed. Some resources have additional functionality described in [their documentation](http://rubydoc.info/gems/ridley).
100
-
101
- ### Listing all resources
71
+ Resources are access by instance functions on a new instance of Ridley::Client.
102
72
 
103
- You use a connection to interact with the resources on the remote Chef server it is pointing to. For example, if you wanted to get a list of all of the roles on your Chef server:
73
+ ridley = Ridley.new(...)
74
+ ridley.client #=> Ridley::ClientResource
75
+ ridley.cookbook #=> Ridley::CookbookResource
76
+ ridley.data_bag #=> Ridley::DataBagResource
77
+ ridley.environment #=> Ridley::EnvironmentResource
78
+ ridley.node #=> Ridley::NodeResource
79
+ ridley.role #=> Ridley::RoleResource
80
+ ridley.sandbox #=> Ridley::SandboxResource
81
+ ridley.search #=> Ridley::SearchResource
104
82
 
105
- conn = Ridley.new(...)
106
- conn.role.all => []
83
+ DataBagItems are the only exception to this rule. The DataBagItem resource is accessed from a DataBagObject
107
84
 
108
- Calling `role.all` on the connection object will return an array of Ridley::RoleResource objects. All of the resources can be listed, not just Roles:
85
+ data_bag = ridley.data_bag.find("my_data")
86
+ data_bag.item #=> Ridley::DataBagItemResource
87
+ data_bag.item.find("my_item") #=> Ridley::DataBagItemObject
109
88
 
110
- conn = Ridley.new(...)
111
- conn.node.all => [<#Ridley::NodeResource>]
112
- conn.role.all => [<#Ridley::RoleResource>]
113
- conn.environment.all => [<#Ridley::EnvironmentResource>]
114
- conn.client.all => [<#Ridley::ClientResource>]
115
- conn.cookbook.all => [<#Ridley::CookbookResource>]
116
- conn.data_bag.all => [<#Ridley::DataBagResource>]
89
+ ### CRUD
117
90
 
118
- ### Creating a resource
91
+ Most resources can be listed, retrieved, created, updated, and destroyed. These are commonly referred to as CRUD (Create Read Update Delete) operations.
119
92
 
120
- A new resource can be created in a few ways
93
+ #### Create
121
94
 
122
- _Create by instantiate and save_
95
+ A new Chef Object can be created in a three ways
123
96
 
124
- conn = Ridley.new(...)
125
- obj = conn.role.new
126
-
127
- obj.name = "reset"
128
- obj.save => <#Ridley::RoleResource: @name="reset">
97
+ _With the `#create` function and an attribute hash_
129
98
 
130
- _Create by the `create` function with attribute hash_
99
+ ridley = Ridley.new(...)
100
+ ridley.role.create(name: "reset") #=> #<Ridley::RoleObject: chef_id:reset>
131
101
 
132
- conn = Ridley.new(...)
133
- conn.role.create(name: "reset") => <#Ridley::RoleResource: @name="reset">
102
+ _With the `#create` function and an instance of a Chef Object_
134
103
 
135
- _Create by the `create` function with a resource object_
104
+ obj = ridley.role.new
105
+ obj.name = "reset"
106
+ ridley.role.create(obj) #=> #<Ridley::RoleObject: chef_id:reset>
136
107
 
137
- conn = Ridley.new(...)
138
- obj = conn.role.new
108
+ _With the `#save` function on an instance of a Chef Object_
139
109
 
110
+ obj = ridley.role.new
140
111
  obj.name = "reset"
141
- conn.role.create(obj) => <#Ridley::RoleResource: @name="reset">
112
+ obj.save #=> #<Ridley::RoleObject: chef_id:reset>
142
113
 
143
- Each of these methods is identical, it is up to you on how you'd like to create new resources.
114
+ Each of these methods produce an identical object on the Chef server. It is up to you on how you'd like to create new resources.
144
115
 
145
- ### Retrieving a resource
116
+ ### Read
146
117
 
147
- There are two functions for retrieving a resource. `find` and `find!`. If you are familiar with ActiveRecord; these are the functions used to pull records out of the database.
118
+ Most resources have two read functions
148
119
 
149
- Both `find` and `find!` will return a resource but if the resource is not found on the Chef server `find!` will raise an exception while `find` will return `nil`.
120
+ - `#all` for listing all the Chef Objects
121
+ - `#find` for retrieving a specific Chef Object
150
122
 
151
- If you were following allong in the previous section we created a role named `reset`. We'll assume that role has been created in this next example.
123
+ #### Listing
152
124
 
153
- conn = Ridley.new(...)
125
+ If you wanted to get a list of all of the roles on your Chef server
154
126
 
155
- conn.role.find("reset") => <#Ridley::RoleResource: @name="reset">
156
- conn.role.find!("reset") => <#Ridley::RoleResource: @name="reset">
127
+ ridley = Ridley.new(...)
128
+ ridley.role.all #=> [
129
+ #<Ridley::RoleObject chef_id:motherbrain_srv ...>,
130
+ #<Ridley::RoleObject chef_id:motherbrain_proxy ...>
131
+ ]
157
132
 
158
- Now if we attempt to find a role that does not exist on the Chef server
159
133
 
160
- conn = Ridley.new(...)
134
+ #### Finding
161
135
 
162
- conn.role.find("not_there") => nil
163
- conn.role.find!("not_there") =>
164
- Ridley::Errors::HTTPNotFound: errors: 'Cannot load role reset'
165
- from /Users/reset/code/ridley/lib/ridley/middleware/chef_response.rb:11:in `on_complete'
166
- from /Users/reset/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/faraday-0.8.1/lib/faraday/response.rb:9:in `block in call'
167
- from /Users/reset/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/faraday-0.8.1/lib/faraday/response.rb:63:in `on_complete'
168
- from /Users/reset/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/faraday-0.8.1/lib/faraday/response.rb:8:in `call'
169
- from /Users/reset/code/ridley/lib/ridley/middleware/chef_auth.rb:31:in `call'
170
- from /Users/reset/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/faraday-0.8.1/lib/faraday/connection.rb:226:in `run_request'
171
- from /Users/reset/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/faraday-0.8.1/lib/faraday/connection.rb:87:in `get'
172
- from /Users/reset/code/ridley/lib/ridley/resource.rb:115:in `find!'
173
- from /Users/reset/code/ridley/lib/ridley/context.rb:22:in `method_missing'
174
- from (irb):6
175
- from /Users/reset/.rbenv/versions/1.9.3-p194/bin/irb:12:in `<main>'
136
+ If you want to retrieve a single role from the Chef server
176
137
 
177
- ### Updating a resource
138
+ ridley = Ridley.new(...)
139
+ ridley.role.find("motherbrain_srv") #=> #<Ridley::RoleObject: chef_id:motherbrain_srv ...>
178
140
 
179
- Like creating a resource, updating a resource can also be expressed a few different ways
141
+ If the role does not exist on the Chef server then `nil` is returned
180
142
 
181
- _Update by the `update` function with an id and attribute hash_
143
+ ridley = Ridley.new(...)
144
+ ridley.role.find("not_there") #=> nil
182
145
 
183
- conn = Ridley.new(...)
184
- conn.role.update("reset", description: "testing updates!") => <#Ridley::RoleResource: @name="reset", @description="testing updates!">
146
+ ### Update
185
147
 
186
- _Update by the `update` function with a resource object_
148
+ Updating a resource can be expressed in three ways
187
149
 
188
- conn = Ridley.new(...)
189
- obj = conn.role.find("reset")
190
- obj.description = "resource object!"
150
+ _With the `#update` function, the ID of the Object to update, and an attributes hash_
191
151
 
192
- conn.role.update(obj) => <#Ridley::RoleResource: @name="reset", @description="resource object!">
152
+ ridley = Ridley.new(...)
153
+ ridley.role.update("motherbrain_srv", description: "testing updates") #=>
154
+ #<Ridley::RoleObject chef_id:motherbrain_srv, description="testing updates" ...>
193
155
 
194
- _Update by saving a resource object_
156
+ _With the `#update` function and an instance of a Chef Object_
195
157
 
196
- conn = Ridley.new(...)
197
- obj = conn.role.find("reset")
158
+ obj = ridley.role.find("motherbrain_srv")
159
+ obj.description = "chef object"
198
160
 
199
- obj.description = "saving an object!"
200
- obj.save => <#Ridley::RoleResource: @name="reset", @description="saving an object!">
161
+ ridley.role.update(obj) #=> #<Ridley::RoleObject: chef_id:motherbrain_srv, description="chef object" ...
201
162
 
202
- ### Deleting a resource
163
+ _With the `#save` function on an instance of a Chef Object_
203
164
 
204
- Like creating or updating a resource, there are a few ways deleting a resource can be expressed
165
+ obj = ridley.role.find("reset")
166
+ obj.description = "saving an object"
167
+ obj.save #=> #<Ridley::RoleObject: chef_id:motherbrain_srv, description="saving an object" ...>
205
168
 
206
- _Delete by the `delete` function with an id_
169
+ ### Destroy
207
170
 
208
- conn = Ridley.new(...)
209
- conn.role.delete("reset") => <#Ridley::RoleResource: @name="reset">
171
+ Destroying a resource can be express in three ways
210
172
 
211
- _Delete by the `delete` function with a resource object_
173
+ _With the `#delete` function and the ID of the Object to destroy_
212
174
 
213
- conn = Ridley.new(...)
214
- obj = conn.role.find("reset")
175
+ ridley = Ridley.new(...)
176
+ ridley.role.delete("motherbrain_srv") => #<Ridley::RoleObject: chef_id:motherbrain_srv ...>
215
177
 
216
- conn.role.delete(obj) => <#Ridley::RoleResource: @name="reset">
178
+ _With the `#delete` function and a Chef Object_
217
179
 
218
- _Delete by the `destroy` function on a resource object_
180
+ obj = ridley.role.find("motherbrain_srv")
181
+ ridley.role.delete(obj) => #<Ridley::RoleObject: chef_id:motherbrain_srv ...>
219
182
 
220
- conn = Ridley.new(...)
221
- obj = conn.role.find("reset")
183
+ _With the `#destroy` function on an instance of a Chef Object_
222
184
 
223
- obj.destroy => true
185
+ obj = conn.role.find("motherbrain_srv")
186
+ obj.destroy #=> true
224
187
 
188
+ ## Client Resource
225
189
  ### Regenerating a client's private key
226
190
 
227
- _Regenerate function on a context with an id_
228
-
229
- conn = Ridley.new(...)
230
- conn.client.regenerate_key("jwinsor") => <#Ridley::ClientResource: @name="jwinsor", @private_key="HIDDEN">
191
+ _With the `#regnerate_key` function and the ID of the Client to regenerate_
231
192
 
232
- _Regenerate function on an instantiated resource object_
193
+ ridley = Ridley.new(...)
194
+ ridley.client.regenerate_key("jamie") #=> #<Ridley::ClientObject: chef_id:"jamie", private_key="**HIDDEN***" ...>
233
195
 
234
- conn = Ridley.new(...)
235
- obj = conn.client.find("jwinsor")
196
+ _With the `#regenerate_key` function on an instance of a Client Object_
236
197
 
237
- obj.regenerate_key => <#Ridley::ClientResource: @name="jwinsor", @private_key="HIDDEN">
198
+ obj = ridley.client.find("jamie")
199
+ obj.regenerate_key #=> #<Ridley::ClientObject: chef_id:"jamie", private_key="**HIDDEN***" ...>
238
200
 
239
- ## Manipulating Data Bags and Data Bag Items
201
+ ## Cookbook Resource
202
+ ## Data Bag Resource
240
203
 
241
204
  A data bag is managed exactly the same as any other Chef resource
242
205
 
243
- conn = Ridley.new(...)
244
- conn.data_bag.create("ridley-test")
206
+ ridley = Ridley.new(...)
207
+ ridley.data_bag.create("ridley-test")
245
208
 
246
209
  You can create, delete, update, or retrieve a data bag exactly how you would expect if you read through the
247
210
  Manipulating Chef Resources portion of this document.
@@ -250,92 +213,31 @@ Unlike a role, node, client, or environment, a data bag is a container for other
250
213
 
251
214
  ### Creating a Data Bag Item
252
215
 
253
- conn = Ridley.new(...)
254
- data_bag = conn.data_bag.create("ridley-test")
255
-
256
- data_bag.item.create(id: "appconfig", host: "reset.local", user: "jwinsor") =>
257
- <#Ridley::DataBagItemResource: @id="appconfig", @host="reset.local", @user="jwinsor">
258
-
259
- ### Saving a Data Bag Item
260
-
261
- conn = Ridley.new(...)
262
- data_bag = conn.data_bag.create("ridley-test")
263
-
264
- dbi = data_bag.item.new
265
- dbi[:id] = "appconfig"
266
- dbi[:host] = "reset.local"
267
- dbi.save => true
268
-
269
- ## Searching
270
-
271
- conn = Ridley.new(...)
272
- conn.search(:node)
273
- conn.search(:node, "name:ridley-test.local")
274
-
275
- Search will return an array of Ridley resource objects if one of the default indices is specified. Chef's default indices are
276
-
277
- * node
278
- * role
279
- * client
280
- * environment
281
-
282
- ## Manipulating Attributes
283
-
284
- Using Ridley you can quickly manipulate node or environment attributes. Attributes are identified by a dotted path notation.
285
-
286
- default[:my_app][:billing][:enabled] => "my_app.billing.enabled"
287
-
288
- Given the previous example you could set the default node attribute with the `set_default_attribute` function on a Node object
289
-
290
- ### Node Attributes
291
-
292
- Setting the `node[:my_app][:billing][:enabled]` node level attribute on the node "jwinsor-1"
216
+ ridley = Ridley.new(...)
217
+ data_bag = ridley.data_bag.create("ridley-test")
293
218
 
294
- conn = Ridley.new
295
- conn.sync do
296
- obj = node.find("jwinsor-1")
297
- obj.set_attribute("my_app.billing.enabled", false)
298
- obj.save
299
- end
219
+ data_bag.item.create(id: "appconfig", host: "reset.local", user: "jamie") #=>
220
+ #<Ridley::DataBagItemObject: chef_id:appconfig, host="reset.local", user="jamie">
300
221
 
301
- ### Environment Attributes
222
+ ## Environment Resource
223
+ ## Node Resource
224
+ ### Setting Attributes
302
225
 
303
226
  Setting a default environment attribute is just like setting a node level default attribute
304
227
 
305
- conn = Ridley.new
306
- conn.sync do
307
- obj = environment.find("production")
308
- obj.set_default_attribute("my_app.proxy.enabled", false)
309
- obj.save
310
- end
228
+ ridley = Ridley.new(...)
229
+ production_env = ridley.environment.find("production")
230
+ production_env.set_default_attribute("my_app.proxy.enabled", false)
231
+ production_env.save #=> true
311
232
 
312
233
  And the same goes for setting an environment level override attribute
313
234
 
314
- conn = Ridley.new
315
- conn.sync do
316
- obj = environment.find("production")
317
- obj.set_override_attribute("my_app.webapp.enabled", false)
318
- obj.save
319
- end
320
-
321
- ### Role Attributes
322
-
323
- conn = Ridley.new
324
- conn.sync do
325
- obj = role.find("why_god_why")
326
- obj.set_default_attribute("my_app.proxy.enabled", false)
327
- obj.save
328
- end
329
-
330
- conn.sync do
331
- obj = role.find("why_god_why")
332
- obj.set_override_attribute("my_app.webapp.enabled", false)
333
- obj.save
334
- end
235
+ production_env.set_override_attribute("my_app.proxy.enabled", false)
236
+ production_env.save #=> true
335
237
 
336
- ## Bootstrapping nodes
238
+ ### Bootstrapping Unix nodes
337
239
 
338
- conn = Ridley.new(
240
+ ridley = Ridley.new(
339
241
  server_url: "https://api.opscode.com",
340
242
  organization: "vialstudios",
341
243
  validator_client: "vialstudios-validator",
@@ -346,13 +248,13 @@ And the same goes for setting an environment level override attribute
346
248
  }
347
249
  )
348
250
 
349
- conn.node.bootstrap("33.33.33.10", "33.33.33.11")
251
+ ridley.node.bootstrap("33.33.33.10", "33.33.33.11")
350
252
 
351
- ## Bootstrapping Windows Nodes
253
+ ### Bootstrapping Windows Nodes
352
254
 
353
255
  Windows Nodes are bootstrapped using a combination of WinRM, Batch, and PowerShell. You will probably need to tweak some settings on your Windows servers to ensure the commands are successful.
354
256
 
355
- ## WinRM Settings
257
+ #### WinRM Settings
356
258
 
357
259
  1. Enable WinRM: `winrm quickconfig` and say Yes.
358
260
  2. Set some WinRM settings to ensure that you don't get 401 Unauthorized responses and 500 Responses because of timeouts.
@@ -365,7 +267,7 @@ winrm set winrm/config @{MaxTimeoutms="600000"}
365
267
  winrm set winrm/config/client @{TrustedHosts="*"}
366
268
  ```
367
269
 
368
- ## PowerShell Settings
270
+ #### PowerShell Settings
369
271
 
370
272
  1. You should also configure your PowerShell profile, so that PowerShell commands have a more lenient timeout period.
371
273
 
@@ -383,6 +285,35 @@ The following links offer some information about configuring a machine's PowerSh
383
285
 
384
286
  You may also want to tweak your Windows boxes a bit more ex: turning UAC off, turning off the Windows Firewall.
385
287
 
288
+ ## Role Resource
289
+ ### Role Attributes
290
+
291
+ Setting role attributes is just like setting node and environment attributes
292
+
293
+ ridley = Ridley.new(...)
294
+ my_app_role = ridley.role.find("my_app")
295
+ my_app_role.set_default_attribute("my_app.proxy.enabled", false)
296
+ my_app_role.save #=> true
297
+
298
+ And the same goes for setting an environment level override attribute
299
+
300
+ my_app_role.set_override_attribute("my_app.proxy.enabled", false)
301
+ my_app_role.save #=> true
302
+
303
+ ## Sandbox Resource
304
+ ## Search Resource
305
+
306
+ ridley = Ridley.new(...)
307
+ ridley.search(:node)
308
+ ridley.search(:node, "name:ridley-test.local")
309
+
310
+ Search will return an array of the appropriate Chef Objects if one of the default indices is specified. The indices are
311
+
312
+ * node
313
+ * role
314
+ * client
315
+ * environment
316
+
386
317
  # Authors and Contributors
387
318
 
388
319
  * Jamie Winsor (<reset@riotgames.com>)