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.


-- 
Kai Stian Olstad


-- 
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/140150938.1yJldNP92I%40x1.
For more options, visit https://groups.google.com/d/optout.

Reply via email to