summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThom May <thom@chef.io>2016-05-11 16:54:39 +0100
committerThom May <thom@chef.io>2016-05-16 13:38:22 +0100
commit36a6c01de1ef24ddb70748023885edac171f9a39 (patch)
tree749ba54164b95ddb6b5dc6c4ccff1a93067caaf9
parentebc0903ebfc3f1e656e52c4a4ece60e08a34bdca (diff)
downloadchef-tm/zolo.tar.gz
move legacy config into a separate functiontm/zolo
per review Signed-off-by: Thom May <thom@may.lt>
-rw-r--r--lib/chef/application/solo.rb55
1 files changed, 29 insertions, 26 deletions
diff --git a/lib/chef/application/solo.rb b/lib/chef/application/solo.rb
index 98d9acca5e..bc2d279508 100644
--- a/lib/chef/application/solo.rb
+++ b/lib/chef/application/solo.rb
@@ -234,39 +234,42 @@ class Chef::Application::Solo < Chef::Application
if !Chef::Config[:solo_legacy_mode]
Chef::Config[:local_mode] = true
else
+ configure_legacy_mode!
+ end
+ end
- if Chef::Config[:daemonize]
- Chef::Config[:interval] ||= 1800
- end
-
- Chef::Application.fatal!(unforked_interval_error_message) if !Chef::Config[:client_fork] && Chef::Config[:interval]
+ def configure_legacy_mode!
+ if Chef::Config[:daemonize]
+ Chef::Config[:interval] ||= 1800
+ end
- if Chef::Config[:recipe_url]
- cookbooks_path = Array(Chef::Config[:cookbook_path]).detect { |e| Pathname.new(e).cleanpath.to_s =~ /\/cookbooks\/*$/ }
- recipes_path = File.expand_path(File.join(cookbooks_path, ".."))
+ Chef::Application.fatal!(unforked_interval_error_message) if !Chef::Config[:client_fork] && Chef::Config[:interval]
- 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)
- result = shell_out!("tar zxvf #{tarball_path} -C #{recipes_path}")
- Chef::Log.debug "#{result.stdout}"
- end
+ if Chef::Config[:recipe_url]
+ cookbooks_path = Array(Chef::Config[:cookbook_path]).detect { |e| Pathname.new(e).cleanpath.to_s =~ /\/cookbooks\/*$/ }
+ recipes_path = File.expand_path(File.join(cookbooks_path, ".."))
- # json_attribs shuld be fetched after recipe_url tarball is unpacked.
- # Otherwise it may fail if points to local file from tarball.
- if Chef::Config[:json_attribs]
- config_fetcher = Chef::ConfigFetcher.new(Chef::Config[:json_attribs])
- @chef_client_json = config_fetcher.fetch_json
+ 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)
+ result = shell_out!("tar zxvf #{tarball_path} -C #{recipes_path}")
+ Chef::Log.debug "#{result.stdout}"
+ end
- # Disable auditing for solo
- Chef::Config[:audit_mode] = :disabled
+ # json_attribs shuld be fetched after recipe_url tarball is unpacked.
+ # Otherwise it may fail if points to local file from tarball.
+ if Chef::Config[:json_attribs]
+ config_fetcher = Chef::ConfigFetcher.new(Chef::Config[:json_attribs])
+ @chef_client_json = config_fetcher.fetch_json
end
+
+ # Disable auditing for solo
+ Chef::Config[:audit_mode] = :disabled
end
def setup_application