diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2016-02-10 11:48:51 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2016-02-10 11:48:51 -0800 |
commit | fcc18aa5062932ca52498328d410910d64bb0eb9 (patch) | |
tree | 1fbd1e1c7ad72895c8d413a71509b3b048dc1a16 /lib/chef/application/solo.rb | |
parent | 09d1cbfb091094c6d5e0d9b5c715c1555ac21f83 (diff) | |
download | chef-fcc18aa5062932ca52498328d410910d64bb0eb9.tar.gz |
remove rm -rf in chef solo recipe_url
- deprecates '-r' used for the recipe_url in chef-solo
- adds --delete-entire-chef-repo option for users who want the
old behavior back.
- cleans up some old code
closes #3802
closes #1515
closes #1751
Diffstat (limited to 'lib/chef/application/solo.rb')
-rw-r--r-- | lib/chef/application/solo.rb | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/lib/chef/application/solo.rb b/lib/chef/application/solo.rb index 26bd6ba52e..c5d7549ffe 100644 --- a/lib/chef/application/solo.rb +++ b/lib/chef/application/solo.rb @@ -25,8 +25,10 @@ require "chef/log" require "chef/rest" require "chef/config_fetcher" require "fileutils" +require "chef/mixin/shell_out" class Chef::Application::Solo < Chef::Application + include Chef::Mixin::ShellOut option :config_file, :short => "-c CONFIG", @@ -135,10 +137,9 @@ class Chef::Application::Solo < Chef::Application :proc => lambda { |s| s.to_i } option :recipe_url, - :short => "-r RECIPE_URL", - :long => "--recipe-url RECIPE_URL", - :description => "Pull down a remote gzipped tarball of recipes and untar it to the cookbook cache.", - :proc => nil + :short => "-r RECIPE_URL", + :long => "--recipe-url RECIPE_URL", + :description => "Pull down a remote gzipped tarball of recipes and untar it to the cookbook cache." option :version, :short => "-v", @@ -191,6 +192,11 @@ class Chef::Application::Solo < Chef::Application :description => "Only run the bare minimum ohai plugins chef needs to function", :boolean => true + option :delete_entire_chef_repo, + :long => "--delete-entire-chef-repo", + :description => "DANGEROUS: does what it says, only useful with --recipe-url", + :boolean => true + attr_reader :chef_client_json def initialize @@ -210,17 +216,22 @@ class Chef::Application::Solo < Chef::Application Chef::Application.fatal!(unforked_interval_error_message) if !Chef::Config[:client_fork] && Chef::Config[:interval] + Chef::Log.deprecation("-r MUST be changed to --recipe-url, the -r option will be changed in Chef 13.0") if ARGV.include?("-r") + if Chef::Config[:recipe_url] - cookbooks_path = Array(Chef::Config[:cookbook_path]).detect { |e| e =~ /\/cookbooks\/*$/ } + cookbooks_path = Array(Chef::Config[:cookbook_path]).detect{|e| e =~ /#{Chef::Config.platform_path_separator_escaped}cookbooks#{Chef::Config.platform_path_separator_escaped}*$/ } recipes_path = File.expand_path(File.join(cookbooks_path, "..")) - Chef::Log.debug "Cleanup path #{recipes_path} before extract recipes into it" - FileUtils.rm_rf(recipes_path, :secure => true) + if Chef::Config[:delete_entire_chef_repo] + Chef::Log.debug "Cleanup path #{recipes_path} before extract recipes into it" + FileUtils.rm_rf(recipes_path, :secure => true) + end Chef::Log.debug "Creating path #{recipes_path} to extract recipes into" FileUtils.mkdir_p(recipes_path) tarball_path = File.join(recipes_path, "recipes.tgz") fetch_recipe_tarball(Chef::Config[:recipe_url], tarball_path) - Mixlib::ShellOut.new("tar zxvf #{tarball_path} -C #{recipes_path}").run_command + result = shell_out!("tar zxvf #{tarball_path} -C #{recipes_path}") + Chef::Log.debug "#{result.stdout}" end # json_attribs shuld be fetched after recipe_url tarball is unpacked. |