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

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

Following up with code. The playbook line is: 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

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

  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."

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

Felix, thanks! That fixed the issue.

Leam