summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanielsdeleo <dan@opscode.com>2014-02-19 08:59:41 -0800
committerdanielsdeleo <dan@opscode.com>2014-02-20 12:30:43 -0800
commit0b3498ffb09504225b1019a4a530256407a3e67e (patch)
treef77e83dede0291c980e349987bf286beeff6abcd
parent50847457ab95ca651c75c13a45734b25e2129eea (diff)
downloadchef-0b3498ffb09504225b1019a4a530256407a3e67e.tar.gz
Add `-r` flag to chef-client
-rw-r--r--lib/chef/application.rb3
-rw-r--r--lib/chef/application/client.rb12
-rw-r--r--spec/integration/client/client_spec.rb14
3 files changed, 27 insertions, 2 deletions
diff --git a/lib/chef/application.rb b/lib/chef/application.rb
index 04e88de2ce..601bbd91f1 100644
--- a/lib/chef/application.rb
+++ b/lib/chef/application.rb
@@ -208,7 +208,8 @@ class Chef::Application
@chef_client = Chef::Client.new(
@chef_client_json,
:override_runlist => config[:override_runlist],
- :specific_recipes => specific_recipes
+ :specific_recipes => specific_recipes,
+ :runlist => config[:runlist]
)
@chef_client_json = nil
diff --git a/lib/chef/application/client.rb b/lib/chef/application/client.rb
index de644b5f31..e14266d82a 100644
--- a/lib/chef/application/client.rb
+++ b/lib/chef/application/client.rb
@@ -170,7 +170,7 @@ class Chef::Application::Client < Chef::Application
option :override_runlist,
:short => "-o RunlistItem,RunlistItem...",
:long => "--override-runlist RunlistItem,RunlistItem...",
- :description => "Replace current run list with specified items",
+ :description => "Replace current run list with specified items for a single run",
:proc => lambda{|items|
items = items.split(',')
items.compact.map{|item|
@@ -178,6 +178,16 @@ class Chef::Application::Client < Chef::Application
}
}
+ option :runlist,
+ :short => "-r RunlistItem,RunlistItem...",
+ :long => "--runlist RunlistItem,RunlistItem...",
+ :description => "Permanently replace current run list with specified items",
+ :proc => lambda{|items|
+ items = items.split(',')
+ items.compact.map{|item|
+ Chef::RunList::RunListItem.new(item)
+ }
+ }
option :why_run,
:short => '-W',
:long => '--why-run',
diff --git a/spec/integration/client/client_spec.rb b/spec/integration/client/client_spec.rb
index bca9ed4854..6357f1e2c0 100644
--- a/spec/integration/client/client_spec.rb
+++ b/spec/integration/client/client_spec.rb
@@ -215,5 +215,19 @@ EOM
result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' -z", :cwd => chef_dir)
result.error!
end
+
+ it "should complete with success when setting the run list with -r" do
+ file 'config/client.rb', <<EOM
+chef_server_url 'http://omg.com/blah'
+cookbook_path "#{path_to('cookbooks')}"
+EOM
+
+ result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -r 'x::default' -z", :cwd => chef_dir)
+ result.stdout.should_not include("Overridden Run List")
+ result.stdout.should include("Run List is [recipe[x::default]]")
+ #puts result.stdout
+ result.error!
+ end
+
end
end