Hello Ansible experts, I am having a 'hostgroup' with a 'host_var' 
associated with each host of the 'hostgroup'. Play 1 which targets the 
'hostgroup', will create files on the target servers using the associated 
'host_var' and get the files back to ansible control machine and 
zip/archive the files. Play 2 which runs local to ansible control machine, 
needs to check for the files created, file name is 'targethostname.txt', 
and then create an email template with a table containing successful hosts 
and their associated 'host_var' using jinja2 and then send an email with a 
table of list of targethostnames and their associated host_vars.

I have completed the code for generating and copying the files to ansible 
control machine, zip, create a html template and send an email. I am struck 
at referencing/generating the html template file with a table consisting of 
the successful 'targethostnames' and their associated 'host_var' in the 
html template. Can anyone please help me with an approach to achieve the 
list of successful targethostnames and their host_vars in a jinja2 
template. Thanks in advance.

<table align="center";>
  <tr>
    <th>HOSTNAME / FQDN</th>
    <th>HOST VAR</th>

{% for host in ansible_play_batch %}
  </tr>
  <tr>
    <td> {{ inventory_hostname }} </td>
    <td> {{ host_var }} </td>
  </tr>
{% endfor %}

  </table>

The above doesn't seem to work. (Also, previously I had both the tasks - 
now Play 1 and Play 2 - in a single play and had to use the 
ansible_play_batch, as above, but, neither that didn't work.)

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/95e7a685-2e1b-4263-9b91-bf52ab783b40%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to