Accessing group_vars variables from a jinja2 loop

Good morning,

I’m trying to write a loop in a template that will access a variable from group_vars. This variable is a string, with values separated by commas, so what I’d like to do is something like:

`
{% for item in variable.split(‘,’) %)

  • {{ item }}
    {% endfor %}
    `

with the group_var being

variable:"variable1,variable2,variable3..."

But I have not been able to achieve this, nor has any cursory googling shown any examples of doing this. I have managed to find an example someone who wanted to do this, but ended up putting the variables into their inventory, but that’s not appropriate in this situation.

Is this possible, or do I need to find another solution?

Regards,

AP

it does not matter if it is a host var or group var, as long as it
belongs to the host in your current task it should be directly
available.