Is it possible to have vagrant sync a folder after the provision script is ran?
I need to sync a guest folder, with the host folder, but the host folder must be empty for the provision script to work. The user and group also need to exist. Non of which can exist until the provision script has ran. My provision script creates the user, and group.
The synced folder is a Magento theme. Magento first needs to install before I can sync the directories as Magento will not install into a non empty directory.
Here is my Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "bento/ubuntu-18.04"
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.provision "shell", path: "provision.sh"
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.synced_folder "app/design/frontend",
"/var/www/mage/app/design/frontend",
create: false,
owner: "mage",
group: "www-data"
config.vm.provider "virtualbox" do |vb|
vb.memory = "3000"
end
end
I've taken a look at triggers, but I can figure out how to use config.vm.synced_folder
within a trigger.
Any advice?
I've found a solution.
In the
Vagrantfile
setconfig.vm.synced_folder
to be false like so (also works fornfs
):Now run
vagrant up
. Once the server provisioning is complete change disabled totrue
like so:Now run
vagrant reload
and the folder will be synced.The docs say
Which makes me believe this may be one of the intended ways to solve my problem.
There is a feature request to mount folders post-provision which seems to be closed and not resolved so I don't think there's any other way to this: https://github.com/hashicorp/vagrant/issues/936