【问题标题】:How assign user to group in ansible?如何在ansible中将用户分配给组?
【发布时间】:2019-12-09 10:10:33
【问题描述】:

我需要使用 Ansible 的哪个模块来执行此操作?

chown -R vmail:vmail /var/mail

谢谢!

【问题讨论】:

    标签: unix ansible chown


    【解决方案1】:

    使用file模块并确保设置

      state: directory
    

    ,因为recurse: yes

    "递归设置目录内容的指定文件属性。 这仅在状态设置为目录时适用。"

    - file:
        state: directory
        path: /var/mail
        recurse: yes
        owner: vmail
        group: vmail
    

    【讨论】:

      【解决方案2】:

      你需要使用文件模块,更多信息在Ansible file module documentation

      那里的例子:

      - name: Recursively change ownership of a directory
        file:
          path: /etc/foo
          recurse: yes
          owner: foo
          group: foo
      

      【讨论】:

        猜你喜欢
        • 2023-03-11
        • 1970-01-01
        • 2017-08-18
        • 2018-06-13
        • 1970-01-01
        • 2022-10-07
        • 1970-01-01
        • 2016-10-06
        • 1970-01-01
        相关资源
        最近更新 更多