As far as I can tell there is no such loop in the template:
[root@awx02 mysql]# cat templates/my.cnf.j2 [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql binlog_format=ROW bind-address="{{ ansible_default_ipv4.address }}" default_storage_engine=innodb innodb_autoinc_lock_mode=2 innodb_flush_log_at_trx_commit=0 innodb_buffer_pool_size=122M wsrep_provider=/usr/lib64/galera-3/libgalera_smm.so wsrep_provider_options="gcache.size=300M; gcache.page_size=300M" wsrep_cluster_name="galera_cluster1" wsrep_cluster_address="gcomm://{% for host in groups['mysql']%}{{hostvars[host]['ansible_default_ipv4']['address']}}{% if not loop.last %},{% endif %}{% endfor %}" wsrep_sst_method=rsync server_id=1 wsrep_node_address="{{ ansible_default_ipv4.address }}" wsrep_node_name="{{ ansible_hostname }}" [mysql_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid >From which message did you get that loop in the template? Am 05.11.18 um 15:51 schrieb Kai Stian Olstad: > On Monday, 5 November 2018 15:38:51 CET Uwe Sauter wrote: >> Sure, but the template will only be used for the one host and as such should >> not look for variables of other hosts, right? > > It will look up the variable on all host in group mysql > > This is the code in the template > > {% for host in groups['mysql']%} > {{hostvars[host]['ansible_default_ipv4']['address']}}{% if not loop.last > %},{% endif %} > {% endfor %} > > In the inventory he has > [mysql] > mysql01 > mysql02 > mysql03 > mysql04 > > In the first iteration host = mysql01 so he is running > {{ hostvars['mysql01']['ansible_default_ipv4']['address'] }} > > But since gather fact has not been run this will get you the error undefined > variable. > > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/1a75b5b6-1af6-682c-0be8-49af7174a5ca%40gmail.com. For more options, visit https://groups.google.com/d/optout.