Generate hostlist.conf for Munin

Hello,

I am trying to generate hostlist.conf on munin machine based on inventory variables, i have something like this in template

hostlist.j2

`
{% for items in groups[‘all’] %}
[{{ hostvars[items][‘inventory_hostname_short’] }}.{{ hostvars[items][‘role_long’] }}.{{ domain }}]
address ssh://user@{{ hostvars[items][‘ansible_default_ipv4’][‘address’] }}:{{ hostvars[items][‘ansible_ssh_port’]|default(22) }} --spooldir /var/lib/munin-async/ --spoolfetch
use_node_name yes
load.load.warning :50
ntp_offset.offset.warning -1000:1000
ntp_offset.offset.critical -10000:10000

{% endfor %}
`

and test.yml which in turn calls hostlist.j2 template:

`

I think the problem could be caused by the delegate_to
Have you tried running the playbook without it? i.e. let the Munin master node to generate the conf file dynamically by being the one that connects to each Munin node to fill in the template.