diff options
-rw-r--r-- | lib/chef/shell.rb | 27 | ||||
-rw-r--r-- | lib/chef/shell/shell_session.rb | 6 |
2 files changed, 28 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 diff --git a/lib/chef/shell/shell_session.rb b/lib/chef/shell/shell_session.rb index bbe7de8b29..41d5bd64a0 100644 --- a/lib/chef/shell/shell_session.rb +++ b/lib/chef/shell/shell_session.rb @@ -227,6 +227,12 @@ module Shell end + class SoloSession < ClientSession + + session_type :solo + + end + class DoppelGangerClient < Chef::Client attr_reader :node_name |