synced_folders/nfs: automatically install NFS client if possible
If guests have the following capabilities, automatic NFS client installation will be done: * nfs_client_installed - Checks if the NFS client is installed * nfs_client_install - Install the NFS client Support is already in for Debian, Ubuntu, RedHat, CentOS, and Fedora
This commit is contained in:
parent
5fd8988835
commit
91380c0650
|
@ -36,6 +36,8 @@ IMPROVEMENTS:
|
|||
plugins.
|
||||
- commands/plugin: `vagrant plugin install` can now install multiple
|
||||
plugins.
|
||||
- synced\_folders/nfs: If the guest supports it, NFS clients will be
|
||||
automatically installed in the guest.
|
||||
|
||||
BUG FIXES:
|
||||
|
||||
|
|
|
@ -360,6 +360,10 @@ module Vagrant
|
|||
error_key(:nfs_no_valid_ids)
|
||||
end
|
||||
|
||||
class NFSClientNotInstalledInGuest < VagrantError
|
||||
error_key(:nfs_client_not_installed_in_guest)
|
||||
end
|
||||
|
||||
class NoDefaultSyncedFolderImpl < VagrantError
|
||||
error_key(:no_default_synced_folder_impl)
|
||||
end
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
module VagrantPlugins
|
||||
module GuestDebian
|
||||
module Cap
|
||||
class NFSClient
|
||||
def self.nfs_client_install(machine)
|
||||
machine.communicate.tap do |comm|
|
||||
comm.sudo("apt-get -y update")
|
||||
comm.sudo("apt-get -y install nfs-common portmap")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -20,6 +20,11 @@ module VagrantPlugins
|
|||
require_relative "cap/change_host_name"
|
||||
Cap::ChangeHostName
|
||||
end
|
||||
|
||||
guest_capability("linux", "nfs_client_install") do
|
||||
require_relative "cap/nfs_client"
|
||||
Cap::NFSClient
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
module VagrantPlugins
|
||||
module GuestLinux
|
||||
module Cap
|
||||
class NFSClient
|
||||
def self.nfs_client_installed(machine)
|
||||
machine.communicate.test("test -x /sbin/mount.nfs")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -36,6 +36,11 @@ module VagrantPlugins
|
|||
Cap::MountVirtualBoxSharedFolder
|
||||
end
|
||||
|
||||
guest_capability("linux", "nfs_client_installed") do
|
||||
require_relative "cap/nfs_client"
|
||||
Cap::NFSClient
|
||||
end
|
||||
|
||||
guest_capability("linux", "read_ip_address") do
|
||||
require_relative "cap/read_ip_address"
|
||||
Cap::ReadIPAddress
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
module VagrantPlugins
|
||||
module GuestRedHat
|
||||
module Cap
|
||||
class NFSClient
|
||||
def self.nfs_client_install(machine)
|
||||
machine.communicate.tap do |comm|
|
||||
comm.sudo("yum -y install nfs-utils nfs-utils-lib")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -25,6 +25,11 @@ module VagrantPlugins
|
|||
require_relative "cap/network_scripts_dir"
|
||||
Cap::NetworkScriptsDir
|
||||
end
|
||||
|
||||
guest_capability("linux", "nfs_client_install") do
|
||||
require_relative "cap/nfs_client"
|
||||
Cap::NFSClient
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -37,6 +37,16 @@ module VagrantPlugins
|
|||
raise Vagrant::Errors::NFSNoHostIP if !nfsopts[:nfs_host_ip]
|
||||
raise Vagrant::Errors::NFSNoGuestIP if !nfsopts[:nfs_machine_ip]
|
||||
|
||||
if machine.guest.capability?(:nfs_client_installed)
|
||||
installed = machine.guest.capability(:nfs_client_installed)
|
||||
if !installed
|
||||
can_install = machine.guest.capability?(:nfs_client_install)
|
||||
raise Vagrant::Errors::NFSClientNotInstalledInGuest if !can_install
|
||||
machine.ui.info I18n.t("vagrant.actions.vm.nfs.installing")
|
||||
machine.guest.capability(:nfs_client_install)
|
||||
end
|
||||
end
|
||||
|
||||
machine_ip = nfsopts[:nfs_machine_ip]
|
||||
machine_ip = [machine_ip] if !machine_ip.is_a?(Array)
|
||||
|
||||
|
|
|
@ -469,6 +469,14 @@ en:
|
|||
No valid IDs were given to the NFS synced folder implementation to
|
||||
prune. This is an internal bug with Vagrant and an issue should be
|
||||
filed.
|
||||
nfs_client_not_installed_in_guest: |-
|
||||
No NFS client was detected as installed in your guest machine. This
|
||||
is required for NFS synced folders to work. In addition to this, Vagrant
|
||||
doesn't know how to automatically install NFS for your machine, so
|
||||
you must do this manually.
|
||||
|
||||
If this message is erroneous, you may disable this check by setting
|
||||
`config.nfs.verify_installed` to `false` in your Vagrantfile.
|
||||
no_default_synced_folder_impl: |-
|
||||
No synced folder implementation is available for your synced folders!
|
||||
Please consult the documentation to learn why this may be the case.
|
||||
|
@ -1116,6 +1124,7 @@ en:
|
|||
preparing: "Preparing host only network..."
|
||||
nfs:
|
||||
exporting: Exporting NFS shared folders...
|
||||
installing: "Installing NFS client..."
|
||||
mounting: Mounting NFS shared folders...
|
||||
provision:
|
||||
beginning: "Running provisioner: %{provisioner}..."
|
||||
|
|
Loading…
Reference in New Issue