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.
|
plugins.
|
||||||
- commands/plugin: `vagrant plugin install` can now install multiple
|
- commands/plugin: `vagrant plugin install` can now install multiple
|
||||||
plugins.
|
plugins.
|
||||||
|
- synced\_folders/nfs: If the guest supports it, NFS clients will be
|
||||||
|
automatically installed in the guest.
|
||||||
|
|
||||||
BUG FIXES:
|
BUG FIXES:
|
||||||
|
|
||||||
|
|
|
@ -360,6 +360,10 @@ module Vagrant
|
||||||
error_key(:nfs_no_valid_ids)
|
error_key(:nfs_no_valid_ids)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class NFSClientNotInstalledInGuest < VagrantError
|
||||||
|
error_key(:nfs_client_not_installed_in_guest)
|
||||||
|
end
|
||||||
|
|
||||||
class NoDefaultSyncedFolderImpl < VagrantError
|
class NoDefaultSyncedFolderImpl < VagrantError
|
||||||
error_key(:no_default_synced_folder_impl)
|
error_key(:no_default_synced_folder_impl)
|
||||||
end
|
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"
|
require_relative "cap/change_host_name"
|
||||||
Cap::ChangeHostName
|
Cap::ChangeHostName
|
||||||
end
|
end
|
||||||
|
|
||||||
|
guest_capability("linux", "nfs_client_install") do
|
||||||
|
require_relative "cap/nfs_client"
|
||||||
|
Cap::NFSClient
|
||||||
|
end
|
||||||
end
|
end
|
||||||
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
|
Cap::MountVirtualBoxSharedFolder
|
||||||
end
|
end
|
||||||
|
|
||||||
|
guest_capability("linux", "nfs_client_installed") do
|
||||||
|
require_relative "cap/nfs_client"
|
||||||
|
Cap::NFSClient
|
||||||
|
end
|
||||||
|
|
||||||
guest_capability("linux", "read_ip_address") do
|
guest_capability("linux", "read_ip_address") do
|
||||||
require_relative "cap/read_ip_address"
|
require_relative "cap/read_ip_address"
|
||||||
Cap::ReadIPAddress
|
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"
|
require_relative "cap/network_scripts_dir"
|
||||||
Cap::NetworkScriptsDir
|
Cap::NetworkScriptsDir
|
||||||
end
|
end
|
||||||
|
|
||||||
|
guest_capability("linux", "nfs_client_install") do
|
||||||
|
require_relative "cap/nfs_client"
|
||||||
|
Cap::NFSClient
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -37,6 +37,16 @@ module VagrantPlugins
|
||||||
raise Vagrant::Errors::NFSNoHostIP if !nfsopts[:nfs_host_ip]
|
raise Vagrant::Errors::NFSNoHostIP if !nfsopts[:nfs_host_ip]
|
||||||
raise Vagrant::Errors::NFSNoGuestIP if !nfsopts[:nfs_machine_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 = nfsopts[:nfs_machine_ip]
|
||||||
machine_ip = [machine_ip] if !machine_ip.is_a?(Array)
|
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
|
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
|
prune. This is an internal bug with Vagrant and an issue should be
|
||||||
filed.
|
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_default_synced_folder_impl: |-
|
||||||
No synced folder implementation is available for your synced folders!
|
No synced folder implementation is available for your synced folders!
|
||||||
Please consult the documentation to learn why this may be the case.
|
Please consult the documentation to learn why this may be the case.
|
||||||
|
@ -1116,6 +1124,7 @@ en:
|
||||||
preparing: "Preparing host only network..."
|
preparing: "Preparing host only network..."
|
||||||
nfs:
|
nfs:
|
||||||
exporting: Exporting NFS shared folders...
|
exporting: Exporting NFS shared folders...
|
||||||
|
installing: "Installing NFS client..."
|
||||||
mounting: Mounting NFS shared folders...
|
mounting: Mounting NFS shared folders...
|
||||||
provision:
|
provision:
|
||||||
beginning: "Running provisioner: %{provisioner}..."
|
beginning: "Running provisioner: %{provisioner}..."
|
||||||
|
|
Loading…
Reference in New Issue