# Append Variables from one group to another

**URL:** <https://forum.ansible.com/t/append-variables-from-one-group-to-another/18338>\
**Category:** Ansible Developer\
**Created:** [May 28, 2015, 10:46pm UTC](https://forum.ansible.com/t/append-variables-from-one-group-to-another/18338 "2015-05-28T22:46:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jay\_Rogers](https://avatars.discourse-cdn.com/v4/letter/j/e47774/32.png) [@Jay\_Rogers](https://forum.ansible.com/u/Jay_Rogers)\
**Post date:** [May 28, 2015, 10:46pm UTC](https://forum.ansible.com/t/append-variables-from-one-group-to-another/18338/1 "2015-05-28T22:46:38Z")

</div>

Hi all! Is it possible to append variables from one group to another? Here is an example below for better clarity:

**Group Variables**

An array that lists users from a “core” group that will be applied to all servers:

1. CORE group
2. User1
3. User2

There would be another group for “customer” that would have:

1. CUSTOMER Group
2. User3
3. User4  
**Conditionals**

If the server DOES belong to the customer group, it should include the following users:

1. User1

2. User2

3. User3

4. User4  
If the server does NOT belong to the “customer” group, it would just be the following users:

5. User1

6. User2  
**Suggestions**  
Any thoughts? Tybstar on IRC recommended “[set operation filters](https://docs.ansible.com/playbooks_filters.html#set-theory-filters)” that could work but even mentioned that it could get _messy_ – especially if I start adding additional groups (Customer2, Customer3, etc.). I figured I would bounce a post off of here incase there are any additional thoughts or suggestions.

Thanks!

---

<div class="post-metadata">

**Author:** ![andy2](https://avatars.discourse-cdn.com/v4/letter/a/b9bd4f/32.png) [@andy2](https://forum.ansible.com/u/andy2)\
**Post date:** [September 3, 2015, 12:27am UTC](https://forum.ansible.com/t/append-variables-from-one-group-to-another/18338/2 "2015-09-03T00:27:52Z")

</div>

If you use a dictionary rather than a list, then you can merge them, giving you what you want.  
(you’ll need the setting ‘hash\_behaviour=merge’ in your ansible.cfg)

This allows you to have group variables like

in core group
