diff --git a/plugins/provisioners/chef/config/chef_apply.rb b/plugins/provisioners/chef/config/chef_apply.rb index 9f313b790..8f7081875 100644 --- a/plugins/provisioners/chef/config/chef_apply.rb +++ b/plugins/provisioners/chef/config/chef_apply.rb @@ -24,11 +24,7 @@ module VagrantPlugins super @recipe = nil if @recipe == UNSET_VALUE - - if @upload_path == UNSET_VALUE - counter = self.class.get_and_update_counter(:chef_apply) - @upload_path = "/tmp/vagrant-chef-apply-#{counter}" - end + @upload_path = "/tmp/vagrant-chef-apply" if @upload_path == UNSET_VALUE end def validate(machine) diff --git a/plugins/provisioners/chef/provisioner/chef_apply.rb b/plugins/provisioners/chef/provisioner/chef_apply.rb index ed857c3b3..a4fdcc145 100644 --- a/plugins/provisioners/chef/provisioner/chef_apply.rb +++ b/plugins/provisioners/chef/provisioner/chef_apply.rb @@ -1,3 +1,4 @@ +require "digest/md5" require "tempfile" require_relative "base" @@ -41,8 +42,8 @@ module VagrantPlugins # The destination (on the guest) where the recipe will live # @return [String] - def target_recipe_path - File.join(config.upload_path, "recipe.rb") + def target_recipe_path(key) + File.join(config.upload_path, "recipe-#{key}.rb") end # Write the raw recipe contents to a tempfile and upload that to the @@ -54,7 +55,9 @@ module VagrantPlugins file.rewind # Upload the tempfile to the guest - @machine.communicate.upload(file.path, target_recipe_path) + @machine.communicate.upload( + file.path, + target_recipe_path(Digest::MD5.hexdigest(config.recipe))) ensure # Delete our template file.close diff --git a/test/unit/plugins/provisioners/chef/config/base_runner_test.rb b/test/unit/plugins/provisioners/chef/config/base_runner_test.rb index 591ec743e..330c31616 100644 --- a/test/unit/plugins/provisioners/chef/config/base_runner_test.rb +++ b/test/unit/plugins/provisioners/chef/config/base_runner_test.rb @@ -123,7 +123,7 @@ describe VagrantPlugins::Chef::Config::BaseRunner do describe "#provisioning_path" do it "defaults to a tmp_path" do subject.finalize! - expect(subject.provisioning_path).to match(%r{/tmp/vagrant-chef-\d+}) + expect(subject.provisioning_path).to eq("/tmp/vagrant-chef") end end diff --git a/test/unit/plugins/provisioners/chef/config/chef_apply_test.rb b/test/unit/plugins/provisioners/chef/config/chef_apply_test.rb index 242eda7ad..135c04213 100644 --- a/test/unit/plugins/provisioners/chef/config/chef_apply_test.rb +++ b/test/unit/plugins/provisioners/chef/config/chef_apply_test.rb @@ -23,7 +23,7 @@ describe VagrantPlugins::Chef::Config::ChefApply do describe "#upload_path" do it "defaults to /tmp/vagrant-chef-apply.rb" do subject.finalize! - expect(subject.upload_path).to match(%r{/tmp/vagrant-chef-apply-\d+}) + expect(subject.upload_path).to eq("/tmp/vagrant-chef-apply") end end