diff --git a/README.md b/README.md index 1df1d45f..acf3c392 100644 --- a/README.md +++ b/README.md @@ -200,7 +200,8 @@ The default is an empty Array, or `[]`. The example: ```ruby driver_config: - synced_folders: [["/Users/mray/ws/cookbooks/pxe_dust/.kitchen/kitchen-vagrant/opt/chef", "/opt/chef"]] + synced_folders: [["/Users/mray/ws/cookbooks/pxe_dust/.kitchen/kitchen-vagrant/opt/chef", "/opt/chef"], + ["/host_path", "/vm_path", "create: true, disabled: false"]] ``` will generate a Vagrantfile configuration similar to: @@ -210,6 +211,7 @@ Vagrant.configure("2") do |config| # ... c.vm.synced_folder "/Users/mray/ws/cookbooks/pxe_dust/.kitchen/kitchen-vagrant/opt/chef", "/opt/chef" + c.vm.synced_folder "/host_path", "/vm_path", create: true, disabled: false end ``` diff --git a/lib/kitchen/vagrant/vagrantfile_creator.rb b/lib/kitchen/vagrant/vagrantfile_creator.rb index d95fe5ca..12db74f0 100644 --- a/lib/kitchen/vagrant/vagrantfile_creator.rb +++ b/lib/kitchen/vagrant/vagrantfile_creator.rb @@ -103,8 +103,12 @@ def chef_block(arr) end def synced_folders_block(arr) - config[:synced_folders].each do |source, destination| - arr << %{ c.vm.synced_folder "#{source}", "#{destination}" } + instance_name = instance.name + config[:synced_folders].each do |source, destination, options| + l_source = source.gsub("%{instance_name}", instance_name) + l_destination = destination.gsub("%{instance_name}", instance_name) + opt = (options.nil? ? '' : ", #{options}") + arr << %{ c.vm.synced_folder "#{l_source}", "#{l_destination}"#{opt} } end end