summaryrefslogtreecommitdiff
path: root/lib/chef/application/client.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef/application/client.rb')
-rw-r--r--lib/chef/application/client.rb13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/chef/application/client.rb b/lib/chef/application/client.rb
index e9973a1131..b936741f70 100644
--- a/lib/chef/application/client.rb
+++ b/lib/chef/application/client.rb
@@ -275,11 +275,22 @@ class Chef::Application::Client < Chef::Application
def load_config_file
Chef::Config.config_file_jail = config[:config_file_jail] if config[:config_file_jail]
if !config.has_key?(:config_file)
+ # If config_file is not specified in the command line, check to see if the default
+ # config file exists
+ default_config_path = Chef::Config.platform_specific_path("/etc/chef/client.rb")
+ config_fetcher = Chef::ConfigFetcher.new(default_config_path, Chef::Config.config_file_jail)
+
+ # If the default config doesn't exist and if server is not specified in the command line
+ # options, switch local mode on.
+ if config_fetcher.config_missing? && config[:chef_server_url].nil?
+ config[:local_mode] = true
+ end
+
if config[:local_mode]
require 'chef/knife'
config[:config_file] = Chef::Knife.locate_config_file
else
- config[:config_file] = Chef::Config.platform_specific_path("/etc/chef/client.rb")
+ config[:config_file] = default_config_path
end
end
super