cheffish 0.8 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/chef/provider/chef_mirror.rb +29 -3
- data/lib/chef/resource/chef_mirror.rb +2 -1
- data/lib/cheffish/chef_provider_base.rb +1 -1
- data/lib/cheffish/recipe_dsl.rb +1 -1
- data/lib/cheffish/version.rb +1 -1
- data/spec/integration/chef_client_spec.rb +1 -1
- data/spec/integration/chef_container_spec.rb +1 -1
- data/spec/integration/chef_group_spec.rb +1 -1
- data/spec/integration/chef_mirror_spec.rb +333 -58
- data/spec/integration/chef_node_spec.rb +45 -1
- data/spec/integration/chef_organization_spec.rb +1 -1
- data/spec/integration/chef_user_spec.rb +1 -1
- data/spec/support/spec_support.rb +6 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 338276289ac7fab89d006bc453e20266560948b7
|
4
|
+
data.tar.gz: 60ac99761729f96b46b5d12f38101fcf930008cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2fbe1a958c572c4c885d8bea5c2453bbd0cfbb9cd0fbba63a15cf47eb7266b946f66a900549b1a9f6b45186f378a01312c573accdadfc84c520b5a288a99753
|
7
|
+
data.tar.gz: 0676d6791b22f25d28ce7977b4e905e10bb8ab2cf44059af0b1cc6175ae6dcad98cebc73024dbb352829405a7237575f862559032105d13c4e95a0aa4270d7f7
|
@@ -12,11 +12,36 @@ class Chef::Provider::ChefMirror < Chef::Provider::LWRPBase
|
|
12
12
|
end
|
13
13
|
|
14
14
|
action :upload do
|
15
|
-
|
15
|
+
with_modified_config do
|
16
|
+
copy_to(local_fs, remote_fs)
|
17
|
+
end
|
16
18
|
end
|
17
19
|
|
18
20
|
action :download do
|
19
|
-
|
21
|
+
with_modified_config do
|
22
|
+
copy_to(remote_fs, local_fs)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def with_modified_config
|
27
|
+
# pre-Chef-12 ChefFS reads versioned_cookbooks out of Chef::Config instead of
|
28
|
+
# taking it as an input, so we need to modify it for the duration of copy_to
|
29
|
+
@old_versioned_cookbooks = Chef::Config.versioned_cookbooks
|
30
|
+
# If versioned_cookbooks is explicitly set, set it.
|
31
|
+
if !new_resource.versioned_cookbooks.nil?
|
32
|
+
Chef::Config.versioned_cookbooks = new_resource.versioned_cookbooks
|
33
|
+
|
34
|
+
# If new_resource.chef_repo_path is set, versioned_cookbooks defaults to true.
|
35
|
+
# Otherwise, it stays at its current Chef::Config value.
|
36
|
+
elsif new_resource.chef_repo_path
|
37
|
+
Chef::Config.versioned_cookbooks = true
|
38
|
+
end
|
39
|
+
|
40
|
+
begin
|
41
|
+
yield
|
42
|
+
ensure
|
43
|
+
Chef::Config.versioned_cookbooks = @old_versioned_cookbooks
|
44
|
+
end
|
20
45
|
end
|
21
46
|
|
22
47
|
def copy_to(src_root, dest_root)
|
@@ -84,7 +109,8 @@ class Chef::Provider::ChefMirror < Chef::Provider::LWRPBase
|
|
84
109
|
:chef_server_url => new_resource.chef_server[:chef_server_url],
|
85
110
|
:node_name => new_resource.chef_server[:options][:client_name],
|
86
111
|
:client_key => new_resource.chef_server[:options][:client_key],
|
87
|
-
:repo_mode => repo_mode
|
112
|
+
:repo_mode => repo_mode,
|
113
|
+
:versioned_cookbooks => Chef::Config.versioned_cookbooks
|
88
114
|
}
|
89
115
|
Chef::ChefFS::FileSystem::ChefServerRootDir.new("remote", config)
|
90
116
|
end
|
@@ -23,8 +23,9 @@ class Chef::Resource::ChefMirror < Chef::Resource::LWRPBase
|
|
23
23
|
# versioned_cookbooks defaults to true.
|
24
24
|
attribute :chef_repo_path, :kind_of => [ String, Hash ]
|
25
25
|
|
26
|
-
# Whether the repo path
|
26
|
+
# Whether the repo path should contain cookbooks with versioned names,
|
27
27
|
# i.e. cookbooks/mysql-1.0.0, cookbooks/mysql-1.2.0, etc.
|
28
|
+
# Defaults to true if chef_repo_path is specified, or to Chef::Config.versioned_cookbooks otherwise.
|
28
29
|
attribute :versioned_cookbooks, :kind_of => [ TrueClass, FalseClass ]
|
29
30
|
|
30
31
|
# Chef server
|
@@ -32,7 +32,7 @@ module Cheffish
|
|
32
32
|
result = normalize(resource_to_json(new_resource))
|
33
33
|
else
|
34
34
|
# If resource is incomplete, use current json to fill any holes
|
35
|
-
result =
|
35
|
+
result = Chef::Mixin::DeepMerge.hash_only_merge(current_json, resource_to_json(new_resource))
|
36
36
|
end
|
37
37
|
augment_new_json(result)
|
38
38
|
end
|
data/lib/cheffish/recipe_dsl.rb
CHANGED
data/lib/cheffish/version.rb
CHANGED
@@ -8,7 +8,7 @@ repo_path = Dir.mktmpdir('chef_repo')
|
|
8
8
|
describe Chef::Resource::ChefClient do
|
9
9
|
extend SpecSupport
|
10
10
|
|
11
|
-
|
11
|
+
when_the_chef_12_server 'is in multi-org mode' do
|
12
12
|
organization 'foo'
|
13
13
|
|
14
14
|
before :each do
|
@@ -5,7 +5,7 @@ require 'chef/provider/chef_container'
|
|
5
5
|
describe Chef::Resource::ChefContainer do
|
6
6
|
extend SpecSupport
|
7
7
|
|
8
|
-
|
8
|
+
when_the_chef_12_server 'is in multi-org mode' do
|
9
9
|
organization 'foo'
|
10
10
|
|
11
11
|
before :each do
|
@@ -5,7 +5,7 @@ require 'chef/provider/chef_group'
|
|
5
5
|
describe Chef::Resource::ChefGroup do
|
6
6
|
extend SpecSupport
|
7
7
|
|
8
|
-
|
8
|
+
when_the_chef_12_server 'is in multi-org mode' do
|
9
9
|
organization 'foo'
|
10
10
|
|
11
11
|
before :each do
|
@@ -5,17 +5,20 @@ require 'chef/provider/chef_mirror'
|
|
5
5
|
describe Chef::Resource::ChefMirror do
|
6
6
|
extend SpecSupport
|
7
7
|
|
8
|
-
|
8
|
+
when_the_chef_12_server 'is in multi-org mode' do
|
9
9
|
organization 'foo'
|
10
10
|
|
11
11
|
before :each do
|
12
12
|
Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url, '/organizations/foo').to_s
|
13
13
|
end
|
14
14
|
|
15
|
-
|
15
|
+
describe 'basic download and upload' do
|
16
16
|
when_the_repository 'is full of stuff' do
|
17
17
|
file 'nodes/x.json', {}
|
18
18
|
file 'roles/x.json', {}
|
19
|
+
directory 'cookbooks/x' do
|
20
|
+
file 'metadata.rb', 'name "x"; version "2.0.0"'
|
21
|
+
end
|
19
22
|
|
20
23
|
it "Download grabs defaults" do
|
21
24
|
run_recipe do
|
@@ -37,6 +40,7 @@ describe Chef::Resource::ChefMirror do
|
|
37
40
|
expect(chef_run).to have_updated('chef_mirror[]', :upload)
|
38
41
|
expect { get('nodes/x') }.not_to raise_error
|
39
42
|
expect { get('roles/x') }.not_to raise_error
|
43
|
+
expect { get('cookbooks/x/2.0.0') }.not_to raise_error
|
40
44
|
end
|
41
45
|
|
42
46
|
it 'chef_mirror with concurrency 0 fails with a reasonable message' do
|
@@ -50,7 +54,96 @@ describe Chef::Resource::ChefMirror do
|
|
50
54
|
}.to raise_error /chef_mirror.concurrency must be above 0/
|
51
55
|
end
|
52
56
|
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context 'and the Chef server has a node and role in it' do
|
60
|
+
node 'x', {}
|
61
|
+
role 'x', {}
|
62
|
+
|
63
|
+
when_the_repository 'is empty' do
|
64
|
+
it "Download grabs the node and role" do
|
65
|
+
run_recipe do
|
66
|
+
chef_mirror '' do
|
67
|
+
action :download
|
68
|
+
end
|
69
|
+
end
|
70
|
+
expect(chef_run).to have_updated('chef_mirror[]', :download)
|
71
|
+
expect(File.exist?(path_to('nodes/x.json'))).to be true
|
72
|
+
expect(File.exist?(path_to('roles/x.json'))).to be true
|
73
|
+
end
|
74
|
+
|
75
|
+
it "Upload uploads nothing" do
|
76
|
+
run_recipe do
|
77
|
+
chef_mirror '' do
|
78
|
+
action :upload
|
79
|
+
end
|
80
|
+
end
|
81
|
+
expect(chef_run).not_to have_updated('chef_mirror[]', :upload)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
context 'and the Chef server has nodes and roles named x' do
|
87
|
+
node 'x', {}
|
88
|
+
role 'x', {}
|
89
|
+
|
90
|
+
when_the_repository 'has nodes and roles named y' do
|
91
|
+
file 'nodes/y.json', {}
|
92
|
+
file 'roles/y.json', {}
|
93
|
+
|
94
|
+
it "Download grabs the x's" do
|
95
|
+
run_recipe do
|
96
|
+
chef_mirror '' do
|
97
|
+
action :download
|
98
|
+
end
|
99
|
+
end
|
100
|
+
expect(chef_run).to have_updated('chef_mirror[]', :download)
|
101
|
+
expect(File.exist?(path_to('nodes/x.json'))).to be true
|
102
|
+
expect(File.exist?(path_to('roles/x.json'))).to be true
|
103
|
+
expect(File.exist?(path_to('nodes/y.json'))).to be true
|
104
|
+
expect(File.exist?(path_to('roles/y.json'))).to be true
|
105
|
+
end
|
106
|
+
|
107
|
+
it "Upload uploads the y's" do
|
108
|
+
run_recipe do
|
109
|
+
chef_mirror '' do
|
110
|
+
action :upload
|
111
|
+
end
|
112
|
+
end
|
113
|
+
expect(chef_run).to have_updated('chef_mirror[]', :upload)
|
114
|
+
expect { get('nodes/x') }.not_to raise_error
|
115
|
+
expect { get('roles/x') }.not_to raise_error
|
116
|
+
expect { get('nodes/y') }.not_to raise_error
|
117
|
+
expect { get('roles/y') }.not_to raise_error
|
118
|
+
end
|
119
|
+
|
120
|
+
it "Download with purge grabs the x's and deletes the y's" do
|
121
|
+
run_recipe do
|
122
|
+
chef_mirror '' do
|
123
|
+
purge true
|
124
|
+
action :download
|
125
|
+
end
|
126
|
+
end
|
127
|
+
expect(chef_run).to have_updated('chef_mirror[]', :download)
|
128
|
+
expect(File.exist?(path_to('nodes/x.json'))).to be true
|
129
|
+
expect(File.exist?(path_to('roles/x.json'))).to be true
|
130
|
+
end
|
131
|
+
|
132
|
+
it "Upload with :purge uploads the y's and deletes the x's" do
|
133
|
+
run_recipe do
|
134
|
+
chef_mirror '*/*.json' do
|
135
|
+
purge true
|
136
|
+
action :upload
|
137
|
+
end
|
138
|
+
end
|
139
|
+
expect(chef_run).to have_updated('chef_mirror[*/*.json]', :upload)
|
140
|
+
expect { get('nodes/y') }.not_to raise_error
|
141
|
+
expect { get('roles/y') }.not_to raise_error
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
53
145
|
|
146
|
+
describe "chef_repo_path" do
|
54
147
|
when_the_repository 'has stuff but no chef_repo_path' do
|
55
148
|
file 'repo/nodes/x.json', {}
|
56
149
|
file 'repo/roles/x.json', {}
|
@@ -153,92 +246,274 @@ describe Chef::Resource::ChefMirror do
|
|
153
246
|
end
|
154
247
|
end
|
155
248
|
|
156
|
-
|
157
|
-
|
158
|
-
|
249
|
+
describe "cookbook upload, chef_repo_path and versioned_cookbooks" do
|
250
|
+
when_the_repository 'has cookbooks in non-versioned format' do
|
251
|
+
file 'cookbooks/x-1.0.0/metadata.rb', 'name "x-1.0.0"; version "2.0.0"'
|
252
|
+
file 'cookbooks/y-1.0.0/metadata.rb', 'name "y-3.0.0"; version "4.0.0"'
|
159
253
|
|
160
|
-
|
161
|
-
it "Download grabs stuff" do
|
254
|
+
it "chef_mirror :upload uploads everything" do
|
162
255
|
run_recipe do
|
163
256
|
chef_mirror '' do
|
164
|
-
action :
|
257
|
+
action :upload
|
165
258
|
end
|
166
259
|
end
|
167
|
-
expect(chef_run).to have_updated('chef_mirror[]', :
|
168
|
-
expect(
|
169
|
-
expect(
|
260
|
+
expect(chef_run).to have_updated('chef_mirror[]', :upload)
|
261
|
+
expect { get('cookbooks/x-1.0.0/2.0.0') }.not_to raise_error
|
262
|
+
expect { get('cookbooks/y-3.0.0/4.0.0') }.not_to raise_error
|
170
263
|
end
|
171
264
|
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
265
|
+
context 'and Chef::Config.versioned_cookbooks is false' do
|
266
|
+
before do
|
267
|
+
Chef::Config.versioned_cookbooks false
|
268
|
+
end
|
269
|
+
it "chef_mirror :upload uploads everything" do
|
270
|
+
run_recipe do
|
271
|
+
chef_mirror '' do
|
272
|
+
action :upload
|
273
|
+
end
|
176
274
|
end
|
275
|
+
expect(chef_run).to have_updated('chef_mirror[]', :upload)
|
276
|
+
expect { get('cookbooks/x-1.0.0/2.0.0') }.not_to raise_error
|
277
|
+
expect { get('cookbooks/y-3.0.0/4.0.0') }.not_to raise_error
|
177
278
|
end
|
178
|
-
expect(chef_run).not_to have_updated('chef_mirror[]', :upload)
|
179
279
|
end
|
180
|
-
end
|
181
|
-
end
|
182
280
|
|
183
|
-
|
184
|
-
|
185
|
-
|
281
|
+
context 'and Chef::Config.chef_repo_path is not set but versioned_cookbooks is false' do
|
282
|
+
before do
|
283
|
+
Chef::Config.delete(:chef_repo_path)
|
284
|
+
Chef::Config.versioned_cookbooks false
|
285
|
+
end
|
186
286
|
|
187
|
-
|
188
|
-
|
189
|
-
|
287
|
+
it "chef_mirror :upload with chef_repo_path and versioned_cookbooks false uploads cookbooks with name including version" do
|
288
|
+
repository_dir = @repository_dir
|
289
|
+
run_recipe do
|
290
|
+
chef_mirror '' do
|
291
|
+
chef_repo_path repository_dir
|
292
|
+
versioned_cookbooks false
|
293
|
+
action :upload
|
294
|
+
end
|
295
|
+
end
|
296
|
+
expect(chef_run).to have_updated('chef_mirror[]', :upload)
|
297
|
+
expect { get('cookbooks/x-1.0.0/2.0.0') }.not_to raise_error
|
298
|
+
expect { get('cookbooks/y-3.0.0/4.0.0') }.not_to raise_error
|
299
|
+
end
|
300
|
+
end
|
301
|
+
end
|
190
302
|
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
303
|
+
when_the_repository 'has cookbooks in versioned_cookbook format' do
|
304
|
+
file 'cookbooks/x-1.0.0/metadata.rb', 'name "x"; version "1.0.0"'
|
305
|
+
file 'cookbooks/x-2.0.0/metadata.rb', 'name "x"; version "2.0.0"'
|
306
|
+
|
307
|
+
context 'and Chef::Config.versioned_cookbooks is true' do
|
308
|
+
before do
|
309
|
+
Chef::Config.versioned_cookbooks true
|
310
|
+
end
|
311
|
+
it "chef_mirror :upload uploads everything" do
|
312
|
+
run_recipe do
|
313
|
+
chef_mirror '' do
|
314
|
+
action :upload
|
315
|
+
end
|
195
316
|
end
|
317
|
+
expect(chef_run).to have_updated('chef_mirror[]', :upload)
|
318
|
+
expect { get('cookbooks/x/1.0.0') }.not_to raise_error
|
319
|
+
expect { get('cookbooks/x/2.0.0') }.not_to raise_error
|
196
320
|
end
|
197
|
-
expect(chef_run).to have_updated('chef_mirror[]', :download)
|
198
|
-
expect(File.exist?(path_to('nodes/x.json'))).to be true
|
199
|
-
expect(File.exist?(path_to('roles/x.json'))).to be true
|
200
|
-
expect(File.exist?(path_to('nodes/y.json'))).to be true
|
201
|
-
expect(File.exist?(path_to('roles/y.json'))).to be true
|
202
321
|
end
|
203
322
|
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
323
|
+
context 'and Chef::Config.chef_repo_path set somewhere else' do
|
324
|
+
before do
|
325
|
+
Chef::Config.chef_repo_path = '/x/y/z'
|
326
|
+
end
|
327
|
+
it "chef_mirror :upload with chef_repo_path uploads cookbooks" do
|
328
|
+
repository_dir = @repository_dir
|
329
|
+
run_recipe do
|
330
|
+
chef_mirror '' do
|
331
|
+
chef_repo_path repository_dir
|
332
|
+
action :upload
|
333
|
+
end
|
208
334
|
end
|
335
|
+
expect(chef_run).to have_updated('chef_mirror[]', :upload)
|
336
|
+
expect { get('cookbooks/x/1.0.0') }.not_to raise_error
|
337
|
+
expect { get('cookbooks/x/2.0.0') }.not_to raise_error
|
209
338
|
end
|
210
|
-
expect(chef_run).to have_updated('chef_mirror[]', :upload)
|
211
|
-
expect { get('nodes/x') }.not_to raise_error
|
212
|
-
expect { get('roles/x') }.not_to raise_error
|
213
|
-
expect { get('nodes/y') }.not_to raise_error
|
214
|
-
expect { get('roles/y') }.not_to raise_error
|
215
339
|
end
|
216
340
|
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
341
|
+
context 'and Chef::Config.chef_repo_path is not set but versioned_cookbooks is false' do
|
342
|
+
before do
|
343
|
+
Chef::Config.delete(:chef_repo_path)
|
344
|
+
Chef::Config.versioned_cookbooks false
|
345
|
+
end
|
346
|
+
|
347
|
+
it "chef_mirror :upload with chef_repo_path uploads cookbooks with name split from version" do
|
348
|
+
repository_dir = @repository_dir
|
349
|
+
run_recipe do
|
350
|
+
chef_mirror '' do
|
351
|
+
chef_repo_path repository_dir
|
352
|
+
action :upload
|
353
|
+
end
|
222
354
|
end
|
355
|
+
expect(chef_run).to have_updated('chef_mirror[]', :upload)
|
356
|
+
expect { get('cookbooks/x/1.0.0') }.not_to raise_error
|
357
|
+
expect { get('cookbooks/x/2.0.0') }.not_to raise_error
|
358
|
+
end
|
359
|
+
|
360
|
+
it "chef_mirror :upload with chef_repo_path and versioned_cookbooks uploads cookbooks with name split from version" do
|
361
|
+
repository_dir = @repository_dir
|
362
|
+
run_recipe do
|
363
|
+
chef_mirror '' do
|
364
|
+
chef_repo_path repository_dir
|
365
|
+
versioned_cookbooks true
|
366
|
+
action :upload
|
367
|
+
end
|
368
|
+
end
|
369
|
+
expect(chef_run).to have_updated('chef_mirror[]', :upload)
|
370
|
+
expect { get('cookbooks/x/1.0.0') }.not_to raise_error
|
371
|
+
expect { get('cookbooks/x/2.0.0') }.not_to raise_error
|
223
372
|
end
|
224
|
-
expect(chef_run).to have_updated('chef_mirror[]', :download)
|
225
|
-
expect(File.exist?(path_to('nodes/x.json'))).to be true
|
226
|
-
expect(File.exist?(path_to('roles/x.json'))).to be true
|
227
373
|
end
|
228
374
|
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
375
|
+
context 'and Chef::Config.chef_repo_path is not set but versioned_cookbooks is true' do
|
376
|
+
before do
|
377
|
+
Chef::Config.delete(:chef_repo_path)
|
378
|
+
Chef::Config.versioned_cookbooks true
|
379
|
+
end
|
380
|
+
it "chef_mirror :upload with chef_repo_path uploads cookbooks with name split from version" do
|
381
|
+
repository_dir = @repository_dir
|
382
|
+
run_recipe do
|
383
|
+
chef_mirror '' do
|
384
|
+
chef_repo_path repository_dir
|
385
|
+
action :upload
|
386
|
+
end
|
234
387
|
end
|
388
|
+
expect(chef_run).to have_updated('chef_mirror[]', :upload)
|
389
|
+
expect { get('cookbooks/x/1.0.0') }.not_to raise_error
|
390
|
+
expect { get('cookbooks/x/2.0.0') }.not_to raise_error
|
235
391
|
end
|
236
|
-
expect(chef_run).to have_updated('chef_mirror[*/*.json]', :upload)
|
237
|
-
expect { get('nodes/y') }.not_to raise_error
|
238
|
-
expect { get('roles/y') }.not_to raise_error
|
239
392
|
end
|
240
393
|
end
|
241
394
|
end
|
242
395
|
|
396
|
+
describe 'cookbook download, chef_repo_path, and versioned_cookbooks' do
|
397
|
+
context 'when the Chef server has a cookbook with multiple versions' do
|
398
|
+
cookbook 'x', '1.0.0', 'metadata.rb' => 'name "x"; version "1.0.0"'
|
399
|
+
cookbook 'x', '2.0.0', 'metadata.rb' => 'name "x"; version "2.0.0"'
|
400
|
+
|
401
|
+
when_the_repository 'is empty' do
|
402
|
+
it 'chef_mirror :download downloads the latest version of the cookbook' do
|
403
|
+
run_recipe do
|
404
|
+
chef_mirror '' do
|
405
|
+
action :download
|
406
|
+
end
|
407
|
+
end
|
408
|
+
expect(chef_run).to have_updated('chef_mirror[]', :download)
|
409
|
+
expect(File.read(path_to('cookbooks/x/metadata.rb'))).to eq('name "x"; version "2.0.0"')
|
410
|
+
end
|
411
|
+
|
412
|
+
it 'chef_mirror :download with versioned_cookbooks = true downloads all versions of the cookbook' do
|
413
|
+
run_recipe do
|
414
|
+
chef_mirror '' do
|
415
|
+
versioned_cookbooks true
|
416
|
+
action :download
|
417
|
+
end
|
418
|
+
end
|
419
|
+
expect(chef_run).to have_updated('chef_mirror[]', :download)
|
420
|
+
expect(File.read(path_to('cookbooks/x-1.0.0/metadata.rb'))).to eq('name "x"; version "1.0.0"')
|
421
|
+
expect(File.read(path_to('cookbooks/x-2.0.0/metadata.rb'))).to eq('name "x"; version "2.0.0"')
|
422
|
+
end
|
423
|
+
|
424
|
+
context 'and Chef::Config.chef_repo_path is set elsewhere' do
|
425
|
+
before do
|
426
|
+
Chef::Config.chef_repo_path = '/x/y/z'
|
427
|
+
end
|
428
|
+
|
429
|
+
it 'chef_mirror :download with chef_repo_path downloads all versions of the cookbook' do
|
430
|
+
repository_dir = @repository_dir
|
431
|
+
run_recipe do
|
432
|
+
chef_mirror '' do
|
433
|
+
chef_repo_path repository_dir
|
434
|
+
action :download
|
435
|
+
end
|
436
|
+
end
|
437
|
+
expect(chef_run).to have_updated('chef_mirror[]', :download)
|
438
|
+
expect(File.read(path_to('cookbooks/x-1.0.0/metadata.rb'))).to eq('name "x"; version "1.0.0"')
|
439
|
+
expect(File.read(path_to('cookbooks/x-2.0.0/metadata.rb'))).to eq('name "x"; version "2.0.0"')
|
440
|
+
end
|
441
|
+
|
442
|
+
it 'chef_mirror :download with chef_repo_path and versioned_cookbooks = false downloads the latest version of the cookbook' do
|
443
|
+
repository_dir = @repository_dir
|
444
|
+
run_recipe do
|
445
|
+
chef_mirror '' do
|
446
|
+
chef_repo_path repository_dir
|
447
|
+
versioned_cookbooks false
|
448
|
+
action :download
|
449
|
+
end
|
450
|
+
end
|
451
|
+
expect(chef_run).to have_updated('chef_mirror[]', :download)
|
452
|
+
expect(File.read(path_to('cookbooks/x/metadata.rb'))).to eq('name "x"; version "2.0.0"')
|
453
|
+
end
|
454
|
+
end
|
455
|
+
|
456
|
+
context 'and Chef::Config.versioned_cookbooks is true' do
|
457
|
+
before do
|
458
|
+
Chef::Config.versioned_cookbooks = true
|
459
|
+
end
|
460
|
+
|
461
|
+
it 'chef_mirror :download downloads all versions of the cookbook' do
|
462
|
+
run_recipe do
|
463
|
+
chef_mirror '' do
|
464
|
+
action :download
|
465
|
+
end
|
466
|
+
end
|
467
|
+
expect(chef_run).to have_updated('chef_mirror[]', :download)
|
468
|
+
expect(File.read(path_to('cookbooks/x-1.0.0/metadata.rb'))).to eq('name "x"; version "1.0.0"')
|
469
|
+
expect(File.read(path_to('cookbooks/x-2.0.0/metadata.rb'))).to eq('name "x"; version "2.0.0"')
|
470
|
+
end
|
471
|
+
|
472
|
+
it 'chef_mirror :download with versioned_cookbooks = false downloads the latest version of the cookbook' do
|
473
|
+
run_recipe do
|
474
|
+
chef_mirror '' do
|
475
|
+
versioned_cookbooks false
|
476
|
+
action :download
|
477
|
+
end
|
478
|
+
end
|
479
|
+
expect(chef_run).to have_updated('chef_mirror[]', :download)
|
480
|
+
expect(File.read(path_to('cookbooks/x/metadata.rb'))).to eq('name "x"; version "2.0.0"')
|
481
|
+
end
|
482
|
+
|
483
|
+
context 'and Chef::Config.chef_repo_path is set elsewhere' do
|
484
|
+
before do
|
485
|
+
Chef::Config.chef_repo_path = '/x/y/z'
|
486
|
+
end
|
487
|
+
|
488
|
+
it 'chef_mirror :download with chef_repo_path downloads all versions of the cookbook' do
|
489
|
+
repository_dir = @repository_dir
|
490
|
+
run_recipe do
|
491
|
+
chef_mirror '' do
|
492
|
+
chef_repo_path repository_dir
|
493
|
+
action :download
|
494
|
+
end
|
495
|
+
end
|
496
|
+
expect(chef_run).to have_updated('chef_mirror[]', :download)
|
497
|
+
expect(File.read(path_to('cookbooks/x-1.0.0/metadata.rb'))).to eq('name "x"; version "1.0.0"')
|
498
|
+
expect(File.read(path_to('cookbooks/x-2.0.0/metadata.rb'))).to eq('name "x"; version "2.0.0"')
|
499
|
+
end
|
500
|
+
|
501
|
+
it 'chef_mirror :download with chef_repo_path and versioned_cookbooks = false downloads the latest version of the cookbook' do
|
502
|
+
repository_dir = @repository_dir
|
503
|
+
run_recipe do
|
504
|
+
chef_mirror '' do
|
505
|
+
chef_repo_path repository_dir
|
506
|
+
versioned_cookbooks false
|
507
|
+
action :download
|
508
|
+
end
|
509
|
+
end
|
510
|
+
expect(chef_run).to have_updated('chef_mirror[]', :download)
|
511
|
+
expect(File.read(path_to('cookbooks/x/metadata.rb'))).to eq('name "x"; version "2.0.0"')
|
512
|
+
end
|
513
|
+
end
|
514
|
+
end
|
515
|
+
end
|
516
|
+
end
|
517
|
+
end
|
243
518
|
end
|
244
519
|
end
|
@@ -5,7 +5,7 @@ require 'chef/provider/chef_node'
|
|
5
5
|
describe Chef::Resource::ChefNode do
|
6
6
|
extend SpecSupport
|
7
7
|
|
8
|
-
|
8
|
+
when_the_chef_12_server 'is in multi-org mode' do
|
9
9
|
organization 'foo'
|
10
10
|
|
11
11
|
before :each do
|
@@ -129,6 +129,34 @@ describe Chef::Resource::ChefNode do
|
|
129
129
|
end
|
130
130
|
end
|
131
131
|
|
132
|
+
context 'with chef_node "blah" and an updated normal attribute value' do
|
133
|
+
with_converge do
|
134
|
+
chef_node 'blah' do
|
135
|
+
attributes 'foo' => 'fum'
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
it 'new normal attribute is added' do
|
140
|
+
expect(chef_run).to have_updated 'chef_node[blah]', :create
|
141
|
+
node = get('nodes/blah')
|
142
|
+
expect(node['normal']).to eq({ 'foo' => 'fum', 'tags' => [ 'a', 'b' ] })
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
context 'with chef_node "blah" and a new normal attribute' do
|
147
|
+
with_converge do
|
148
|
+
chef_node 'blah' do
|
149
|
+
attributes 'foe' => 'fum'
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
it 'new normal attribute is added' do
|
154
|
+
expect(chef_run).to have_updated 'chef_node[blah]', :create
|
155
|
+
node = get('nodes/blah')
|
156
|
+
expect(node['normal']).to eq({ 'foe' => 'fum', 'foo' => 'bar', 'tags' => [ 'a', 'b' ] })
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
132
160
|
context 'with chef_node "blah" with complete true' do
|
133
161
|
with_converge do
|
134
162
|
chef_node 'blah' do
|
@@ -147,6 +175,22 @@ describe Chef::Resource::ChefNode do
|
|
147
175
|
expect(node['override']).to eq({ 'foo4' => 'bar4' })
|
148
176
|
end
|
149
177
|
end
|
178
|
+
|
179
|
+
context 'with chef_node "blah", complete true and a new normal attribute' do
|
180
|
+
with_converge do
|
181
|
+
chef_node 'blah' do
|
182
|
+
attributes 'foe' => 'fum'
|
183
|
+
complete true
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
it 'normal foo attribute is replaced with new attribute' do
|
188
|
+
expect(chef_run).to have_updated 'chef_node[blah]', :create
|
189
|
+
node = get('nodes/blah')
|
190
|
+
expect(node['normal']).to eq({ 'foe' => 'fum', 'tags' => [ 'a', 'b' ] })
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
150
194
|
end
|
151
195
|
end
|
152
196
|
|
@@ -5,7 +5,7 @@ require 'chef/provider/chef_organization'
|
|
5
5
|
describe Chef::Resource::ChefOrganization do
|
6
6
|
extend SpecSupport
|
7
7
|
|
8
|
-
|
8
|
+
when_the_chef_12_server 'is in multi-org mode' do
|
9
9
|
context 'and chef_server_url is pointed at the top level' do
|
10
10
|
user 'u', {}
|
11
11
|
user 'u2', {}
|
@@ -44,7 +44,7 @@ describe Chef::Resource::ChefUser do
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
|
47
|
+
when_the_chef_12_server 'is in multi-org mode' do
|
48
48
|
context 'and chef_server_url is pointed at the top level' do
|
49
49
|
context 'and we run a recipe that creates user "blah"'do
|
50
50
|
with_converge do
|
@@ -9,6 +9,12 @@ require 'support/repository_support'
|
|
9
9
|
module SpecSupport
|
10
10
|
include ChefZero::RSpec
|
11
11
|
|
12
|
+
def when_the_chef_12_server(*args, &block)
|
13
|
+
if Gem::Version.new(ChefZero::VERSION) >= Gem::Version.new('3.1')
|
14
|
+
when_the_chef_server(*args, :osc_compat => false, :single_org => false, &block)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
12
18
|
def self.extended(klass)
|
13
19
|
klass.class_eval do
|
14
20
|
extend RepositorySupport
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cheffish
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Keiser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chef
|