# Append to var in group or host var when defined in role default var

**URL:** <https://forum.ansible.com/t/append-to-var-in-group-or-host-var-when-defined-in-role-default-var/33026>\
**Category:** Ansible Project\
**Created:** [May 26, 2020, 11:48am UTC](https://forum.ansible.com/t/append-to-var-in-group-or-host-var-when-defined-in-role-default-var/33026 "2020-05-26T11:48:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Laurent\_HENSSEN](https://avatars.discourse-cdn.com/v4/letter/l/53a042/32.png) [@Laurent\_HENSSEN](https://forum.ansible.com/u/Laurent_HENSSEN)\
**Post date:** [May 26, 2020, 11:48am UTC](https://forum.ansible.com/t/append-to-var-in-group-or-host-var-when-defined-in-role-default-var/33026/1 "2020-05-26T11:48:34Z")

</div>

Hi,

I’m trying something which is currently failing.  
I have a role using a list defined in its default vars.

My objective is to use the same var but to be able to “add” more item into the list at group / host var definition.

So, var in role/xxx/defaults/main.yml is a list and in group\_vars/ or host\_vars/, I need to add item so that in the role/xxx/tasks/main.yml, I directly have defaults + other optional added item to that list.

Is that possible ? Because looks like it’s not trying to resolve anything from group / host vars :

`  
fatal: [xxxxx]: FAILED! =\> {“msg”: “Invalid data passed to ‘loop’, it requires a list, got this instead: {{ audit\_list\_exclude\_tracing + append\_exts }}. Hint: If you passed a list/dict of just one element, try adding wantlist=True to your lookup invocation or use q/query instead of lookup.”}

`

In above error, the task got no more a (from defaults) list but what I tried so, no interpretation (same result I use host or group var)

Bellow is my host / group var :

`  
append\_exts:

- /usr/bin/at
- /usr/bin/automake

audit\_list\_exclude\_tracing: “{{ audit\_list\_exclude\_tracing + append\_exts }}”

`

The list where to append is audit\_list\_exclude\_tracing and I try to append the append\_exts list (name of the list come from a previous copy past from the web when testing …).

Not sure it’s possible to make it works …  
If not, I will probably need to define another var and merge them together in a set\_fact task : could do the trick but if I can avoid, even better.  
Also, will be the problem where the second list will be not defined (for the set\_facl task).

Any idea ?

Thanks,  
Laurent
