几个月来,我一直在我的 Vagrant VM 中使用 NFS 挂载,在运行我们的 puppet 配置时没有任何问题。如您所知,每次您使用 puppet 创建文件夹时都必须指定其所有者和组,否则将使用默认值。出于某种原因,我们已将默认设置为 root:root,这也适用于其他一些文件/目录。
Puppet 试图chown
文件到root:root 但它失败 但它不应该因为chown 以0 退出 不更改所有者或组。此行为在 NFS 和 VirtualBox 共享上相同,但puppet 仅在使用 NFS 时失败共享。
问题是 - 是否有任何合理的解释为什么 puppet 在更改文件所有权时开始失败?它曾经工作了几个月,我仍在运行相同版本的 Vagrant 和 VirtualBox。
我发现了很多关于类似问题(改变所有权)的问题,发现所有者和组没有改变是可以的。我只是不知道为什么 puppet 会因为这个只在 NFS 上失败。
Vagrantfile 挂载部分
config.vm.synced_folder "../puppet", "/root/puppet", type: "nfs", mount_options: ["rw", "tcp", "fsc", "nolock", "noacl", "async"], nfs_udp: false
config.vm.synced_folder ".", "/media/src/project", type: "nfs", mount_options: ["rw", "tcp", "fsc", "nolock", "noacl", "async"], nfs_udp: false
NFS 上的 Puppet 日志
Info: Applying configuration version '1471704237'
Notice: /Stage[main]/Farm_tooling::Webgrind/Exec[configure]/returns: executed successfully
Notice: /Stage[main]/Ulozto::Web::Lab/File[/media/src/ulozto/.local/]/owner: owner changed '501' to 'root'
Error: Failed to set group to '0': Operation not permitted @ lchown_internal - /media/src/ulozto/.local
Error: /Stage[main]/Ulozto::Web::Lab/File[/media/src/ulozto/.local/]/group: change from dialout to root failed: Failed to set group to '0': Operation not permitted @ lchown_internal - /media/src/ulozto/.local
Puppet 登录 VirtualBox 共享
Info: Applying configuration version '1471704248'
Notice: /Stage[main]/Farm_tooling::Webgrind/Exec[configure]/returns: executed successfully
Notice: /Stage[main]/Ulozto::Web::Lab/File[/media/src/ulozto/.local/]/owner: owner changed 'vagrant' to 'root'
Notice: /Stage[main]/Ulozto::Web::Lab/File[/media/src/ulozto/.local/]/group: group changed 'vagrant' to 'root'
Notice: /Stage[main]/Ulozto::Pornfile::Remote/File[/var/www/pornfile-web/PornFile/App]/owner: owner changed 'vagrant' to 'root'
puppet 在 NFS 上运行后的目录列表
drwxr-xr-x 4 501 dialout 136 Aug 19 05:40 .local
我实际上不知道什么是拨出,但 501 是我帐户的 ID - uid=501(northys)
。在 puppet 运行后,所有者仍然是相同的。
puppet 在 VirtualBox 共享上运行后的目录列表
drwxr-xr-x 1 vagrant vagrant 136 Aug 19 05:40 .local
在 Puppet 运行后,所有者和组仍然是 vagrant:vagrant
,但 Puppet 并没有像 NFS 挂载情况那样在更改它时失败。
最佳答案
在我的 VagrantFile 中,我将其添加到映射中以使其正常工作:
:linux__nfs_options => ["no_root_squash"], :map_uid => 0, :map_gid => 0
关于linux - 无法从 Vagrant VM 更改文件所有权,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39045997/