Created
October 14, 2014 01:34
-
-
Save Maniacal/baf48edf29cfba541db3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define :deploy_archive, :type => "zip" do | |
module_name = params[:name] | |
destination = params[:destination] | |
bundle_path = "#{Chef::Config[:file_cache_path]}/#{node['deployment']['id']}" | |
execute "Clean out destination" do | |
user 'root' | |
command "rm -rf #{destination}/*" | |
action :run | |
end | |
# Set extract command based on data read in from the deployment manifest | |
ruby_block "Set extract command" do | |
block do | |
module_file = node['deployment']['manifest']['packages'][module_name] | |
archive = "#{Chef::Config[:file_cache_path]}/#{node['deployment']['id']}/#{module_name}/#{module_file}" | |
# Obtain the desired resource from resource_collection | |
execute_res = run_context.resource_collection.find(:execute => "Extract archive") | |
# Update the command attribute | |
case params[:type] | |
when 'zip' | |
execute_res.command "unzip -oq #{archive}" | |
when 'tar_gz' | |
execute_res.command "tar -xzf #{archive}" | |
end | |
end | |
end | |
execute "Extract archive" do | |
cwd destination | |
user 'root' | |
# 'command' parameter set to "true" to get through convergence. Is overwritten during | |
# the run by the ruby_block above | |
command "true" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment