最终,我想起了我最近使用的插件中类似的代码行:
action_hook(:install_chef, Plugin::ALL_ACTIONS) do |hook|
require_relative 'action/install_chef'
hook.after(Vagrant::Action::Builtin::Provision, Action::InstallChef)
if defined? VagrantPlugins::AWS::Action::TimedProvision
hook.after(VagrantPlugins::AWS::Action::TimedProvision,
Action::InstallChef)
end
end
所以,我只是更改了它以确保我想要的任务总是在同步文件夹任务之前运行:
action_hook(:tty_workaround, Plugin::ALL_ACTIONS) do |hook|
require_relative 'action/tty_workaround'
hook.after(Vagrant::Action::Builtin::SyncedFolders, Action::TTYWorkaround)
end
像魅力一样工作!
我仍在试图弄清楚在 Vagrant 核心中是否有这样做的方法,但现在我计划制作一个 vagrant 插件,您可以在其中提供要在 vagrant 节点上运行的脚本的路径config,允许您在任何 Vagrant 实例中使用上述方法,而不仅仅是 vagrant-rackspace。