Multiple Chef provisioners no longer overwrite cookbook folders. [closes GH-407]

This commit is contained in:
Mitchell Hashimoto 2011-07-07 22:49:58 -07:00
parent 729d62d1ea
commit e625dba5ab
4 changed files with 11 additions and 6 deletions

View File

@ -18,6 +18,7 @@
`merge` technique. [GH-314]
- Provisioner configuration is no longer cleared when the box
needs to be downloaded during an `up`. [GH-308]
- Multiple Chef provisioners no longer overwrite cookbook folders. [GH-407]
## 0.7.6 (July 2, 2011)

View File

@ -76,6 +76,8 @@ module Vagrant
class Chef < Base
# This is the configuration which is available through `config.chef`
class Config < Vagrant::Config::Base
extend Util::Counter
# Shared config
attr_accessor :node_name
attr_accessor :provisioning_path
@ -93,7 +95,7 @@ module Vagrant
attr_accessor :run_list
def initialize
@provisioning_path = "/tmp/vagrant-chef"
@provisioning_path = "/tmp/vagrant-chef-#{self.class.get_and_update_counter}"
@log_level = :info
@json = {}
@http_proxy = nil

View File

@ -4,8 +4,6 @@ module Vagrant
class ChefSolo < Chef
register :chef_solo
extend Util::Counter
class Config < Chef::Config
attr_accessor :cookbooks_path
attr_accessor :roles_path
@ -58,6 +56,7 @@ module Vagrant
# path element which contains the folder location (:host or :vm)
paths = [paths] if paths.is_a?(String) || paths.first.is_a?(Symbol)
index = 0
paths.map do |path|
path = [:host, path] if !path.is_a?(Array)
type, path = path
@ -66,7 +65,8 @@ module Vagrant
# or VM path.
local_path = nil
local_path = File.expand_path(path, env.root_path) if type == :host
remote_path = type == :host ? "#{config.provisioning_path}/chef-solo-#{self.class.get_and_update_counter}" : path
remote_path = type == :host ? "#{config.provisioning_path}/chef-solo-#{index}" : path
index += 1
# Return the result
[type, local_path, remote_path]
@ -76,10 +76,12 @@ module Vagrant
# Shares the given folders with the given prefix. The folders should
# be of the structure resulting from the `expanded_folders` function.
def share_folders(prefix, folders)
index = 0
folders.each do |type, local_path, remote_path|
if type == :host
env.config.vm.share_folder("v-#{prefix}-#{self.class.get_and_update_counter}",
env.config.vm.share_folder("v-#{prefix}-#{index}",
remote_path, local_path, :nfs => config.nfs)
index += 1
end
end
end

View File

@ -52,7 +52,7 @@ class ChefSoloProvisionerTest < Test::Unit::TestCase
should "expand host folders properly" do
path = "foo"
local_path = File.expand_path(path, @env.root_path)
remote_path = "#{@action.config.provisioning_path}/chef-solo-1"
remote_path = "#{@action.config.provisioning_path}/chef-solo-0"
assert_equal [[:host, local_path, remote_path]], @action.expanded_folders([:host, path])
end
end