This is a little old but I'll throw another answer in here for entire directory structures for Windows users using PowerShell.
First, create a Powershell script that copies over an entire folder structure from a shared folder.
#Check if the directory you're copying already exists on the VM
$foldercheck = "path\to\folder\on\vm"
if (test-path $foldercheck)
{
Write-Host "Folder 'path\to\folder\on\vm' already exists..."
}
else {
#Create the new directory
New-Item -ItemType Directory -Force -Path "path\to\folder\on\vm"
#Copy over contents to the directory
Copy-Item "\\VBOXSRV\<share_name>\path\to\folder\to\copy\*" -Destination "path\to\folder\on\vm" -recurse
}
Then, configure your Vagrantfile to automount a sharedfolder, copy over PowerShell scripts, and then run them in the order specified.
Vagrant.configure(2) do |config|
config.vm.provider "virtualbox" do |vb|
# Other settings
# ...
# Add shared folders
vb.customize ["sharedfolder", "add", :id, "--name", "<share_name>", "--hostpath", "path/to/host/folder/location", "--automount"]
end
# =================================================================
# PROVISIONING
# =================================================================
# Load up the files to the Guest environment for use by PowerShell
config.vm.provision "file", source: "path/to/provisioning/files/powershellfile.ps1", destination: "path/to/temporary/location/powershellfile.ps1"
# Rinse/repeat for additional provisioning files
# Now provision files in the order they are specified
config.vm.provision "shell", inline: "path/to/temporary/location/powershellfile.ps1"
# Rinse/repeat to run PowerShell scripts
end