Skip to content

Instantly share code, notes, and snippets.

@virtuald
Created August 11, 2018 22:03
Show Gist options
  • Save virtuald/af30557554ea839c6d00fc2386bc0a58 to your computer and use it in GitHub Desktop.
Save virtuald/af30557554ea839c6d00fc2386bc0a58 to your computer and use it in GitHub Desktop.
Vagrant NFS4 client+server automated setup
$serverScript = <<-SCRIPT
sudo apt-get update
sudo apt-get -y install nfs-kernel-server
sudo mkdir -p /exports/share
sudo chown -R vagrant:vagrant /exports
echo "/exports 192.168.50.0/24(rw,fsid=0,no_subtree_check,sync,sec=sys)" > /etc/exports
echo "/exports/share 192.168.50.0/24(rw,nohide,insecure,no_subtree_check,sync,sec=sys)" >> /etc/exports
sudo service nfs-kernel-server restart
SCRIPT
$clientScript = <<-SCRIPT
sudo mount -t nfs4 -o proto=tcp,port=2049 192.168.50.4:/ /mnt
SCRIPT
Vagrant.configure("2") do |config|
config.vm.define "server" do |server|
server.vm.box = "ubuntu/trusty64"
server.vm.provision "shell", inline: $serverScript
server.vm.network "private_network", ip: "192.168.50.4"
end
config.vm.define "client" do |client|
client.vm.box = "ubuntu/trusty64"
client.vm.provision "shell", inline: $clientScript
client.vm.network "private_network", ip: "192.168.50.5"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment