diff options
author | danielsdeleo <dan@chef.io> | 2015-09-22 15:40:34 -0700 |
---|---|---|
committer | danielsdeleo <dan@chef.io> | 2015-09-24 12:37:26 -0700 |
commit | e92665d448eaaf92fdfb5bb3cdb4be3a2ddad9ac (patch) | |
tree | 63a028fc8b41dbb63e40a71266558812ce5b6e28 | |
parent | efe6286540a56960e109dcc65db63cc7461c1753 (diff) | |
download | chef-e92665d448eaaf92fdfb5bb3cdb4be3a2ddad9ac.tar.gz |
Add policyfile support to bootstrap context
-rw-r--r-- | lib/chef/knife/core/bootstrap_context.rb | 7 | ||||
-rw-r--r-- | spec/unit/knife/core/bootstrap_context_spec.rb | 10 |
2 files changed, 16 insertions, 1 deletions
diff --git a/lib/chef/knife/core/bootstrap_context.rb b/lib/chef/knife/core/bootstrap_context.rb index 867b6fe366..d85ee91490 100644 --- a/lib/chef/knife/core/bootstrap_context.rb +++ b/lib/chef/knife/core/bootstrap_context.rb @@ -164,7 +164,12 @@ CONFIG def first_boot (@config[:first_boot_attributes] || {}).tap do |attributes| - attributes.merge!(:run_list => @run_list) + if @config[:policy_name] && @config[:policy_group] + attributes.merge!(:policy_name => @config[:policy_name], :policy_group => @config[:policy_group]) + else + attributes.merge!(:run_list => @run_list) + end + attributes.merge!(:tags => @config[:tags]) if @config[:tags] && !@config[:tags].empty? end end diff --git a/spec/unit/knife/core/bootstrap_context_spec.rb b/spec/unit/knife/core/bootstrap_context_spec.rb index 268b61c756..a93e5362a9 100644 --- a/spec/unit/knife/core/bootstrap_context_spec.rb +++ b/spec/unit/knife/core/bootstrap_context_spec.rb @@ -117,6 +117,16 @@ EXPECTED end end + describe "when policy_name and policy_group are present in config" do + + let(:config) { { policy_name: "my_app_server", policy_group: "staging" } } + + it "includes them in the first_boot data and excludes run_list" do + expect(Chef::JSONCompat.to_json(bootstrap_context.first_boot)).to eq(Chef::JSONCompat.to_json(config)) + end + + end + describe "when an encrypted_data_bag_secret is provided" do let(:secret) { "supersekret" } it "reads the encrypted_data_bag_secret" do |