diff options
author | Salim Afiune <afiune@chef.io> | 2017-03-14 16:49:54 -0400 |
---|---|---|
committer | Tom Duffield <tom@chef.io> | 2017-03-17 11:46:12 -0500 |
commit | 8358dca75c76eb4e342040e7efc9ec7277f8dc52 (patch) | |
tree | d3f3e84d52fd9fad6aca1dec6ca6f5e7859ddf8e /lib/chef/shell.rb | |
parent | dad266026cea748013b9b593dc88cbe523a9a623 (diff) | |
download | chef-8358dca75c76eb4e342040e7efc9ec7277f8dc52.tar.gz |
Make chef-shell to use SoloSession properly
Signed-off-by: Salim Afiune <afiune@chef.io>
Diffstat (limited to 'lib/chef/shell.rb')
-rw-r--r-- | lib/chef/shell.rb | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/lib/chef/shell.rb b/lib/chef/shell.rb index d7aff8fce6..6d6d1437e2 100644 --- a/lib/chef/shell.rb +++ b/lib/chef/shell.rb @@ -27,6 +27,7 @@ require "chef/config" require "chef/config_fetcher" require "chef/shell/shell_session" +require "chef/workstation_config_loader" require "chef/shell/ext" require "chef/json_compat" require "chef/util/path_helper" @@ -62,6 +63,12 @@ module Shell irb = IRB::Irb.new + if solo_mode? + # Setup the mocked ChefServer + Chef::Config.local_mode = true + Chef::LocalMode.setup_server_connectivity + end + init(irb.context.main) irb_conf[:IRB_RC].call(irb.context) if irb_conf[:IRB_RC] @@ -74,6 +81,13 @@ module Shell catch(:IRB_EXIT) do irb.eval_input end + ensure + # We destroy the mocked ChefServer + Chef::LocalMode.destroy_server_connectivity if solo_mode? + end + + def self.solo_mode? + Chef::Config[:solo] end def self.setup_logger @@ -167,8 +181,9 @@ module Shell def self.client_type type = Shell::StandAloneSession - type = Shell::SoloSession if Chef::Config[:shell_solo] - type = Shell::ClientSession if Chef::Config[:client] + type = Shell::SoloSession if solo_mode? + type = Shell::SoloLegacySession if Chef::Config[:solo_legacy_shell] + type = Shell::ClientSession if Chef::Config[:client] type = Shell::DoppelGangerSession if Chef::Config[:doppelganger] type end @@ -226,7 +241,7 @@ FOOTER :default => true, :boolean => true - option :shell_solo, + option :solo_shell, :short => "-s", :long => "--solo", :description => "chef-solo session", @@ -239,7 +254,7 @@ FOOTER :description => "chef-client session", :boolean => true - option :solo_legacy_mode, + option :solo_legacy_shell, :long => "--solo-legacy-mode", :description => "chef-solo legacy session", :boolean => true, @@ -319,10 +334,12 @@ FOOTER config_file_to_try elsif dot_chef_dir && ::File.exist?(File.join(dot_chef_dir, "chef_shell.rb")) File.join(dot_chef_dir, "chef_shell.rb") - elsif config[:solo_legacy_mode] + elsif config[:solo_legacy_shell] Chef::Config.platform_specific_path("/etc/chef/solo.rb") elsif config[:client] Chef::Config.platform_specific_path("/etc/chef/client.rb") + elsif config[:solo] + Chef::WorkstationConfigLoader.new(nil, Chef::Log).config_location else nil end |