# "Group a does not exist" when adding groups to an existing user

**URL:** <https://forum.ansible.com/t/group-a-does-not-exist-when-adding-groups-to-an-existing-user/25575>\
**Category:** Ansible Project\
**Created:** [September 22, 2017, 3:38pm UTC](https://forum.ansible.com/t/group-a-does-not-exist-when-adding-groups-to-an-existing-user/25575 "2017-09-22T15:38:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![LeamHall](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/leamhall/32/9390_2.png) [@LeamHall](https://forum.ansible.com/u/LeamHall)\
**Post date:** [September 22, 2017, 3:38pm UTC](https://forum.ansible.com/t/group-a-does-not-exist-when-adding-groups-to-an-existing-user/25575/1 "2017-09-22T15:38:59Z")

</div>

I’m trying to add the long list of groups to the oracle user and getting “Group a does not exist.” as a failure msg. Not trying to add an “a” group, and the groups I am adding exist on the host. Is there a way to get more detail on what is going on?

Thanks!

Leam

---

<div class="post-metadata">

**Author:** ![LeamHall](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/leamhall/32/9390_2.png) [@LeamHall](https://forum.ansible.com/u/LeamHall)\
**Post date:** [September 25, 2017, 1:24pm UTC](https://forum.ansible.com/t/group-a-does-not-exist-when-adding-groups-to-an-existing-user/25575/2 "2017-09-25T13:24:24Z")

</div>

Following up with code. The playbook line is: [https://github.com/LeamHall/Ansible\_Test/blob/master/playbooks/roles/users/tasks/main.yml#L22](https://github.com/LeamHall/Ansible_Test/blob/master/playbooks/roles/users/tasks/main.yml#L22)

groups: “{{ item.groups | default(‘’) | join(‘,’) }}”

and the user’s “groups” line is:

groups: dba,oper,asmadmin,asmdba,asmoper,grid

The actual error message is:  
“msg”: “Group a does not exist.”

In the data above it lists: “item”: {“group”: “oinstall”, “groups”:“dba,oper,asmadmin,asmdba,asmoper,grid”, …}

Thanks!

Leam

---

<div class="post-metadata">

**Author:** ![felixfontein](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/felixfontein/32/7530_2.png) [@felixfontein](https://forum.ansible.com/u/felixfontein)\
**Post date:** [September 25, 2017, 3:42pm UTC](https://forum.ansible.com/t/group-a-does-not-exist-when-adding-groups-to-an-existing-user/25575/3 "2017-09-25T15:42:13Z")

</div>

Hi Leam,

> Following up with code. The playbook line is:  
> [https://github.com/LeamHall/Ansible\_Test/blob/master/playbooks/roles/users/tasks/main.yml#L22](https://github.com/LeamHall/Ansible_Test/blob/master/playbooks/roles/users/tasks/main.yml#L22)
> 
> &nbsp;&nbsp;groups: "{{ item.groups | default('') | join(',') }}"
> 
> and the user's "groups" line is:
> 
> &nbsp;&nbsp;groups: dba,oper,asmadmin,asmdba,asmoper,grid
> 
> The actual error message is:  
> "msg": "Group a does not exist."

I think the problem could be that "{{ item.groups | default('') }}" is  
a string; so when you try to run the "join(',')" filter, the filter  
iterates over the string (i.e. over the characters in the string) and  
puts a comma between each entry (i.e. each character). So the resulting  
string will be "d,b,a,o,p,e,r,a,s,...". I guess the group plugin  
converts sorts this list and thus complains about the first entry ("a")  
not being a valid group.

If you remove the "| join(',')" part, it should work.

Cheers,  
Felix

---

<div class="post-metadata">

**Author:** ![LeamHall](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/leamhall/32/9390_2.png) [@LeamHall](https://forum.ansible.com/u/LeamHall)\
**Post date:** [September 25, 2017, 5:18pm UTC](https://forum.ansible.com/t/group-a-does-not-exist-when-adding-groups-to-an-existing-user/25575/4 "2017-09-25T17:18:29Z")

</div>

Felix, thanks! That fixed the issue.

Leam
