diff options
author | Sean Walberg <sean@ertw.com> | 2015-04-09 09:54:49 -0500 |
---|---|---|
committer | Sean Walberg <sean@ertw.com> | 2015-04-09 10:02:18 -0500 |
commit | f6835a4f5af4a380d7e35e32ddd8c3a0fe7f2ac3 (patch) | |
tree | 0e4485067263b8fc2e1a8f0a00cca45918e534a1 | |
parent | 4cdce72a39b6f2e9ad0eb3029d861c99494738f0 (diff) | |
download | chef-f6835a4f5af4a380d7e35e32ddd8c3a0fe7f2ac3.tar.gz |
If tags are present, add to the first-boot.json
Thanks to @coderanger from IRC for pointing me in the right direction.
I also snuck in a whitespace fix
-rw-r--r-- | lib/chef/knife/core/bootstrap_context.rb | 7 | ||||
-rw-r--r-- | spec/unit/knife/core/bootstrap_context_spec.rb | 7 |
2 files changed, 12 insertions, 2 deletions
diff --git a/lib/chef/knife/core/bootstrap_context.rb b/lib/chef/knife/core/bootstrap_context.rb index 7197653489..867b6fe366 100644 --- a/lib/chef/knife/core/bootstrap_context.rb +++ b/lib/chef/knife/core/bootstrap_context.rb @@ -163,11 +163,14 @@ CONFIG end def first_boot - (@config[:first_boot_attributes] || {}).merge(:run_list => @run_list) + (@config[:first_boot_attributes] || {}).tap do |attributes| + attributes.merge!(:run_list => @run_list) + attributes.merge!(:tags => @config[:tags]) if @config[:tags] && !@config[:tags].empty? + end end private - + # Returns a string for copying the trusted certificates on the workstation to the system being bootstrapped # This string should contain both the commands necessary to both create the files, as well as their content def trusted_certs_content diff --git a/spec/unit/knife/core/bootstrap_context_spec.rb b/spec/unit/knife/core/bootstrap_context_spec.rb index 3718cb228c..268b61c756 100644 --- a/spec/unit/knife/core/bootstrap_context_spec.rb +++ b/spec/unit/knife/core/bootstrap_context_spec.rb @@ -97,6 +97,13 @@ EXPECTED end end + describe "when tags are given" do + let(:config) { {:tags => [ "unicorn" ] } } + it "adds the attributes to first_boot" do + expect(Chef::JSONCompat.to_json(bootstrap_context.first_boot)).to eq(Chef::JSONCompat.to_json({:run_list => run_list, :tags => ["unicorn"]})) + end + end + describe "when JSON attributes are given" do let(:config) { {:first_boot_attributes => {:baz => :quux}} } it "adds the attributes to first_boot" do |