summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanielsdeleo <dan@chef.io>2015-09-17 16:14:03 -0700
committerdanielsdeleo <dan@chef.io>2015-09-21 09:07:28 -0700
commit6a3ff229c9db3c9811ada59aed2ead80efe699b4 (patch)
treedfef01974745109f6dd7ed0fdafd4d553877cc64
parent3bffbc968d4dc76cd6992c603f849cf46fd759dc (diff)
downloadchef-6a3ff229c9db3c9811ada59aed2ead80efe699b4.tar.gz
Configure named run list via command line or config file
-rw-r--r--chef-config/lib/chef-config/config.rb6
-rw-r--r--lib/chef/application/client.rb6
-rw-r--r--spec/unit/application/client_spec.rb13
3 files changed, 25 insertions, 0 deletions
diff --git a/chef-config/lib/chef-config/config.rb b/chef-config/lib/chef-config/config.rb
index 76ee589ff9..32058f283a 100644
--- a/chef-config/lib/chef-config/config.rb
+++ b/chef-config/lib/chef-config/config.rb
@@ -356,6 +356,12 @@ module ChefConfig
default :policy_name, nil
default :policy_group, nil
+ # Policyfiles can have multiple run lists, via the named run list feature.
+ # Generally this will be set by a CLI option via Chef::Application::Client,
+ # but it could be set in client.rb if desired.
+
+ default :named_run_list, nil
+
# During initial development, users were required to set `use_policyfile true`
# in `client.rb` to opt-in to policyfile use. Chef Client now examines
# configuration, node json, and the stored node to determine if policyfile
diff --git a/lib/chef/application/client.rb b/lib/chef/application/client.rb
index 73eda81343..148257ab89 100644
--- a/lib/chef/application/client.rb
+++ b/lib/chef/application/client.rb
@@ -160,6 +160,12 @@ class Chef::Application::Client < Chef::Application
:description => "Set the client key file location",
:proc => nil
+ option :named_run_list,
+ :short => "-n NAMED_RUN_LIST",
+ :long => "--named-run-list NAMED_RUN_LIST",
+ :description => "Use a policyfile's named run list instead of the default run list",
+ :default => nil
+
option :environment,
:short => '-E ENVIRONMENT',
:long => '--environment ENVIRONMENT',
diff --git a/spec/unit/application/client_spec.rb b/spec/unit/application/client_spec.rb
index 64a6bcc9d2..49da62c719 100644
--- a/spec/unit/application/client_spec.rb
+++ b/spec/unit/application/client_spec.rb
@@ -47,6 +47,19 @@ describe Chef::Application::Client, "reconfigure" do
expect(app).to receive(:set_specific_recipes).and_return(true)
app.reconfigure
end
+
+ context "when given a named_run_list" do
+
+ before do
+ ARGV.replace( %w[ --named-run-list arglebargle-example ] )
+ app.reconfigure
+ end
+
+ it "sets named_run_list in Chef::Config" do
+ expect(Chef::Config[:named_run_list]).to eq("arglebargle-example")
+ end
+
+ end
end
describe "when configured to not fork the client process" do