2015-10-20 60 views
1

当我把这个top.sls:如何设置安装文件夹的默认用户?

/var/www: 
    file.directory: 
    - user: {{ pillar['user'] }} 
    - group: www-data 
    - mode: 755 
    - makedirs: True 

,它创建一个被定义的权限“的/ var/www”的目录,这是好的。 所以基本上chown是:用户:万维网 - 数据

但是,当我尝试将该文件夹挂载到我的Mac然后问题出现。 所有者和组为 - > 501:拨出

这里是我使用的代码:

/var/www: 
{% if pillar['sshfs_www'] %} 
    file.directory: 
    - mode: 755 
    - follow_symlinks: False 
    - group: www-data 
    - makedirs: True 

    mount: 
    - user: {{ pillar['user'] }} 
    - mounted 
    - device: sshfs#{{ pillar['sshfs_www'] }} 
    - fstype: fuse 
    - opts: nonempty,allow_other,auto 
{% else %} 
    file.directory: 
    - mode: 755 
    - group: www-data 
    - makedirs: True 
{% endif %} 

不仅如此,用户和组没有被设置为我设置,我得到错误:无法更改用户myuser

如何使用我的用户和组进行装载?

谢谢

回答

0

serverfail answer援引埃里克森:

You can't. That's a limitation of SSHFS/Fuse: Everything is mapped to the permission of the user you use to connect with SSH by default.

However, it appears you can work around this a bit with idmap files, see the options -o idmap , -o uidfile , -o gidfile and -o nomap in the man page.

+0

我通过创建bash脚本来解决这个问题:) – CroiOS

+0

@CroiOS:优秀:)你可能想在这里发布你的解决方案或者删除问题。 – tarleb

+1

在盐中发布了解决方案,最好是所有盐都在单独的脚本中 – CroiOS

1

我希望这将有助于其他用户与盐安装时与权限解决他们的问题:

所以我在这里是如何解决那。

首先我手动设置的ID为用户和组:

{{ pillar['user'] }}: 
    user.present:  
    - shell: /bin/bash 
    - home: /home/{{ pillar['user'] }} 
    - require_in: 
    - uid: 4000 
    - gid: 4000 
    - file: /home/{{ pillar['user'] }}/.ssh/id_rsa 
    - file: /home/{{ pillar['user'] }}/.ssh/authorized_keys 

www-data: 
    group.present: 
    - gid: 4000 
    - system: True 
    - members: 
     - {{ pillar['user'] }} 

之后部分,其中是安装的,我所定义uid和gid该型号:UID = 4000,GID = 4000

/var/www: 
{% if pillar['sshfs_www'] %} 
    mount: 
    - user: {{ pillar['user'] }} 
    - mounted 
    - device: sshfs#{{ pillar['sshfs_www'] }} 
    - fstype: fuse 
    - opts: nonempty,allow_other,auto,uid=4000,gid=4000 
{% else %} 
    file.directory: 
    - mode: 755 
    - group: www-data 
    - makedirs: True 
{% endif %} 
相关问题