kitchen-salt 0.0.17 → 0.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZWQxMDZhMzQ4YmZiZjZkYzU5ZDUxZGFkODc2ZDBkMmNiMTY5MjRlYQ==
4
+ YmZkODE1Yjg1ZDI3NGE3ZDRmOTRmMzdjM2E1NzdlODc4ZTlhNjA2MA==
5
5
  data.tar.gz: !binary |-
6
- ZTY2ODFjOTQ5ODAwNDdjMmY1ZjA1MGUyZDYzYTgzNWY5MzlkMGQ0NA==
6
+ ZDI5ZTVjMjg4ZGQxZmUwMDRjOGYyZTljNTdmZDY0MTQzOGI2NzA1OQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YTJlOWJjMmY0YjIzZjJmNzQ2ZDY1ODMxZTI3NTZkMWM5YzMyNjczYWM4OTc0
10
- N2I0ZGUyMzZkNWQxYTNmMGNlMDRmNTczM2ZmZWQ3NzM4ZDNiY2E3YTQ3MzE4
11
- ZGI5NjZjZDk4YTJmYmZmMzk1MDBjYWMzZmVhMzYyYWNkYzBlYTY=
9
+ ODgxZDY3NjY1ODMyM2E4OGRlMTBjMmMyNjMxNDVjOGI2ODI4NmM1NzllMGYw
10
+ NmM0ZjA2ZTAxOWFlZTU3YWNlZTg3ZTU3M2JkYTAwOGUzZjBhNGFiZDgyYzY5
11
+ OTg5M2E4Mjg5YjRkYmFiOGIwMDYxZjc1NjYxNzFiMmVjZmI5MzY=
12
12
  data.tar.gz: !binary |-
13
- OWQzNzZlYzk1ODA3YTVmNjQ5NGYxY2U0MWU1N2NmMmJjOWU2OWI0YmM2OGQx
14
- ZDI2ODlhOWU5OTQxZTY4NmRhYWU2OGQzNWU4YmZkOGQ3YjYwMzIwYjZkZmE0
15
- ZDAxNGU3MDIyYWI1MmU5ODEyZGY0ZmRlZWM0M2I5ZWM2NDJlN2M=
13
+ YzMzMmExODUzMDkzYzdhYzNjNzJmOGZkMTViZGI2NzVkOGE5NTA5ZWI2MDVm
14
+ Y2ZjM2FkMzc1ZGE3YjU1YzExMzllMGEwMTgzNDU0YTNiYjNkN2FhNjFhYjM1
15
+ NjMxYjUzNmNlMGY2ZmIyNTEwODNhMmNjZjM0YjJkYWJhYTcwNWM=
@@ -1,5 +1,5 @@
1
1
  module Kitchen
2
2
  module Salt
3
- VERSION = "0.0.17"
3
+ VERSION = "0.0.18"
4
4
  end
5
5
  end
@@ -17,6 +17,8 @@
17
17
  # limitations under the License.
18
18
 
19
19
  require 'kitchen/provisioner/base'
20
+ require 'find'
21
+ require 'fileutils'
20
22
  require 'yaml'
21
23
 
22
24
  module Kitchen
@@ -51,6 +53,9 @@ module Kitchen
51
53
  default_config :state_top, {}
52
54
  default_config :state_top_from_file, false
53
55
  default_config :salt_run_highstate, true
56
+ default_config :salt_copy_filter, []
57
+ default_config :is_file_root, false
58
+
54
59
 
55
60
  # salt-call version that supports the undocumented --retcode-passthrough command
56
61
  RETCODE_VERSION = '0.17.5'
@@ -146,7 +151,7 @@ module Kitchen
146
151
  prepare_state_top
147
152
  prepare_pillars
148
153
  prepare_grains
149
- if config[:state_collection]
154
+ if config[:state_collection] || config[:is_file_root]
150
155
  prepare_state_collection
151
156
  else
152
157
  prepare_formula
@@ -179,8 +184,7 @@ module Kitchen
179
184
  end
180
185
 
181
186
  # scan the output for signs of failure, there is a risk of false negatives
182
- fail_grep = 'grep -e Result.*False -e Data.failed.to.compile'
183
- fail_grep = 'grep -e Result.*False'
187
+ fail_grep = 'grep -e Result.*False -e Data.failed.to.compile -e No.matching.sls.found.for'
184
188
  # capture any non-zero exit codes from the salt-call | tee pipe
185
189
  cmd = 'set -o pipefail ; ' << cmd
186
190
  # Capture the salt-call output & exit code
@@ -203,7 +207,8 @@ module Kitchen
203
207
 
204
208
  tmpdata_dir = File.join(sandbox_path, "data")
205
209
  FileUtils.mkdir_p(tmpdata_dir)
206
- FileUtils.cp_r(Dir.glob("#{config[:data_path]}/*"), tmpdata_dir)
210
+ #FileUtils.cp_r(Dir.glob("#{config[:data_path]}/*"), tmpdata_dir)
211
+ cp_r_with_filter(config[:data_path], tmpdata_dir, config[:salt_copy_filter])
207
212
  end
208
213
 
209
214
  def prepare_minion
@@ -270,17 +275,9 @@ module Kitchen
270
275
  info("Preparing pillars into #{config[:salt_pillar_root]}")
271
276
  debug("Pillars Hash: #{config[:pillars]}")
272
277
 
