Vagrant: how to set owner to synced/shared folders when this owner is created in the provisioning phase

天大地大妈咪最大 提交于 2019-12-01 03:53:02

问题


Vagrantfile (relevant parts)

  config.vm.provision :chef_solo do |chef|
    chef.add_recipe "yum"
    # various recipes..
    # in one of these i create the 'localuser' user
  end

  config.vm.synced_folder "./site/frontend", "/var/www/vhosts/site/frontend", :owner=> 'localuser', :group=>'apache', :extra => 'dmode=755,fmode=755'

When i do the first vagrant up i get an erroring on mounting because it can't find localuser (mounting of shared folders comes before the provisioning)

What can i do to have a shared folder with an owner that is created later?


回答1:


I wasn't aware you could set the owner on a folder like that... is it in the docs?

What I would do is mount the folder and then in the provisioning step set the owner and permissions that way... if the folder doesn't exist until provisioning that I would mount a folder that does exist but create a symlink to it from the mounted folder in the provisioning step.

I also normally create an AFP or Samba server share and access folders on the server that way... its a bit more setup but a lot more powerful than just mounting a shared folder through Vagrant.



来源:https://stackoverflow.com/questions/16840296/vagrant-how-to-set-owner-to-synced-shared-folders-when-this-owner-is-created-in

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!