summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Cragun <me@ryan.ec>2014-05-19 16:33:37 -0700
committerRyan Cragun <me@ryan.ec>2014-05-20 16:03:31 -0700
commit840682f34c1785426794ff7f656d339d3e276110 (patch)
treed161d665e19c0195b99cab5d5f40a55b33a08855
parent62103f41818f897330b1ed424334d1eb88bcef41 (diff)
downloadchef-840682f34c1785426794ff7f656d339d3e276110.tar.gz
[CHEF-5314] Support override_runlist CLI option in shef/chef-shell
-rw-r--r--lib/chef/shell.rb7
-rw-r--r--lib/chef/shell/shell_session.rb6
2 files changed, 10 insertions, 3 deletions
diff --git a/lib/chef/shell.rb b/lib/chef/shell.rb
index 0788962e62..568e70c36f 100644
--- a/lib/chef/shell.rb
+++ b/lib/chef/shell.rb
@@ -53,6 +53,7 @@ module Shell
IRB::ExtendCommandBundle.instance_variable_get(:@ALIASES).delete(irb_help)
parse_opts
+ Chef::Config[:shell_config] = options.config
# HACK: this duplicates the functions of IRB.start, but we have to do it
# to get access to the main object before irb starts.
@@ -257,6 +258,12 @@ FOOTER
:proc => lambda {|v| puts "Chef: #{::Chef::VERSION}"},
:exit => 0
+ option :override_runlist,
+ :short => "-o RunlistItem,RunlistItem...",
+ :long => "--override-runlist RunlistItem,RunlistItem...",
+ :description => "Replace current run list with specified items",
+ :proc => lambda { |items| items.split(',').map { |item| Chef::RunList::RunListItem.new(item) }}
+
def self.print_help
instance = new
instance.parse_options([])
diff --git a/lib/chef/shell/shell_session.rb b/lib/chef/shell/shell_session.rb
index 2f4d9375eb..a158020116 100644
--- a/lib/chef/shell/shell_session.rb
+++ b/lib/chef/shell/shell_session.rb
@@ -151,7 +151,7 @@ module Shell
def rebuild_node
Chef::Config[:solo] = true
- @client = Chef::Client.new
+ @client = Chef::Client.new(nil, Chef::Config[:shell_config])
@client.run_ohai
@client.load_node
@client.build_node
@@ -183,7 +183,7 @@ module Shell
def rebuild_node
# Tell the client we're chef solo so it won't try to contact the server
Chef::Config[:solo] = true
- @client = Chef::Client.new
+ @client = Chef::Client.new(nil, Chef::Config[:shell_config])
@client.run_ohai
@client.load_node
@client.build_node
@@ -214,7 +214,7 @@ module Shell
def rebuild_node
# Make sure the client knows this is not chef solo
Chef::Config[:solo] = false
- @client = Chef::Client.new
+ @client = Chef::Client.new(nil, Chef::Config[:shell_config])
@client.run_ohai
@client.register
@client.load_node