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

122 views
Skip to first unread message

Laurent HENSSEN

unread,
May 26, 2020, 7:48:34 AM5/26/20
to Ansible Project
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

Reply all
Reply to author
Forward
0 new messages