Ansible 错误:无法将用户添加到已经存在的组

Ansible 错误:无法将用户添加到已经存在的组

我无法将用户添加到已经存在的组。执行后,通过验证/etc/groups我可以看到未添加该用户。我是 Ansible 新手。有人可以帮忙吗?

这是我正在使用的脚本:

 hosts: host1
  remote_user: root
  tasks:
  - name: Creating user arun with shell login
    user:
     name: arun
     password: redhat
     shell: /bin/bash
  - name: creating group
     group:
     name: arungrp
     state: present
  - name: adding test user to group
     user:
      name: test
      group: arungrp
      append: yes

答案1

附加是组的修饰符s,不是群组。

您想要将 arungrp 设为次要组吗?

- name: creating group
     group:
     name: arungrp
     state: present
 - name: Creating user arun with shell login
     user:
      name: test
      password: redhat
      shell: /bin/bash
      groups: arungrp
      append: yes

如果您希望将其作为主要组:

- name: creating group
     group:
     name: arungrp
     state: present
- name: Creating user arun with shell login
    user:
     name: arun
     password: redhat
     shell: /bin/bash
     group: arungrp

相关内容