# delegate\_to in Jinja2

**URL:** <https://forum.ansible.com/t/delegate-to-in-jinja2/20334>\
**Category:** Ansible Project\
**Created:** [January 25, 2016, 2:18am UTC](https://forum.ansible.com/t/delegate-to-in-jinja2/20334 "2016-01-25T02:18:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dewangga\_Bachrul\_Ala](https://avatars.discourse-cdn.com/v4/letter/d/43a26b/32.png) [@Dewangga\_Bachrul\_Ala](https://forum.ansible.com/u/Dewangga_Bachrul_Ala)\
**Post date:** [January 25, 2016, 2:18am UTC](https://forum.ansible.com/t/delegate-to-in-jinja2/20334/1 "2016-01-25T02:18:20Z")

</div>

Hi,

I tried to build templates on mariadb (galera) and this templates  
should be suites on any additional nodes.

For the example, on the `wsrep_cluster_address`, I put  
wsrep\_cluster\_address = "gcomm://{% if (groups['dbservers']

> length) \> 1 %}{% for host in groups['dbservers'] %}{{

hostvars[host]['ansible\_ssh\_host'] }}{% if not loop.last %},{% endif  
%}{% endfor %}{% endif %}"

It's success, but I need to put additional parameter/variable.

I need to put `wsrep_new_cluster` below `wsrep_cluster_address` and it  
only `delegate_to` first node/host.

I've read the `delegate_to` parameter on inventory, but I didn't know  
how to put it on jinja2 templates. Any ref/docs? Or maybe an example?

Is it possible to do it? Any hints/helps are really appreciated 🙂  
Thank you.
