I’d like to be able to do the following, hopefully someone can point me to a simple way to do it.
I have two lists, one contains vars for all hosts another vars for a specific host. I’d like to join them into a single list that can be iterated over in a template. I reuse the template so would rather it did not know about two separate lists.
generic_vars: [ ‘a’, ‘b’, ‘c’ ]
specific_vars: [ ‘d’, ‘e’ ]
somehow I’d like to combine these into an all_vars variable, so that in the template I can do the following.
mytemplate.json
{
“vars”: [
{% for v in all_vars %}
“{{v}}”{% if not loop.last %},{% endif %}
{% endfor %}
]
}
This is a patten that arises a lot for me so I’m probably going to write a module to do it. But I thought I’d check to see if there was a simple standard way of doing so before heading down that path.
Is this something that can be easily done?
thanks,
Steve.