diff --git a/CHANGELOG.md b/CHANGELOG.md index d0d93c0a8e6..065faa34c41 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ BUG FIXES: - providers/docker: Protocol is now honored in direct `ports settings. - providers/docker: Images built using `build\_dir` will more robustly capture the final image. [GH-4598] + - providers/docker: NFS synced folders now work. [GH-4344] - providers/virtualbox: Show a human-friendly error if VirtualBox didn't clean up an existing VM. [GH-4681] - provisioners/docker: Search for docker binary in multiple places. [GH-4580] diff --git a/plugins/providers/virtualbox/action.rb b/plugins/providers/virtualbox/action.rb index 668cbe0efea..83eb3aec96c 100644 --- a/plugins/providers/virtualbox/action.rb +++ b/plugins/providers/virtualbox/action.rb @@ -292,6 +292,16 @@ def self.action_suspend end end + # This is the action that is called to sync folders to a running + # machine without a reboot. + def self.action_sync_folders + Vagrant::Action::Builder.new.tap do |b| + b.use PrepareNFSValidIds + b.use SyncedFolders + b.use PrepareNFSSettings + end + end + # This action brings the machine up from nothing, including importing # the box, configuring metadata, and booting. def self.action_up diff --git a/plugins/providers/virtualbox/action/prepare_nfs_settings.rb b/plugins/providers/virtualbox/action/prepare_nfs_settings.rb index b88cee99f59..b7a92d1acab 100644 --- a/plugins/providers/virtualbox/action/prepare_nfs_settings.rb +++ b/plugins/providers/virtualbox/action/prepare_nfs_settings.rb @@ -1,7 +1,10 @@ +require "vagrant/action/builtin/mixin_synced_folders" + module VagrantPlugins module ProviderVirtualBox module Action class PrepareNFSSettings + include Vagrant::Action::Builtin::MixinSyncedFolders include Vagrant::Util::Retryable def initialize(app, env) @@ -14,7 +17,13 @@ def call(env) @app.call(env) - if using_nfs? + opts = { + cached: !!env[:synced_folders_cached], + config: env[:synced_folders_config], + } + folders = synced_folders(env[:machine], **opts) + + if folders.has_key?(:nfs) @logger.info("Using NFS, preparing NFS settings by reading host IP and machine IP") add_ips_to_env!(env) end