-
Notifications
You must be signed in to change notification settings - Fork 91
/
deploy.rb
697 lines (624 loc) · 24.3 KB
/
deploy.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
#
# Cookbook Name:: artifact
# Provider:: deploy
#
# Author:: Jamie Winsor (<jamie@vialstudios.com>)
# Author:: Kyle Allan (<kallan@riotgames.com>)
#
# Copyright 2013, Riot Games
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
require 'digest'
require 'pathname'
require 'yaml'
attr_reader :release_path
attr_reader :current_path
attr_reader :shared_path
attr_reader :artifact_cache
attr_reader :artifact_cache_version_path
attr_reader :manifest_file
attr_reader :previous_version_paths
attr_reader :previous_version_numbers
attr_reader :artifact_location
attr_reader :artifact_version
attr_reader :nexus_configuration_object
attr_reader :nexus_connection
include Chef::Artifact::Helpers
def load_current_resource
if Chef::Artifact.latest?(@new_resource.version) && Chef::Artifact.from_http?(@new_resource.artifact_location)
Chef::Application.fatal! "You cannot specify the latest version for an artifact when attempting to download an artifact using http(s)!"
end
if @new_resource.name =~ /\s/
Chef::Log.warn "Whitespace detected in resource name. Failing Chef run."
Chef::Application.fatal! "The name attribute for this resource is significant, and there cannot be whitespace. The preferred usage is to use the name of the artifact."
end
if Chef::Artifact.from_nexus?(@new_resource.artifact_location)
chef_gem "nexus_cli" do
version "4.0.2"
end
@nexus_configuration_object = new_resource.nexus_configuration
@nexus_connection = Chef::Artifact::Nexus.new(node, nexus_configuration_object)
coordinates = [@new_resource.artifact_location, @new_resource.version].join(':')
@artifact_version = nexus_connection.get_actual_version(coordinates)
artifact = NexusCli::Artifact.new(coordinates)
if artifact.classifier.nil?
@artifact_location = "#{artifact.group_id}:#{artifact.artifact_id}:#{artifact.extension}:#{artifact_version}"
else
@artifact_location = "#{artifact.group_id}:#{artifact.artifact_id}:#{artifact.extension}:#{artifact.classifier}:#{artifact_version}"
end
elsif Chef::Artifact.from_s3?(@new_resource.artifact_location)
unless Chef::Artifact.windows?
case node['platform_family']
when 'debian'
nokogiri_requirements = %W{gcc make libxml2 libxslt1.1 libxml2-dev libxslt1-dev}
when 'rhel'
nokogiri_requirements = %W{gcc make libxml2 libxslt libxml2-devel libxslt-devel patch}
else
Chef::Log.warn "Watch out, you might not be able to install the nokogiri gem!"
end
nokogiri_requirements.each do |nokogiri_requirement|
package nokogiri_requirement do
action :nothing
end.run_action(:install)
end
end
chef_gem "aws-sdk" do
version "1.29.0"
end
@artifact_version = @new_resource.version
@artifact_location = @new_resource.artifact_location
else
@artifact_version = @new_resource.version
@artifact_location = @new_resource.artifact_location
end
@release_path = get_release_path
@current_path = @new_resource.current_path
@shared_path = @new_resource.shared_path
@artifact_cache = ::File.join(@new_resource.artifact_deploys_cache_path, @new_resource.name)
@artifact_cache_version_path = ::File.join(artifact_cache, artifact_version)
@previous_version_paths = get_previous_version_paths
@previous_version_numbers = get_previous_version_numbers
@manifest_file = ::File.join(@release_path, "manifest.yaml")
@deploy = false
@skip_manifest_check = @new_resource.skip_manifest_check
@remove_on_force = @new_resource.remove_on_force
@nexus_configuration_object = @new_resource.nexus_configuration
@current_resource = Chef::Resource::ArtifactDeploy.new(@new_resource.name)
@current_resource
end
action :deploy do
delete_current_if_forcing!
setup_deploy_directories!
setup_shared_directories!
@deploy = manifest_differences?
retrieve_artifact!
run_proc :before_deploy
if deploy?
run_proc :before_extract
if new_resource.is_tarball
extract_artifact!
else
copy_artifact
end
run_proc :after_extract
run_proc :before_symlink
symlink_it_up!
run_proc :after_symlink
end
run_proc :configure
if deploy? && new_resource.should_migrate
run_proc :before_migrate
run_proc :migrate
run_proc :after_migrate
end
if deploy? || manifest_differences? || current_symlink_changing?
run_proc :restart
end
recipe_eval do
if !@new_resource.use_symlinks
if !is_current_using_symlinks?
directory current_path do
recursive true
action :delete
end
else
execute "delete the link current at #{current_path}" do
command "rmdir #{current_path}"
end
end
directory current_path do
recursive true
action :create
end
execute "copy artifact from #{release_path} to #{current_path}" do
command Chef::Artifact.copy_command_for(release_path, current_path)
end
Chef::Artifact.write_current_symlink_to(@new_resource.deploy_to, release_path)
else
if !is_current_using_symlinks?
if ::File.exist? "#{new_resource.deploy_to}/.symlinks"
execute "delete the .symlinks file at #{new_resource.deploy_to}/.symlinks" do
command "rm #{new_resource.deploy_to}/.symlinks"
end
end
directory current_path do
recursive true
action :delete
end
else
if Chef::Artifact.windows?
# Needed until CHEF-3960 is fixed.
symlink_changing = current_symlink_changing?
execute "delete the symlink at #{new_resource.current_path}" do
command "rmdir #{new_resource.current_path}"
only_if {Chef::Artifact.symlink?(new_resource.current_path) && symlink_changing}
end
end
end
link new_resource.current_path do
to release_path
owner new_resource.owner
group new_resource.group
end
end
end
run_proc :after_deploy
recipe_eval { write_manifest } unless skip_manifest_check?
delete_previous_versions!
new_resource.updated_by_last_action(true)
end
action :pre_seed do
setup_deploy_directories!
retrieve_artifact!
end
# Extracts the artifact defined in the resource call. Handles
# a variety of 'tar' based files (tar.gz, tgz, tar, tar.bz2, tbz)
# and a few 'zip' based files (zip, war, jar).
#
# @return [void]
def extract_artifact!
recipe_eval do
case ::File.extname(cached_tar_path)
when /(tar|tgz|tar\.gz|tbz2|tbz|tar\.xz)$/
taropts = [ '-x' ]
taropts.push('-z') if cached_tar_path.match(/(tgz|tar\.gz)$/)
taropts.push('-j') if cached_tar_path.match(/(tbz2|tbz)$/)
taropts.push('-J') if cached_tar_path.match(/tar\.xz$/)
taropts = taropts.join(' ')
execute "extract_artifact!" do
command "tar #{taropts} -f #{cached_tar_path} -C #{release_path}"
user new_resource.owner unless Chef::Artifact.windows?
group new_resource.group unless Chef::Artifact.windows?
retries 2
end
when /zip$/
if Chef::Artifact.windows?
windows_zipfile release_path do
source cached_tar_path
overwrite true
retries 2
end
else
package "unzip"
execute "extract_artifact!" do
command "unzip -q -u -o #{cached_tar_path} -d #{release_path}"
user new_resource.owner
group new_resource.group
retries 2
end
end
when /(war|jar)$/
ruby_block "Copy War/JAR File to Release_Path" do
block do
::FileUtils.cp "#{cached_tar_path}", "#{release_path}"
end
end
else
Chef::Application.fatal! "Cannot extract artifact because of its extension. Supported types are [tar.gz tgz tar tar.bz2 tbz zip war jar]."
end
# Working with artifacts that are packaged under an extra top level directory
# can be cumbersome. Remove it if a top level directory exists and the user
# says to
release_pathname = Pathname.new(release_path)
ruby_block "remove top level" do
block do
top_level_dir = release_pathname.children.first.to_s
::FileUtils.mv(release_pathname.children.first.children, release_path)
::FileUtils.rm_rf(top_level_dir)
end
only_if do
new_resource.remove_top_level_directory &&
release_pathname.children.size == 1 &&
release_pathname.children.first.directory?
end
end
end
end
# Copies the artifact from its cached path to its release path. The cached path is
# the configured Chef::Config[:file_cache_path]/artifact_deploys
#
# @example
# cp /tmp/vagrant-chef-1/artifact_deploys/artifact_test/1.0.0/my-artifact /srv/artifact_test/releases/1.0.0
#
# @return [void]
def copy_artifact
recipe_eval do
execute "copy artifact" do
command Chef::Artifact.copy_command_for(cached_tar_path, release_path)
user new_resource.owner unless Chef::Artifact.windows?
group new_resource.group unless Chef::Artifact.windows?
end
end
end
# Returns the file path to the cached artifact the resource is installing.
#
# @return [String] the path to the cached artifact
def cached_tar_path
::File.join(artifact_cache_version_path, artifact_filename)
end
# Returns the filename of the artifact being installed when the LWRP
# is called. Depending on how the resource is called in a recipe, the
# value returned by this method will change. If Chef::Artifact.from_nexus?, return the
# concatination of "artifact_id-version.extension" otherwise return the
# basename of where the artifact is located.
#
# @example
# When: new_resource.artifact_location => "com.artifact:my-artifact:1.0.0:tgz"
# artifact_filename => "my-artifact-1.0.0.tgz"
# When: new_resource.artifact_location => "http://some-site.com/my-artifact.jar"
# artifact_filename => "my-artifact.jar"
#
# @return [String] the artifacts filename
def artifact_filename
if Chef::Artifact.from_nexus?(new_resource.artifact_location)
artifact = NexusCli::Artifact.new(artifact_location)
artifact.file_name
else
::File.basename(artifact_location)
end
end
# Deletes the current version if and only if it is the same
# as the one to be installed, we are forcing, and remove_on_force is
# set. Only bad people will use this.
def delete_current_if_forcing!
return unless @new_resource.force
return unless remove_on_force?
return unless get_current_release_version == artifact_version || previous_version_numbers.include?(artifact_version)
recipe_eval do
log "artifact_deploy[delete_current_if_forcing!] #{artifact_version} deleted because remove_on_force is true" do
level :info
end
directory ::File.join(new_resource.deploy_to, 'releases', artifact_version) do
recursive true
action :delete
end
end
end
# Deletes released versions of the artifact when the number of
# released versions exceeds the :keep value.
def delete_previous_versions!
recipe_eval do
versions_to_delete = []
keep = new_resource.keep
delete_first = total = get_previous_version_paths.length
if total == 0 || total <= keep
true
else
delete_first -= keep
Chef::Log.info "artifact_deploy[delete_previous_versions!] is deleting #{delete_first} of #{total} old versions (keeping: #{keep})"
versions_to_delete = get_previous_version_paths.shift(delete_first)
end
versions_to_delete.each do |version|
log "artifact_deploy[delete_previous_versions!] #{version.basename} deleted" do
level :info
end
directory ::File.join(artifact_cache, version.basename) do
recursive true
action :delete
end
directory ::File.join(new_resource.deploy_to, 'releases', version.basename) do
recursive true
action :delete
end
end
end
end
private
def location_parts(location)
group_id, artifact_id, extension, classifier, version = location.split(":")
unless version
version = classifier
classifier = nil
end
[group_id, artifact_id, extension, classifier, version]
end
# A wrapper that calls Chef::Artifact:run_proc
#
# @param name [Symbol] the name of the proc to execute
#
# @return [void]
def run_proc(name)
execute_run_proc("artifact_deploy", new_resource, name)
end
# Checks the various cases of whether an artifact has or has not been installed. If the artifact
# has been installed let #has_manifest_changed? determine the return value.
#
# @return [Boolean]
def manifest_differences?
if new_resource.force
Chef::Log.debug "artifact_deploy[manifest_differences?] Force attribute has been set for #{new_resource.name}."
Chef::Log.info "artifact_deploy[manifest_differences?] Installing version, #{artifact_version} for #{new_resource.name}."
return true
elsif get_current_release_version.nil?
Chef::Log.debug "artifact_deploy[manifest_differences?] No current version installed for #{new_resource.name}."
Chef::Log.info "artifact_deploy[manifest_differences?] Installing version, #{artifact_version} for #{new_resource.name}."
return true
elsif artifact_version != get_current_release_version && !previous_version_numbers.include?(artifact_version)
Chef::Log.debug "artifact_deploy[manifest_differences?] Currently installed version of artifact is #{get_current_release_version}."
Chef::Log.debug "artifact_deploy[manifest_differences?] Version #{artifact_version} for #{new_resource.name} has not already been installed."
Chef::Log.info "artifact_deploy[manifest_differences?] Installing version, #{artifact_version} for #{new_resource.name}."
return true
elsif artifact_version != get_current_release_version && previous_version_numbers.include?(artifact_version)
Chef::Log.info "artifact_deploy[manifest_differences?] Version #{artifact_version} of artifact has already been installed."
return has_manifest_changed?
elsif artifact_version == get_current_release_version
Chef::Log.info "artifact_deploy[manifest_differences?] Currently installed version of artifact is #{artifact_version}."
return has_manifest_changed?
end
end
# Loads the saved manifest.yaml file and generates a new, current manifest. The
# saved manifest is then parsed through looking for files that may have been deleted,
# added, or modified.
#
# @return [Boolean]
def has_manifest_changed?
Chef::Log.debug "artifact_deploy[has_manifest_changed?] Loading manifest.yaml file from directory: #{release_path}"
begin
saved_manifest = YAML.load_file(::File.join(release_path, "manifest.yaml"))
rescue Errno::ENOENT
unless skip_manifest_check?
Chef::Log.warn "artifact_deploy[has_manifest_changed?] Cannot load manifest.yaml. It may have been deleted. Deploying."
return true
end
end
if skip_manifest_check?
Chef::Log.debug "artifact_deploy[has_manifest_changed?] Skip Manifest Check attribute is true. Skipping manifest check."
return false
end
current_manifest = generate_manifest(release_path)
Chef::Log.debug "artifact_deploy[has_manifest_changed?] Comparing saved manifest from #{release_path} with regenerated manifest from #{release_path}."
differences = !saved_manifest.diff(current_manifest).empty?
if differences
Chef::Log.info "artifact_deploy[has_manifest_changed?] Saved manifest from #{release_path} differs from regenerated manifest. Deploying."
return true
else
Chef::Log.info "artifact_deploy[has_manifest_changed?] Saved manifest from #{release_path} is the same as regenerated manifest. Not Deploying."
return false
end
end
# Checks the not-equality of the current_release_version against the version of
# the currently configured resource. Returns true when the current symlink will
# be changed to a different release of the artifact at the end of the resource
# call.
#
# @return [Boolean]
def current_symlink_changing?
get_current_release_version != ::File.basename(release_path)
end
# @return [Boolean] the deploy instance variable
def deploy?
@deploy
end
# @return [Boolean] the skip_manifest_check instance variable
def skip_manifest_check?
@skip_manifest_check
end
# @return [Boolean] the remove_on_force instance variable
def remove_on_force?
@remove_on_force
end
# @return [String] the current version the current symlink points to
def get_current_release_version
Chef::Artifact.get_current_deployed_version(new_resource.deploy_to)
end
# @return [Boolean] the current artifact is deployed using symlinks
def is_current_using_symlinks?
Chef::Artifact.symlink? new_resource.current_path
end
# Returns a path to the artifact being installed by
# the configured resource.
#
# @example
# When:
# new_resource.deploy_to = "/srv/artifact_test" and artifact_version = "1.0.0"
# get_release_path => "/srv/artifact_test/releases/1.0.0"
#
# @return [String] the artifacts release path
def get_release_path
::File.join(new_resource.deploy_to, "releases", artifact_version)
end
# Searches the releases directory and returns an Array of version folders. After
# rejecting the current release version from the Array, the array is sorted by mtime
# and returned.
#
# @return [Array] the mtime sorted array of currently installed versions
def get_previous_version_paths
versions = Dir[::File.join(new_resource.deploy_to, "releases", '**')].collect do |v|
Pathname.new(v)
end
versions.reject! { |v| v.basename.to_s == get_current_release_version }
versions.sort_by(&:mtime)
end
# Convenience method for returning just the version numbers of
# the currently installed versions of the artifact.
#
# @return [Array] the currently installed version numbers
def get_previous_version_numbers
previous_version_paths.collect { |version| version.basename.to_s}
end
# Creates directories and symlinks as defined by the symlinks
# attribute of the resource.
#
# @return [void]
def symlink_it_up!
recipe_eval do
new_resource.symlinks.each do |key, value|
Chef::Log.info "artifact_deploy[symlink_it_up!] Creating and linking #{new_resource.shared_path}/#{key} to #{release_path}/#{value}"
directory "#{new_resource.shared_path}/#{key}" do
owner new_resource.owner
group new_resource.group
mode '0755'
recursive true
end
link "#{release_path}/#{value}" do
to "#{new_resource.shared_path}/#{key}"
owner new_resource.owner
group new_resource.group
end
end
end
end
# Creates directories that are necessary for installing
# the artifact.
#
# @return [void]
def setup_deploy_directories!
recipe_eval do
[ artifact_cache_version_path, release_path, shared_path ].each do |path|
Chef::Log.info "artifact_deploy[setup_deploy_directories!] Creating #{path}"
directory path do
owner new_resource.owner
group new_resource.group
mode '0755'
recursive true
end
end
end
end
# Creates directories that are defined in the shared_directories
# attribute of the resource.
#
# @return [void]
def setup_shared_directories!
recipe_eval do
new_resource.shared_directories.each do |dir|
Chef::Log.info "artifact_deploy[setup_shared_directories!] Creating #{shared_path}/#{dir}"
directory "#{shared_path}/#{dir}" do
owner new_resource.owner
group new_resource.group
mode '0755'
recursive true
end
end
end
end
# Retrieves the configured artifact based on the
# artifact_location instance variable.
#
# @return [void]
def retrieve_artifact!
recipe_eval do
if Chef::Artifact.from_http?(new_resource.artifact_location)
Chef::Log.info "artifact_deploy[retrieve_artifact!] Retrieving artifact from #{artifact_location}"
retrieve_from_http
elsif Chef::Artifact.from_nexus?(new_resource.artifact_location)
Chef::Log.info "artifact_deploy[retrieve_artifact!] Retrieving artifact from Nexus using #{artifact_location}"
retrieve_from_nexus
elsif Chef::Artifact.from_s3?(new_resource.artifact_location)
Chef::Log.info "artifact_deploy[retrieve_artifact!] Retrieving artifact from S3 using #{artifact_location}"
retrieve_from_s3
elsif ::File.exist?(new_resource.artifact_location)
Chef::Log.info "artifact_deploy[retrieve_artifact!] Retrieving artifact local path #{artifact_location}"
retrieve_from_local
else
Chef::Application.fatal! "artifact_deploy[retrieve_artifact!] Cannot retrieve artifact #{artifact_location}! Please make sure the artifact exists in the specified location."
end
end
end
# Defines a resource call for downloading the remote artifact.
#
# @return [void]
def retrieve_from_http
artifact_file cached_tar_path do
location new_resource.artifact_location
after_download new_resource.after_download
owner new_resource.owner
group new_resource.group
checksum new_resource.artifact_checksum
download_retries new_resource.download_retries
action :create
end
end
# Defines a artifact_file resource call to download an artifact from Nexus.
#
# @return [void]
def retrieve_from_nexus
artifact_file cached_tar_path do
location artifact_location
after_download new_resource.after_download
owner new_resource.owner
group new_resource.group
nexus_configuration nexus_configuration_object
download_retries new_resource.download_retries
action :create
end
end
# Defines a artifact_file resource call to download an artifact from S3.
#
# @return [void]
def retrieve_from_s3
artifact_file cached_tar_path do
location new_resource.artifact_location
after_download new_resource.after_download
owner new_resource.owner
group new_resource.group
checksum new_resource.artifact_checksum
download_retries new_resource.download_retries
action :create
end
end
# Defines a resource call for a file already on the file system.
#
# @return [void]
def retrieve_from_local
execute "copy artifact from #{new_resource.artifact_location} to #{cached_tar_path}" do
command Chef::Artifact.copy_command_for(new_resource.artifact_location, cached_tar_path)
user new_resource.owner unless Chef::Artifact.windows?
group new_resource.group unless Chef::Artifact.windows?
only_if { !::File.exists?(cached_tar_path) || !FileUtils.compare_file(new_resource.artifact_location, cached_tar_path) }
end
end
# Generates a manifest for all the files underneath the given files_path. SHA1 digests will be
# generated for all files under the given files_path with the exception of directories and the
# manifest.yaml file itself.
#
# @param files_path [String] a path to the files that a manfiest will be generated for
#
# @return [Hash] a mapping of file_path => SHA1 of that file
def generate_manifest(files_path)
Chef::Log.debug "artifact_deploy[generate_manifest] Generating manifest for files in #{files_path}"
files_in_release_path = Dir[::File.join(files_path, "**/*")].reject { |file| ::File.directory?(file) || file =~ /manifest.yaml/ || Chef::Artifact.symlink?(file) }
{}.tap do |map|
files_in_release_path.each { |file| map[file] = Digest::SHA1.file(file).hexdigest }
end
end
# Generates a manfiest Hash for the files under the release_path and
# writes a YAML dump of the created Hash to manifest_file.
#
# @return [String] a String of the YAML dumped to the manifest.yaml file
def write_manifest
manifest = generate_manifest(release_path)
Chef::Log.debug "artifact_deploy[write_manifest] Writing manifest.yaml file to #{manifest_file}"
::File.open(manifest_file, "w") { |file| file.puts YAML.dump(manifest) }
end