# win\_domain\_group to append new member groups

**URL:** <https://forum.ansible.com/t/win-domain-group-to-append-new-member-groups/29017>\
**Category:** Ansible Project\
**Created:** [November 13, 2018, 12:06pm UTC](https://forum.ansible.com/t/win-domain-group-to-append-new-member-groups/29017 "2018-11-13T12:06:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raj1](https://avatars.discourse-cdn.com/v4/letter/r/5fc32e/32.png) [@Raj1](https://forum.ansible.com/u/Raj1)\
**Post date:** [November 13, 2018, 12:06pm UTC](https://forum.ansible.com/t/win-domain-group-to-append-new-member-groups/29017/1 "2018-11-13T12:06:46Z")

</div>

Hello All,

I’m using the ‘win\_domain\_group module’ in ansible 2.6 to add a newly created AD group (new\_grp) to an existing AD group ( my\_admins). It works, but instead of appending “new\_grp” as a member of “my\_admins” it removes all current members and adds only “new\_group” . Does this module have an append option for attributes?

win\_domain\_group:  
domain\_server: “{{ domain\_ctrl }}”  
domain\_username: “{{ domain\_user }}”  
domain\_password: “{{ domain\_pass }}”  
name: “CN=my\_admins,ou=user groups,ou=accounts,ou=xyz,DC=Lab,DC=local”

path: “{{ ldap\_group\_path }}”  
category: security  
scope: global  
description: “My test group”  
state: present  
attributes:  
member: “CN=new\_grp,ou=user groups,ou=accounts,ou=xyz,DC=Lab,DC=local”

I can get it to work if I manually list all needed member groups like for the attribute like this?

win\_domain\_group:  
…  
…

state: present  
attributes:  
member:

- “CN=new\_grp,ou=user groups,ou=accounts,ou=xyz,DC=Lab,DC=local”
- “CN=group1,ou=user groups,ou=accounts,ou=xyz,DC=Lab,DC=local”
- “CN=group2,ou=user groups,ou=accounts,ou=xyz,DC=Lab,DC=local”
- “CN=group3,ou=user groups,ou=accounts,ou=xyz,DC=Lab,DC=local”

But as I generate the list from a previous task I’d like to pass the member list as a variable like “{{ teams}}”

teams:

- “CN=new\_grp,ou=user groups,ou=accounts,ou=xyz,DC=Lab,DC=local”
- “CN=group1,ou=user groups,ou=accounts,ou=xyz,DC=Lab,DC=local”
- “CN=group2,ou=user groups,ou=accounts,ou=xyz,DC=Lab,DC=local”
- “CN=group3,ou=user groups,ou=accounts,ou=xyz,DC=Lab,DC=local”

Using with\_items: “{{ teams}}” , iterates through the list but the result only the last group as a member. Any suggestions on how I can get around this?

---

<div class="post-metadata">

**Author:** ![Raj1](https://avatars.discourse-cdn.com/v4/letter/r/5fc32e/32.png) [@Raj1](https://forum.ansible.com/u/Raj1)\
**Post date:** [November 23, 2018, 11:23am UTC](https://forum.ansible.com/t/win-domain-group-to-append-new-member-groups/29017/2 "2018-11-23T11:23:25Z")

</div>

I managed to get this working. I used a series of set\_facts with loops to convert the list of groups from :  
teams:

- “CN=new\_grp,ou=user groups,ou=accounts,ou=xyz,DC=Lab,DC=local”
- “CN=group1,ou=user groups,ou=accounts,ou=xyz,DC=Lab,DC=local”
- “CN=group2,ou=user groups,ou=accounts,ou=xyz,DC=Lab,DC=local”
- “CN=group3,ou=user groups,ou=accounts,ou=xyz,DC=Lab,DC=local”

TO  
teams\_formatted: “CN=new\_grp,ou=user groups,ou=accounts,ou=xyz,DC=Lab,DC=local,CN=group1,ou=user groups,ou=accounts,ou=xyz,DC=Lab,DC=local,CN=group2,ou=user groups,ou=accounts,ou=xyz,DC=Lab,DC=local, CN=group3,ou=user groups,ou=accounts,ou=xyz,DC=Lab,DC=local”

Then the following task worked

win\_domain\_group:  
domain\_server: “{{ domain\_ctrl }}”  
domain\_username: “{{ domain\_user }}”  
domain\_password: “{{ domain\_pass }}”  
name: “CN=my\_admins,ou=user groups,ou=accounts,ou=xyz,DC=Lab,DC=local”  
path: “{{ ldap\_group\_path }}”  
category: security  
scope: global  
description: “My test group”  
state: present  
attributes:  
member: “{{ teams\_formatted }}”
