# Merging lists from group\_vars

**URL:** <https://forum.ansible.com/t/merging-lists-from-group-vars/20162>\
**Category:** Ansible Project\
**Created:** [January 9, 2016, 1:12am UTC](https://forum.ansible.com/t/merging-lists-from-group-vars/20162 "2016-01-09T01:12:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guy\_Knights](https://avatars.discourse-cdn.com/v4/letter/g/db5fbb/32.png) [@Guy\_Knights](https://forum.ansible.com/u/Guy_Knights)\
**Post date:** [January 9, 2016, 1:12am UTC](https://forum.ansible.com/t/merging-lists-from-group-vars/20162/1 "2016-01-09T01:12:14Z")

</div>

Is there any way to merge lists from group\_vars, much like hash\_behaviour = merge, but for lists? From what I can tell, there is no explicit list\_behaviour option I can set, but is there perhaps a manual way I can do this? I have a firewall configuration that uses group\_vars to define the rules that are applied to each type of server, but now I’m trying to provision a server that is a member of multiple groups and it’s only applying the rules from the last group that it belongs to. One way around my issue is to explicitly specify the rules in a host\_vars file for this server only, but it feels a bit redundant; I’d really prefer if the rule lists could be combined from all groups this server belongs to as then I wouldn’t have to go through each group and manually combine the lists in the host\_vars file.

Thanks,  
Guy

---

<div class="post-metadata">

**Author:** ![Jesse\_Schluter](https://avatars.discourse-cdn.com/v4/letter/j/f17d59/32.png) [@Jesse\_Schluter](https://forum.ansible.com/u/Jesse_Schluter)\
**Post date:** [January 9, 2016, 7:53am UTC](https://forum.ansible.com/t/merging-lists-from-group-vars/20162/2 "2016-01-09T07:53:36Z")

</div>

I don’t know whether this works in your case, but we worked around, by creating different lists and manually merging them together:

type\_policy1:

- whatever
- your
- policy  
type\_policy2:
- list
- looks
- like

host\_policy: ‘{{ policies1 + policies2 }}’
