cheffish 0.4 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cheffish.rb +10 -0
- data/lib/cheffish/basic_chef_client.rb +6 -5
- data/lib/cheffish/chef_provider_base.rb +5 -5
- data/lib/cheffish/chef_run_data.rb +1 -7
- data/lib/cheffish/version.rb +1 -1
- data/spec/integration/chef_client_spec.rb +2 -2
- data/spec/integration/chef_node_spec.rb +8 -8
- data/spec/integration/chef_user_spec.rb +2 -2
- data/spec/integration/private_key_spec.rb +58 -27
- data/spec/integration/recipe_dsl_spec.rb +1 -1
- data/spec/support/spec_support.rb +42 -19
- metadata +25 -15
- checksums.yaml +0 -7
data/lib/cheffish.rb
CHANGED
@@ -8,6 +8,16 @@ module Cheffish
|
|
8
8
|
BasicChefClient.inline_resource(provider, provider_action, &block)
|
9
9
|
end
|
10
10
|
|
11
|
+
def self.default_chef_server
|
12
|
+
{
|
13
|
+
:chef_server_url => Chef::Config[:chef_server_url],
|
14
|
+
:options => {
|
15
|
+
:client_name => Chef::Config[:node_name],
|
16
|
+
:signing_key_filename => Chef::Config[:client_key]
|
17
|
+
}
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
11
21
|
NOT_PASSED=Object.new
|
12
22
|
|
13
23
|
def self.node_attributes(klass)
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'cheffish/version'
|
1
2
|
require 'chef/dsl/recipe'
|
2
3
|
require 'chef/event_dispatch/base'
|
3
4
|
require 'chef/event_dispatch/dispatcher'
|
@@ -13,9 +14,9 @@ module Cheffish
|
|
13
14
|
def initialize(node = nil, events = nil)
|
14
15
|
if !node
|
15
16
|
node = Chef::Node.new
|
16
|
-
node.name '
|
17
|
-
node.automatic[:platform] = '
|
18
|
-
node.automatic[:platform_version] =
|
17
|
+
node.name 'basic_chef_client'
|
18
|
+
node.automatic[:platform] = 'basic_chef_client'
|
19
|
+
node.automatic[:platform_version] = Cheffish::VERSION
|
19
20
|
end
|
20
21
|
|
21
22
|
@event_catcher = BasicChefClientEvents.new
|
@@ -23,7 +24,7 @@ module Cheffish
|
|
23
24
|
dispatcher.register(events) if events
|
24
25
|
@run_context = Chef::RunContext.new(node, {}, dispatcher)
|
25
26
|
@updated = []
|
26
|
-
@cookbook_name = '
|
27
|
+
@cookbook_name = 'basic_chef_client'
|
27
28
|
end
|
28
29
|
|
29
30
|
extend Forwardable
|
@@ -53,7 +54,7 @@ module Cheffish
|
|
53
54
|
|
54
55
|
def self.inline_resource(provider, provider_action, &block)
|
55
56
|
events = ProviderEventForwarder.new(provider, provider_action)
|
56
|
-
client = BasicChefClient.new(provider.node)
|
57
|
+
client = BasicChefClient.new(provider.node, events)
|
57
58
|
client.load_block(&block)
|
58
59
|
client.converge
|
59
60
|
client.updated?
|
@@ -97,23 +97,23 @@ module Cheffish
|
|
97
97
|
end
|
98
98
|
else
|
99
99
|
if print_values
|
100
|
-
result << "add #{name == '' ? new_key : "#{name}.#{new_key}"} = #{new_value.inspect}"
|
100
|
+
result << " add #{name == '' ? new_key : "#{name}.#{new_key}"} = #{new_value.inspect}"
|
101
101
|
else
|
102
|
-
result << "add #{name == '' ? new_key : "#{name}.#{new_key}"}"
|
102
|
+
result << " add #{name == '' ? new_key : "#{name}.#{new_key}"}"
|
103
103
|
end
|
104
104
|
end
|
105
105
|
end
|
106
106
|
removed_keys.keys.each do |removed_key|
|
107
|
-
result << "remove #{name == '' ? removed_key : "#{name}.#{removed_key}"}"
|
107
|
+
result << " remove #{name == '' ? removed_key : "#{name}.#{removed_key}"}"
|
108
108
|
end
|
109
109
|
else
|
110
110
|
old_json = old_json.to_s if old_json.kind_of?(Symbol)
|
111
111
|
new_json = new_json.to_s if new_json.kind_of?(Symbol)
|
112
112
|
if old_json != new_json
|
113
113
|
if print_values
|
114
|
-
result << "update #{name} from #{old_json.inspect} to #{new_json.inspect}"
|
114
|
+
result << " update #{name} from #{old_json.inspect} to #{new_json.inspect}"
|
115
115
|
else
|
116
|
-
result << "update #{name}"
|
116
|
+
result << " update #{name}"
|
117
117
|
end
|
118
118
|
end
|
119
119
|
end
|
@@ -5,13 +5,7 @@ module Cheffish
|
|
5
5
|
class ChefRunData
|
6
6
|
def initialize
|
7
7
|
@local_servers = []
|
8
|
-
@current_chef_server =
|
9
|
-
:chef_server_url => Chef::Config[:chef_server_url],
|
10
|
-
:options => {
|
11
|
-
:client_name => Chef::Config[:node_name],
|
12
|
-
:signing_key_filename => Chef::Config[:client_key]
|
13
|
-
}
|
14
|
-
}
|
8
|
+
@current_chef_server = Cheffish.default_chef_server
|
15
9
|
end
|
16
10
|
|
17
11
|
extend Cheffish::WithPattern
|
data/lib/cheffish/version.rb
CHANGED
@@ -15,7 +15,7 @@ describe Chef::Resource::ChefClient do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
context 'and we run a recipe that creates client "blah"' do
|
18
|
-
|
18
|
+
with_converge do
|
19
19
|
chef_client 'blah' do
|
20
20
|
source_key_path "#{repo_path}/blah.pem"
|
21
21
|
end
|
@@ -31,7 +31,7 @@ describe Chef::Resource::ChefClient do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
context 'and we run a recipe that creates client "blah" with output_key_path' do
|
34
|
-
|
34
|
+
with_converge do
|
35
35
|
chef_client 'blah' do
|
36
36
|
source_key_path "#{repo_path}/blah.pem"
|
37
37
|
output_key_path "#{repo_path}/blah.pub"
|
@@ -7,7 +7,7 @@ describe Chef::Resource::ChefNode do
|
|
7
7
|
|
8
8
|
when_the_chef_server 'is empty' do
|
9
9
|
context 'and we run a recipe that creates node "blah"' do
|
10
|
-
|
10
|
+
with_converge do
|
11
11
|
chef_node 'blah'
|
12
12
|
end
|
13
13
|
|
@@ -31,7 +31,7 @@ describe Chef::Resource::ChefNode do
|
|
31
31
|
|
32
32
|
context 'and a recipe is run that creates node "blah" on the second chef server using with_chef_server' do
|
33
33
|
|
34
|
-
|
34
|
+
with_converge do
|
35
35
|
with_chef_server 'http://127.0.0.1:8899'
|
36
36
|
chef_node 'blah'
|
37
37
|
end
|
@@ -45,7 +45,7 @@ describe Chef::Resource::ChefNode do
|
|
45
45
|
|
46
46
|
context 'and a recipe is run that creates node "blah" on the second chef server using chef_server' do
|
47
47
|
|
48
|
-
|
48
|
+
with_converge do
|
49
49
|
chef_node 'blah' do
|
50
50
|
chef_server({ :chef_server_url => 'http://127.0.0.1:8899' })
|
51
51
|
end
|
@@ -64,7 +64,7 @@ describe Chef::Resource::ChefNode do
|
|
64
64
|
when_the_chef_server 'has a node named "blah"' do
|
65
65
|
node 'blah', {}
|
66
66
|
|
67
|
-
|
67
|
+
with_converge do
|
68
68
|
chef_node 'blah'
|
69
69
|
end
|
70
70
|
|
@@ -79,7 +79,7 @@ describe Chef::Resource::ChefNode do
|
|
79
79
|
}
|
80
80
|
|
81
81
|
context 'with chef_node "blah" that sets attributes' do
|
82
|
-
|
82
|
+
with_converge do
|
83
83
|
chef_node 'blah' do
|
84
84
|
attributes({})
|
85
85
|
end
|
@@ -91,7 +91,7 @@ describe Chef::Resource::ChefNode do
|
|
91
91
|
end
|
92
92
|
|
93
93
|
context 'with chef_node "blah" that sets attributes with tags in them' do
|
94
|
-
|
94
|
+
with_converge do
|
95
95
|
chef_node 'blah' do
|
96
96
|
attributes 'tags' => [ 'c', 'd' ]
|
97
97
|
end
|
@@ -114,7 +114,7 @@ describe Chef::Resource::ChefNode do
|
|
114
114
|
}
|
115
115
|
|
116
116
|
context 'with chef_node "blah"' do
|
117
|
-
|
117
|
+
with_converge do
|
118
118
|
chef_node 'blah'
|
119
119
|
end
|
120
120
|
|
@@ -124,7 +124,7 @@ describe Chef::Resource::ChefNode do
|
|
124
124
|
end
|
125
125
|
|
126
126
|
context 'with chef_node "blah" with complete true' do
|
127
|
-
|
127
|
+
with_converge do
|
128
128
|
chef_node 'blah' do
|
129
129
|
complete true
|
130
130
|
end
|
@@ -15,7 +15,7 @@ describe Chef::Resource::ChefUser do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
context 'and we run a recipe that creates user "blah"'do
|
18
|
-
|
18
|
+
with_converge do
|
19
19
|
chef_user 'blah' do
|
20
20
|
source_key_path "#{repo_path}/blah.pem"
|
21
21
|
end
|
@@ -31,7 +31,7 @@ describe Chef::Resource::ChefUser do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
context 'and we run a recipe that creates client "blah" with output_key_path' do
|
34
|
-
|
34
|
+
with_converge do
|
35
35
|
chef_client 'blah' do
|
36
36
|
source_key_path "#{repo_path}/blah.pem"
|
37
37
|
output_key_path "#{repo_path}/blah.pub"
|
@@ -25,9 +25,17 @@ describe Chef::Resource::PrivateKey do
|
|
25
25
|
IO.read("#{repo_path}/blah").should start_with('-----BEGIN')
|
26
26
|
OpenSSL::PKey.read(IO.read("#{repo_path}/blah")).kind_of?(OpenSSL::PKey::RSA).should be_true
|
27
27
|
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'with a private key' do
|
31
|
+
before :each do
|
32
|
+
Cheffish::BasicChefClient.converge_block do
|
33
|
+
private_key "#{repo_path}/blah"
|
34
|
+
end
|
35
|
+
end
|
28
36
|
|
29
37
|
context 'and a private_key that copies it in der format' do
|
30
|
-
|
38
|
+
with_converge do
|
31
39
|
private_key "#{repo_path}/blah.der" do
|
32
40
|
source_key_path "#{repo_path}/blah"
|
33
41
|
format :der
|
@@ -74,22 +82,31 @@ describe Chef::Resource::PrivateKey do
|
|
74
82
|
"#{repo_path}/blah.der".should match_private_key("#{repo_path}/blah")
|
75
83
|
end
|
76
84
|
|
77
|
-
context 'and a public_key' do
|
78
|
-
|
85
|
+
context 'and a public_key recipe' do
|
86
|
+
with_converge do
|
79
87
|
public_key "#{repo_path}/blah.pub" do
|
80
88
|
source_key_path "#{repo_path}/blah"
|
81
89
|
end
|
82
90
|
end
|
83
91
|
|
84
92
|
it 'the public_key is created' do
|
85
|
-
chef_run.should have_updated "private_key[#{repo_path}/blah]", :create
|
86
93
|
chef_run.should have_updated "public_key[#{repo_path}/blah.pub]", :create
|
87
94
|
IO.read("#{repo_path}/blah.pub").should start_with('ssh-rsa ')
|
88
95
|
"#{repo_path}/blah.pub".should be_public_key_for "#{repo_path}/blah"
|
89
96
|
end
|
97
|
+
end
|
90
98
|
|
91
|
-
|
92
|
-
|
99
|
+
context 'and a public key' do
|
100
|
+
before :each do
|
101
|
+
Cheffish::BasicChefClient.converge_block do
|
102
|
+
public_key "#{repo_path}/blah.pub" do
|
103
|
+
source_key_path "#{repo_path}/blah"
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
context 'and public_key resource based off the public key file' do
|
109
|
+
with_converge do
|
93
110
|
public_key "#{repo_path}/blah.pub2" do
|
94
111
|
source_key_path "#{repo_path}/blah.pub"
|
95
112
|
end
|
@@ -103,7 +120,7 @@ describe Chef::Resource::PrivateKey do
|
|
103
120
|
end
|
104
121
|
|
105
122
|
context 'and another public_key based off the first public_key in-memory in a string' do
|
106
|
-
|
123
|
+
with_converge do
|
107
124
|
public_key "#{repo_path}/blah.pub2" do
|
108
125
|
source_key IO.read("#{repo_path}/blah.pub")
|
109
126
|
end
|
@@ -131,7 +148,7 @@ describe Chef::Resource::PrivateKey do
|
|
131
148
|
end
|
132
149
|
|
133
150
|
context 'and another public_key in :pem format based off the first public_key' do
|
134
|
-
|
151
|
+
with_converge do
|
135
152
|
public_key "#{repo_path}/blah.pub2" do
|
136
153
|
source_key_path "#{repo_path}/blah.pub"
|
137
154
|
format :pem
|
@@ -146,7 +163,7 @@ describe Chef::Resource::PrivateKey do
|
|
146
163
|
end
|
147
164
|
|
148
165
|
context 'and another public_key in :der format based off the first public_key' do
|
149
|
-
|
166
|
+
with_converge do
|
150
167
|
public_key "#{repo_path}/blah.pub2" do
|
151
168
|
source_key_path "#{repo_path}/blah.pub"
|
152
169
|
format :pem
|
@@ -161,8 +178,8 @@ describe Chef::Resource::PrivateKey do
|
|
161
178
|
end
|
162
179
|
end
|
163
180
|
|
164
|
-
context 'and a
|
165
|
-
|
181
|
+
context 'and a public_key resource in pem format' do
|
182
|
+
with_converge do
|
166
183
|
public_key "#{repo_path}/blah.pub" do
|
167
184
|
source_key_path "#{repo_path}/blah"
|
168
185
|
format :pem
|
@@ -170,15 +187,14 @@ describe Chef::Resource::PrivateKey do
|
|
170
187
|
end
|
171
188
|
|
172
189
|
it 'the public_key is created' do
|
173
|
-
chef_run.should have_updated "private_key[#{repo_path}/blah]", :create
|
174
190
|
chef_run.should have_updated "public_key[#{repo_path}/blah.pub]", :create
|
175
191
|
IO.read("#{repo_path}/blah.pub").should start_with('-----BEGIN')
|
176
192
|
"#{repo_path}/blah.pub".should be_public_key_for "#{repo_path}/blah"
|
177
193
|
end
|
178
194
|
end
|
179
195
|
|
180
|
-
context 'and a
|
181
|
-
|
196
|
+
context 'and a public_key resource in der format' do
|
197
|
+
with_converge do
|
182
198
|
public_key "#{repo_path}/blah.pub" do
|
183
199
|
source_key_path "#{repo_path}/blah"
|
184
200
|
format :der
|
@@ -186,7 +202,6 @@ describe Chef::Resource::PrivateKey do
|
|
186
202
|
end
|
187
203
|
|
188
204
|
it 'the public_key is created in openssh format' do
|
189
|
-
chef_run.should have_updated "private_key[#{repo_path}/blah]", :create
|
190
205
|
chef_run.should have_updated "public_key[#{repo_path}/blah.pub]", :create
|
191
206
|
IO.read("#{repo_path}/blah.pub").should_not start_with('-----BEGIN')
|
192
207
|
IO.read("#{repo_path}/blah.pub").should_not start_with('ssh-rsa')
|
@@ -207,16 +222,25 @@ describe Chef::Resource::PrivateKey do
|
|
207
222
|
IO.read("#{repo_path}/blah").should_not start_with('-----BEGIN')
|
208
223
|
OpenSSL::PKey.read(IO.read("#{repo_path}/blah")).kind_of?(OpenSSL::PKey::RSA).should be_true
|
209
224
|
end
|
225
|
+
end
|
226
|
+
|
227
|
+
context 'with a private key in der format' do
|
228
|
+
before :each do
|
229
|
+
Cheffish::BasicChefClient.converge_block do
|
230
|
+
private_key "#{repo_path}/blah" do
|
231
|
+
format :der
|
232
|
+
end
|
233
|
+
end
|
234
|
+
end
|
210
235
|
|
211
236
|
context 'and a public_key' do
|
212
|
-
|
237
|
+
with_converge do
|
213
238
|
public_key "#{repo_path}/blah.pub" do
|
214
239
|
source_key_path "#{repo_path}/blah"
|
215
240
|
end
|
216
241
|
end
|
217
242
|
|
218
243
|
it 'the public_key is created in openssh format' do
|
219
|
-
chef_run.should have_updated "private_key[#{repo_path}/blah]", :create
|
220
244
|
chef_run.should have_updated "public_key[#{repo_path}/blah.pub]", :create
|
221
245
|
IO.read("#{repo_path}/blah.pub").should start_with('ssh-rsa ')
|
222
246
|
"#{repo_path}/blah.pub".should be_public_key_for "#{repo_path}/blah"
|
@@ -225,7 +249,7 @@ describe Chef::Resource::PrivateKey do
|
|
225
249
|
end
|
226
250
|
|
227
251
|
context 'with a recipe with a private_key with a pass_phrase' do
|
228
|
-
|
252
|
+
with_converge do
|
229
253
|
private_key "#{repo_path}/blah" do
|
230
254
|
pass_phrase 'hello'
|
231
255
|
end
|
@@ -236,9 +260,19 @@ describe Chef::Resource::PrivateKey do
|
|
236
260
|
IO.read("#{repo_path}/blah").should start_with('-----BEGIN')
|
237
261
|
OpenSSL::PKey.read(IO.read("#{repo_path}/blah"), 'hello').kind_of?(OpenSSL::PKey::RSA).should be_true
|
238
262
|
end
|
263
|
+
end
|
264
|
+
|
265
|
+
context 'with a private key with a pass phrase' do
|
266
|
+
before :each do
|
267
|
+
Cheffish::BasicChefClient.converge_block do
|
268
|
+
private_key "#{repo_path}/blah" do
|
269
|
+
pass_phrase 'hello'
|
270
|
+
end
|
271
|
+
end
|
272
|
+
end
|
239
273
|
|
240
274
|
context 'and a private_key that copies it in der format' do
|
241
|
-
|
275
|
+
with_converge do
|
242
276
|
private_key "#{repo_path}/blah.der" do
|
243
277
|
source_key_path "#{repo_path}/blah"
|
244
278
|
source_key_pass_phrase 'hello'
|
@@ -255,7 +289,7 @@ describe Chef::Resource::PrivateKey do
|
|
255
289
|
end
|
256
290
|
end
|
257
291
|
|
258
|
-
it 'a private_key that copies it from in-memory as a string succeeds' do
|
292
|
+
it 'a private_key resource that copies it from in-memory as a string succeeds' do
|
259
293
|
run_recipe do
|
260
294
|
private_key "#{repo_path}/blah.der" do
|
261
295
|
source_key IO.read("#{repo_path}/blah")
|
@@ -272,7 +306,7 @@ describe Chef::Resource::PrivateKey do
|
|
272
306
|
end
|
273
307
|
|
274
308
|
context 'and a public_key' do
|
275
|
-
|
309
|
+
with_converge do
|
276
310
|
public_key "#{repo_path}/blah.pub" do
|
277
311
|
source_key_path "#{repo_path}/blah"
|
278
312
|
source_key_pass_phrase 'hello'
|
@@ -280,7 +314,6 @@ describe Chef::Resource::PrivateKey do
|
|
280
314
|
end
|
281
315
|
|
282
316
|
it 'the public_key is created in openssh format' do
|
283
|
-
chef_run.should have_updated "private_key[#{repo_path}/blah]", :create
|
284
317
|
chef_run.should have_updated "public_key[#{repo_path}/blah.pub]", :create
|
285
318
|
IO.read("#{repo_path}/blah.pub").should start_with('ssh-rsa ')
|
286
319
|
"#{repo_path}/blah.pub".should be_public_key_for "#{repo_path}/blah", 'hello'
|
@@ -288,7 +321,7 @@ describe Chef::Resource::PrivateKey do
|
|
288
321
|
end
|
289
322
|
|
290
323
|
context 'and a public_key derived from the private key in an in-memory string' do
|
291
|
-
|
324
|
+
with_converge do
|
292
325
|
public_key "#{repo_path}/blah.pub" do
|
293
326
|
source_key IO.read("#{repo_path}/blah")
|
294
327
|
source_key_pass_phrase 'hello'
|
@@ -296,7 +329,6 @@ describe Chef::Resource::PrivateKey do
|
|
296
329
|
end
|
297
330
|
|
298
331
|
it 'the public_key is created in openssh format' do
|
299
|
-
chef_run.should have_updated "private_key[#{repo_path}/blah]", :create
|
300
332
|
chef_run.should have_updated "public_key[#{repo_path}/blah.pub]", :create
|
301
333
|
IO.read("#{repo_path}/blah.pub").should start_with('ssh-rsa ')
|
302
334
|
"#{repo_path}/blah.pub".should be_public_key_for "#{repo_path}/blah", 'hello'
|
@@ -305,7 +337,7 @@ describe Chef::Resource::PrivateKey do
|
|
305
337
|
end
|
306
338
|
|
307
339
|
context 'with a recipe with a private_key and public_key_path' do
|
308
|
-
|
340
|
+
with_converge do
|
309
341
|
private_key "#{repo_path}/blah" do
|
310
342
|
public_key_path "#{repo_path}/blah.pub"
|
311
343
|
end
|
@@ -321,7 +353,7 @@ describe Chef::Resource::PrivateKey do
|
|
321
353
|
end
|
322
354
|
|
323
355
|
context 'with a recipe with a private_key and public_key_path and public_key_format' do
|
324
|
-
|
356
|
+
with_converge do
|
325
357
|
private_key "#{repo_path}/blah" do
|
326
358
|
public_key_path "#{repo_path}/blah.pub.der"
|
327
359
|
public_key_format :der
|
@@ -353,4 +385,3 @@ describe Chef::Resource::PrivateKey do
|
|
353
385
|
end
|
354
386
|
|
355
387
|
end
|
356
|
-
|
@@ -1,11 +1,7 @@
|
|
1
1
|
require 'chef_zero/rspec'
|
2
|
-
require 'chef/recipe'
|
3
|
-
require 'chef/run_context'
|
4
|
-
require 'chef/event_dispatch/dispatcher'
|
5
|
-
require 'chef/cookbook/cookbook_collection'
|
6
|
-
require 'chef/runner'
|
7
2
|
require 'chef/server_api'
|
8
3
|
require 'cheffish'
|
4
|
+
require 'cheffish/basic_chef_client'
|
9
5
|
|
10
6
|
module SpecSupport
|
11
7
|
include ChefZero::RSpec
|
@@ -17,34 +13,61 @@ module SpecSupport
|
|
17
13
|
end
|
18
14
|
|
19
15
|
def chef_run
|
20
|
-
|
16
|
+
converge if !@converged
|
17
|
+
event_sink.events
|
21
18
|
end
|
22
19
|
|
23
|
-
def
|
24
|
-
@
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
20
|
+
def event_sink
|
21
|
+
@event_sink ||= EventSink.new
|
22
|
+
end
|
23
|
+
|
24
|
+
def basic_chef_client
|
25
|
+
@basic_chef_client ||= begin
|
26
|
+
Cheffish::BasicChefClient.new(nil, event_sink)
|
30
27
|
end
|
31
28
|
end
|
32
29
|
|
33
|
-
def
|
34
|
-
|
30
|
+
def load_recipe(&block)
|
31
|
+
basic_chef_client.load_block(&block)
|
35
32
|
end
|
36
33
|
|
37
34
|
def run_recipe(&block)
|
38
|
-
|
39
|
-
|
40
|
-
|
35
|
+
load_recipe(&block)
|
36
|
+
converge
|
37
|
+
end
|
38
|
+
|
39
|
+
def reset_chef_client
|
40
|
+
@event_sink = nil
|
41
|
+
@basic_chef_client = nil
|
42
|
+
@converged = false
|
43
|
+
end
|
44
|
+
|
45
|
+
def converge
|
46
|
+
if @converged
|
47
|
+
raise "Already converged! Cannot converge twice, that's bad mojo."
|
48
|
+
end
|
49
|
+
@converged = true
|
50
|
+
basic_chef_client.converge
|
41
51
|
end
|
42
52
|
end
|
43
53
|
end
|
44
54
|
|
45
55
|
def with_recipe(&block)
|
46
56
|
before :each do
|
47
|
-
|
57
|
+
load_recipe(&block)
|
58
|
+
end
|
59
|
+
|
60
|
+
after :each do
|
61
|
+
if !@converged
|
62
|
+
raise "Never tried to converge!"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def with_converge(&block)
|
68
|
+
before :each do
|
69
|
+
load_recipe(&block) if block_given?
|
70
|
+
converge
|
48
71
|
end
|
49
72
|
end
|
50
73
|
|
metadata
CHANGED
@@ -1,69 +1,78 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cheffish
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.4.1
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- John Keiser
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
12
|
+
date: 2014-05-07 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: chef
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
|
-
- - '>='
|
19
|
+
- - ! '>='
|
18
20
|
- !ruby/object:Gem::Version
|
19
21
|
version: '0'
|
20
22
|
type: :runtime
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
|
-
- - '>='
|
27
|
+
- - ! '>='
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '0'
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: openssl_pkcs8
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
|
-
- - '>='
|
35
|
+
- - ! '>='
|
32
36
|
- !ruby/object:Gem::Version
|
33
37
|
version: '0'
|
34
38
|
type: :runtime
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
|
-
- - '>='
|
43
|
+
- - ! '>='
|
39
44
|
- !ruby/object:Gem::Version
|
40
45
|
version: '0'
|
41
46
|
- !ruby/object:Gem::Dependency
|
42
47
|
name: rake
|
43
48
|
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
44
50
|
requirements:
|
45
|
-
- - '>='
|
51
|
+
- - ! '>='
|
46
52
|
- !ruby/object:Gem::Version
|
47
53
|
version: '0'
|
48
54
|
type: :development
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
51
58
|
requirements:
|
52
|
-
- - '>='
|
59
|
+
- - ! '>='
|
53
60
|
- !ruby/object:Gem::Version
|
54
61
|
version: '0'
|
55
62
|
- !ruby/object:Gem::Dependency
|
56
63
|
name: rspec
|
57
64
|
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
58
66
|
requirements:
|
59
|
-
- - '>='
|
67
|
+
- - ! '>='
|
60
68
|
- !ruby/object:Gem::Version
|
61
69
|
version: '0'
|
62
70
|
type: :development
|
63
71
|
prerelease: false
|
64
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
65
74
|
requirements:
|
66
|
-
- - '>='
|
75
|
+
- - ! '>='
|
67
76
|
- !ruby/object:Gem::Version
|
68
77
|
version: '0'
|
69
78
|
description: A library to manipulate Chef in Chef.
|
@@ -117,26 +126,27 @@ files:
|
|
117
126
|
- spec/support/spec_support.rb
|
118
127
|
homepage: http://wiki.opscode.com/display/chef
|
119
128
|
licenses: []
|
120
|
-
metadata: {}
|
121
129
|
post_install_message:
|
122
130
|
rdoc_options: []
|
123
131
|
require_paths:
|
124
132
|
- lib
|
125
133
|
required_ruby_version: !ruby/object:Gem::Requirement
|
134
|
+
none: false
|
126
135
|
requirements:
|
127
|
-
- - '>='
|
136
|
+
- - ! '>='
|
128
137
|
- !ruby/object:Gem::Version
|
129
138
|
version: '0'
|
130
139
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
140
|
+
none: false
|
131
141
|
requirements:
|
132
|
-
- - '>='
|
142
|
+
- - ! '>='
|
133
143
|
- !ruby/object:Gem::Version
|
134
144
|
version: '0'
|
135
145
|
requirements: []
|
136
146
|
rubyforge_project:
|
137
|
-
rubygems_version:
|
147
|
+
rubygems_version: 1.8.23
|
138
148
|
signing_key:
|
139
|
-
specification_version:
|
149
|
+
specification_version: 3
|
140
150
|
summary: A library to manipulate Chef in Chef.
|
141
151
|
test_files: []
|
142
152
|
has_rdoc:
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 2c99e67f4f2af51e4be1bb7f4d127973b0060789
|
4
|
-
data.tar.gz: e8547a16bc4df37aa4d29b00f6f36af3ec57c381
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 5ac67f69abb511dab697a2a6d77b058dcfb665864d0d647b332a7a820cb59e576406fbabb1fb22a417c2dbb4cb66b7683d537ebe1b97dfa1779a4e985577dcea
|
7
|
-
data.tar.gz: 85e3d63ac54c4b1665d2b4957be6982731f1a701cab9709537e545890c7415331773c47ff187cbf31a1b5328813cd6c8c6d361ad1aa9a4404f8a73a49c1b0f89
|