# Issue with jinja2 template

**URL:** <https://forum.ansible.com/t/issue-with-jinja2-template/35615>\
**Category:** Ansible Project\
**Tags:** rhel\
**Created:** [August 12, 2021, 3:38pm UTC](https://forum.ansible.com/t/issue-with-jinja2-template/35615 "2021-08-12T15:38:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![harry\_devine](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/harry_devine/32/5293_2.png) [@harry\_devine](https://forum.ansible.com/u/harry_devine)\
**Post date:** [August 12, 2021, 3:38pm UTC](https://forum.ansible.com/t/issue-with-jinja2-template/35615/1 "2021-08-12T15:38:56Z")

</div>

I’m trying to create a report when we do our updates via yum (rhel 7) and dnf (rhel 8). I register the output in variables called yum\_rhel7 and yum \_rhel8. Here’s my j2 file:

Yum/DNF Update Report

{{ now(false, ‘%m/%d/%Y %I:%M:%S’) }}

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [August 12, 2021, 3:47pm UTC](https://forum.ansible.com/t/issue-with-jinja2-template/35615/2 "2021-08-12T15:47:30Z")

</div>

> I'm trying to create a report when we do our updates via yum (rhel 7) and dnf (rhel 8). I register the output in variables called yum\_rhel7 and yum \_rhel8. Here's my j2 file:
> 
> Yum/DNF Update Report
> 
> {{ now(false, '%m/%d/%Y %I:%M:%S') }}
> 
> ---  
> {% for i in play\_hosts | sort %}  
> {% if {{ hostvars[i]['ansible\_distribution\_major\_version'] == '7' }} %}  
> {% if {{ hostvars[i]['yum\_rhel7']['skipped'] is not defined }} %}  
> Host: {{ i }}  
> Yum Result: {{ hostvars[i]['yum\_rhel7']['results'] }}  
> {% endif %}  
> ---  
> {% endfor %}

No curly braces in conditions, e.g. use

{% if hostvars[i]['ansible\_distribution\_major\_version'] == '7' %}

Also

{% if 'skipped' not in hostvars[i]['yum\_rhel7'] %}

is probably more correct.

Regards  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke
