2
votes

I'm needing to recreate a setup on an old server with vagrant where we served sites within the home directory. Its not possible to set a shared folder to /home in vagrant as this will remove the vagrant user. I therefore would like to create a shared folder that is actually a symlink to the home directory.

If I create a shared directory like this in my Vagrantfile:

config.vm.share_folder "v-www", "/webroot", "/Users/me/sites/vagrant"

and then try and create a symlink with puppet overwriting this directory like this:

class misc {
  file { '/webroot':
   ensure => 'link',
   target => '/home',
   force => true,     
  }
}

It throws an error:

Error: Could not remove existing file

Error: /Stage[main]/Misc/File[/webroot]/ensure: change from directory to link failed: Could not remove existing file

When I log into the box and attempt this manually this also fails as i'm not actually able to remove the webroot - I assume this is because its created as some kind nfs share or something like that.

Any ideas how I can get around this?

1

1 Answers

2
votes

Try adding a replace:

class misc {
  file { '/webroot':
   ensure  => 'link',
   target  => '/home',
   force   => true,     
   replace => true,
  }
}