From f8223d470494361b44bf62749b44080e191990cf Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 6 Dec 2013 12:26:48 -0800 Subject: [PATCH] provisioners/chef: support proper counter for multiple chefs --- plugins/provisioners/chef/config/base.rb | 10 ++++++++++ plugins/provisioners/chef/provisioner/base.rb | 9 --------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/plugins/provisioners/chef/config/base.rb b/plugins/provisioners/chef/config/base.rb index 514353813..5b1ebff83 100644 --- a/plugins/provisioners/chef/config/base.rb +++ b/plugins/provisioners/chef/config/base.rb @@ -1,7 +1,11 @@ +require "vagrant/util/counter" + module VagrantPlugins module Chef module Config class Base < Vagrant.plugin("2", :config) + extend Vagrant::Util::Counter + attr_accessor :arguments attr_accessor :attempts attr_accessor :binary_path @@ -74,6 +78,12 @@ module VagrantPlugins # Make sure the log level is a symbol @log_level = @log_level.to_sym + + # Set the default provisioning path to be a unique path in /tmp + if !@provisioning_path + counter = self.class.get_and_update_counter(:chef_config) + @provisioning_path = "/tmp/vagrant-chef-#{counter}" + end end def merge(other) diff --git a/plugins/provisioners/chef/provisioner/base.rb b/plugins/provisioners/chef/provisioner/base.rb index f62666078..312905f7b 100644 --- a/plugins/provisioners/chef/provisioner/base.rb +++ b/plugins/provisioners/chef/provisioner/base.rb @@ -1,6 +1,5 @@ require 'tempfile' -require "vagrant/util/counter" require "vagrant/util/template_renderer" module VagrantPlugins @@ -14,14 +13,6 @@ module VagrantPlugins error_namespace("vagrant.provisioners.chef") end - include Vagrant::Util::Counter - - def initialize(machine, config) - super - - config.provisioning_path ||= "/tmp/vagrant-chef-#{get_and_update_counter(:provisioning_path)}" - end - def verify_binary(binary) # Checks for the existence of chef binary and error if it # doesn't exist.