However, you can probably use typed triggers to achieve your goal of running something before folders get synced.
In order to use this feature, you’ll need to enable the experimental feature flag:
VAGRANT_EXPERIMENTAL="typed_triggers"
Then you can make a trigger on the sync folder action. Something like:
config.trigger.before :"Vagrant::Action::Builtin::SyncedFolders", type: :action do |t|
t.info = "Before action class!
end
Many thanks, I will give that a shot. I was hoping to get the trigger to actually do something of use, which I think is missing. add a user so that the given owner of a share is created if not found. the current process of syncedfolders is to fail if the owner dont exist,( which I would consider a bit poor) it would be better if it actually created the user for the owner
t.trigger.before :"Vagrant::Action::Builtin::SyncedFolders", type: :action do |t|
t.info = "Before action class!"
t.warn = "add user"
#t.run_remote ={inline:"uname -n"}
end
The above trigger worked but it ran to early! is it possible to next these triggers, so it runs
after
==> ansible: Before action class! ==> ansible: add user far to early to be of use
==> ansible: Clearing any previously set network interfaces…
==> ansible: Preparing network interfaces based on configuration…
ansible: Adapter 1: nat
ansible: Adapter 2: hostonly
==> ansible: Forwarding ports…
ansible: 22 (guest) => 2205 (host) (adapter 1)
==> ansible: Running ‘pre-boot’ VM customizations…
==> ansible: Booting VM…
==> ansible: Waiting for machine to boot. This may take a few minutes…
ansible: SSH address: 127.0.0.1:2205
ansible: SSH username: vagrant
ansible: SSH auth method: private key
==> ansible: Machine booted and ready!
==> ansible: Checking for guest additions in VM…
==> ansible: Setting hostname…
HERE, so is it possible to trigger after setting hostname but before sharefolders.
Right, apologies about Vagrant::Action::Builtin::SyncedFolders, looks like that’s the wrong action to attach to. You can see a list of the all the action available to a provider by inspection (it might be cool one day if there was some more digestible docs for this). For example, the actions available to virtualbox are listed here: vagrant/plugins/providers/virtualbox/action at main · hashicorp/vagrant · GitHub.
It looks like a trigger on the action VagrantPlugins::ProviderVirtualBox::Action::Boot will to what you are looking for.