Vagrant OS X host nfs share permissions error - Failed to set owner to '1000'

8,750

Solution 1

To get rid of this permissions issue, here is what I added to my Vagrantfile :

if (/darwin/ =~ RUBY_PLATFORM) != nil
    config.vm.synced_folder ".", "/host/path/to/shared/folder", nfs: true, :bsd__nfs_options => ["-maproot=0:0"]
  else
    config.vm.synced_folder ".", "/host/path/to/shared/folder", nfs: true, :linux__nfs_options => ["no_root_squash"]
  end

It will adapt the NFS options according to your host OS (OSX or Linux).

Solution 2

mbarthelemy answer got me halfway there, but in the end, I had to tweak a little more:

In my VagrantFile, I added this to the mapping to get it to work:

:linux__nfs_options => ["no_root_squash"], :map_uid => 0, :map_gid => 0

Solution 3

This might be caused by "root squashing" on the NFS server.

When the root user on an NFS client machine tries to manipulate files on an exported NFS filesystem, it does so with the permissions of an unprivileged user (usually nobody or nfsnobody). In this case, if I'm reading correctly, it may be that Puppet (running as root) cannot manipulate files on the NFS server because its permissions are being mapped to this unprivileged user.

To remove root squashing, edit /etc/exports on the NFS server, and add no_root_squash to the options for the exported filesystem, then run exportfs -av to re-export the filesystems.

Example /etc/exports line:

/srv   192.168.0.0/24 (rw,no_root_squash)
Share:
8,750

Related videos on Youtube

rachelandrew
Author by

rachelandrew

Updated on September 18, 2022

Comments

  • rachelandrew
    rachelandrew over 1 year

    I am a Vagrant and Puppet newbie, I have created a Base Box with Debian Squeeze plus standalone Puppet, using the instructions here to install Puppet with the Puppetlabs packages.

    The box itself seems to import successfully but once I get onto provisioning it, I get errors that seem to be to do with the nfs share on the host. 1000 is the uid of the Vagrant user on the vm.

    Error:

    Error: Failed to set owner to '1000': Operation not permitted - /vagrant/www/index.php
    Error: /Stage[main]/Perchdemo::Sites::Create/File[/vagrant/www/index.php]/owner: change from 501 to vagrant failed: Failed to set owner to '1000': Operation not permitted - /vagrant/www/index.php
    

    This occurs when I copy the index.php file into the share /vagrant/www on the host filesystem using Puppet. I have used this Puppet module on a standalone install of Puppet on a vm where the files were hosted on the filesystem of the vm, ideally though I'd like them to be on the nfs share.

    Edited with a bit more information. Having had a poke around the error initially occurs when I create the vhost using the puppetlabs apache module. However whichever user I try and force that to create under, it fails with the same error.

    My VagrantFile for this is as follows.

    Vagrant::Config.run do |config|
    
      config.vm.box = "squeeze64"
    
    
      config.vm.network :hostonly, "10.1.0.52"
    
      config.nfs.map_uid = :auto
      config.nfs.map_gid = :auto
    
      config.vm.forward_port 80, 8080
    
      config.vm.share_folder("v-web", "/vagrant/www", "./www", :nfs => true)
    
    
      config.vm.provision :shell, :inline => "echo \"Europe/London\" | sudo tee /etc/timezone && dpkg-reconfigure --frontend noninteractive tzdata"
    
    
      config.vm.provision :shell, :inline => "apt-get update --fix-missing"
      config.vm.provision :shell, :inline => "apt-get upgrade"
    
    
      config.vm.provision :puppet do |puppet|
         puppet.facter = { "fqdn" => "perchtutorial.eoms"}
         puppet.manifests_path = "puppet/manifests"
         puppet.manifest_file  = "perchtutorial.pp"
         puppet.module_path = "puppet/modules"
      end
    
    end
    
  • danieldkim
    danieldkim almost 8 years
    Small correction for the :bsd__nfs_options: the minus prefix for the maproot argument should not be included as Vagrant will add it for you.