Hi all,

Ansible has a lot of options, where combining and chaining filters is of 
great usage.
In certain cases the final result might become a bit hard to maintain if it 
is re-used in multiple places. E.g. take the following examples:


*merged_list: "{{ (lookup('vars', *query('varnames', '^.+__merge_list$')) + 
[testlist_initial_value]) | flatten(levels=1) }}"*

*merged_dict: "{{ lookup('vars', *query('varnames', '^.+__merge_dict$')) | 
combine(testdict_initial_value, recursive=True, list_merge='append') }}"*

I couldn't find anything about Ansible having this functionality, but is it 
an idea for adding functions/aliases to Ansible where often re-used 
expressions can be stored as a 'function' or 'alias' so the user can call 
it with the appropriate input arguments?

In case of the above e.g. defining the expressions somewhere and calling it 
as e.g.
*{{ merge_dict('__merge_dict', testdict_initial_value) }}*

The user then only has to define the complex expression once, after which 
it can re-use the function in multiple places throughout the project.

Happy to hear any thoughts on this idea (or whether this is already 
possible).

Regards,
Roy 

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-devel/ef556d24-963f-43f2-8190-39e87340dca9n%40googlegroups.com.

Reply via email to