summaryrefslogtreecommitdiff
path: root/lib/chef/application
diff options
context:
space:
mode:
authorVasiliy Tolstov <v.tolstov@selfip.ru>2014-11-18 17:32:49 +0300
committerLamont Granquist <lamont@scriptkiddie.org>2015-01-25 13:31:53 -0800
commit38ac328723a6221349db78355e741817f2b98618 (patch)
tree364f79ec4955ba1a9e8bd6ea50d12e1b3612c8bb /lib/chef/application
parent232f823e07586f4b41c9c11b1510531975ba6f61 (diff)
downloadchef-38ac328723a6221349db78355e741817f2b98618.tar.gz
cosmetic fixes
Signed-off-by: Vasiliy Tolstov <v.tolstov@selfip.ru>
Diffstat (limited to 'lib/chef/application')
-rw-r--r--lib/chef/application/client.rb15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/chef/application/client.rb b/lib/chef/application/client.rb
index c654226d93..d7b5f858e8 100644
--- a/lib/chef/application/client.rb
+++ b/lib/chef/application/client.rb
@@ -27,6 +27,7 @@ require 'chef/handler/error_report'
require 'chef/workstation_config_loader'
class Chef::Application::Client < Chef::Application
+ include Chef::Mixin::ShellOut
# Mimic self_pipe sleep from Unicorn to capture signals safely
SELF_PIPE = []
@@ -207,7 +208,7 @@ class Chef::Application::Client < Chef::Application
option :recipe_url,
:long => "--recipe-url",
- :description => "Pull down a remote gzipped tarball of recipes and untar it to the cookbook cache. Only useful in local mode (-z/--local-mode)"
+ :description => "Pull down a remote archive of recipes and unpack it to the cookbook cache. Only used in local mode."
option :enable_reporting,
:short => "-R",
@@ -272,14 +273,22 @@ class Chef::Application::Client < Chef::Application
Chef::Config.chef_repo_path = Chef::Config.find_chef_repo_path(Dir.pwd)
end
- if Chef::Config.local_mode && Chef::Config.has_key?(:recipe_url)
+ if !Chef::Config.local_mode && Chef::Config.has_key?(:recipe_url)
+ Chef::Application.fatal!("chef-client recipe-url can be used only in local-mode", 1)
+ elsif Chef::Config.local_mode && Chef::Config.has_key?(:recipe_url)
Chef::Log.debug "Cleanup path #{Chef::Config.chef_repo_path} before extract recipes into it"
FileUtils.rm_rf(Chef::Config.chef_repo_path, :secure => true)
Chef::Log.debug "Creating path #{Chef::Config.chef_repo_path} to extract recipes into"
FileUtils.mkdir_p(Chef::Config.chef_repo_path)
tarball_path = File.join(Chef::Config.chef_repo_path, 'recipes.tgz')
fetch_recipe_tarball(Chef::Config[:recipe_url], tarball_path)
- Chef::Mixin::Command.run_command(:command => "tar zxvf #{tarball_path} -C #{Chef::Config.chef_repo_path}")
+ begin
+ result = shell_out("tar zxvf #{tarball_path} -C #{Chef::Config.chef_repo_path}")
+ Chef::Log.debug "#{result.stdout}"
+ Chef::Log.debug "#{result.stderr}"
+ rescue Mixlib::ShellOut::ShellCommandFailed => e
+ Chef::Log.error "Not able to unpack recipes archive (#{e})"
+ end
end
Chef::Config.chef_zero.host = config[:chef_zero_host] if config[:chef_zero_host]