273
- # load any pillars from disk, if specified
274
- if !config[:'pillars-from-files'].nil?
275
- external_pillars = unsymbolize(config[:'pillars-from-files'])
276
- debug("external_pillars (unsymbolize): #{external_pillars}")
277
- external_pillars.each do |key, value|
278
- debug("loading externalpillar: #{key}, #{value}")
279
- config[:pillars][key] = YAML.load(File.read(value))
280
- end
281
- end
278
+ return if config[:pillars].nil? && config[:'pillars-from-files'].nil?
279
+
282
280
 
283
- return if config[:pillars].nil?
284
281
 
285
282
  # we get a hash with all the keys converted to symbols, salt doesn't like this
286
283
  # to convert all the keys back to strings again
@@ -308,6 +305,22 @@ module Kitchen
308
305
  file.write(pillar)
309
306
  end
310
307
  end
308
+
309
+ # copy the pillars from files straight across, as YAML.load/to_yaml and
310
+ # munge multiline strings
311
+ if !config[:'pillars-from-files'].nil?
312
+ external_pillars = unsymbolize(config[:'pillars-from-files'])
313
+ debug("external_pillars (unsymbolize): #{external_pillars}")
314
+ external_pillars.each do |key, srcfile|
315
+ debug("Copying external pillar: #{key}, #{srcfile}")
316
+ # generate the filename
317
+ sandbox_pillar_path = File.join(sandbox_path, config[:salt_pillar_root], key)
318
+ # create the directory where the pillar file will go
319
+ FileUtils.mkdir_p(File.dirname(sandbox_pillar_path))
320
+ # copy the file across
321
+ FileUtils.copy srcfile, sandbox_pillar_path
322
+ end
323
+ end
311
324
  end
312
325
 
313
326
  def prepare_grains
@@ -341,7 +354,8 @@ module Kitchen
341
354
 
342
355
  formula_dir = File.join(sandbox_path, config[:salt_file_root], config[:formula])
343
356
  FileUtils.mkdir_p(formula_dir)
344
- FileUtils.cp_r(Dir.glob(File.join(config[:kitchen_root], config[:formula], "*")), formula_dir)
357
+ #FileUtils.cp_r(Dir.glob(File.join(config[:kitchen_root], config[:formula], "*")), formula_dir)
358
+ cp_r_with_filter(File.join(config[:kitchen_root], config[:formula]), formula_dir, config[:salt_copy_filter])
345
359
 
346
360
  # copy across the _modules etc directories for python implementation
347
361
  ['_modules', '_states', '_grains', '_renderers', '_returners'].each do |extrapath|
@@ -351,7 +365,8 @@ module Kitchen
351
365
  debug("prepare_formula: #{src} exists, copying..")
352
366
  extrapath_dir = File.join(sandbox_path, config[:salt_file_root], extrapath)
353
367
  FileUtils.mkdir_p(extrapath_dir)
354
- FileUtils.cp_r(Dir.glob(File.join(src, "*")), extrapath_dir)
368
+ #FileUtils.cp_r(Dir.glob(File.join(src, "*")), extrapath_dir)
369
+ cp_r_with_filter(src, extrapath_dir, config[:salt_copy_filter])
355
370
  else
356
371
  debug("prepare_formula: #{src} doesn't exist, skipping.")
357
372
  end
@@ -363,8 +378,8 @@ module Kitchen
363
378
  debug("Using config #{config}")
364
379
 
365
380
  if config[:collection_name].nil? and config[:formula].nil?
366
- error("neither collection_name or formula have been set!")
367
- exit(2)
381
+ info("neither collection_name or formula have been set, assuming this is a pre-built collection")
382
+ config[:collection_name] = ""
368
383
  else
369
384
  if config[:collection_name].nil?
370
385
  debug("collection_name not set, using #{config[:formula]}")
@@ -377,9 +392,32 @@ module Kitchen
377
392
  debug("collection_name = #{config[:collection_name]}")
378
393
  collection_dir = File.join(sandbox_path, config[:salt_file_root], config[:collection_name])
379
394
  FileUtils.mkdir_p(collection_dir)
380
- FileUtils.cp_r(Dir.glob(File.join(config[:kitchen_root], "*")), collection_dir)
395
+ cp_r_with_filter(config[:kitchen_root], collection_dir, config[:salt_copy_filter])
381
396
 
382
397
  end
398
+
399
+ def cp_r_with_filter(source_path, target_path, filter=[])
400
+ debug("cp_r_with_filter:source_path = #{source_path}")
401
+ debug("cp_r_with_filter:target_path = #{target_path}")
402
+ debug("cp_r_with_filter:filter = #{filter}")
403
+
404
+ Array(source_path).each do |source_path|
405
+ Find.find(source_path) do |source|
406
+ target = source.sub(/^#{source_path}/, target_path)
407
+ debug("cp_r_with_filter:source = #{source}")
408
+ debug("cp_r_with_filter:target = #{target}")
409
+ if File.directory? source
410
+ if filter.include?(File.basename(source))
411
+ debug("Found #{source} in #{filter}, pruning it from the Find")
412
+ Find.prune
413
+ end
414
+ FileUtils.mkdir target unless File.exists? target
415
+ else
416
+ FileUtils.copy source, target
417
+ end
418
+ end
419
+ end
420
+ end
383
421
  end
384
422
  end
385
423
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-salt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.17
4
+ version: 0.0.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon McCartney
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-22 00:00:00.000000000 Z
11
+ date: 2014-06-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: salt provisioner for test-kitchen
14
14
  email: