# Jinja interpreted values in Play.get\_vars() or Task.get\_vars()

**URL:** <https://forum.ansible.com/t/jinja-interpreted-values-in-play-get-vars-or-task-get-vars/35148>\
**Category:** Ansible Developer\
**Created:** [May 11, 2021, 9:05am UTC](https://forum.ansible.com/t/jinja-interpreted-values-in-play-get-vars-or-task-get-vars/35148 "2021-05-11T09:05:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Didier\_BOURRIAUD](https://avatars.discourse-cdn.com/v4/letter/d/919ad9/32.png) [@Didier\_BOURRIAUD](https://forum.ansible.com/u/Didier_BOURRIAUD)\
**Post date:** [May 11, 2021, 9:05am UTC](https://forum.ansible.com/t/jinja-interpreted-values-in-play-get-vars-or-task-get-vars/35148/1 "2021-05-11T09:05:57Z")

</div>

Hi,

I want to fill a custom dashboard with specifics events raise in a playbook, not all tasks that can be confuse output for functionnal users.

To do that, I first developped a role, and include it everytime I want to push an event. This solution works, but introduce so much task in a playbook. I try to handle exceptions too, so I use block with rescue etc… and Playbook become so complex with this approch.

So, after some research, I think that a Callback plugin can answer my needs. The idea is to inject at the plays and tasks levels, a specific var that the callback plugin can catch and react in function.

Playbook Example ( this is the Ansiboad var ):

---

<div class="post-metadata">

**Author:** ![Didier\_BOURRIAUD](https://avatars.discourse-cdn.com/v4/letter/d/919ad9/32.png) [@Didier\_BOURRIAUD](https://forum.ansible.com/u/Didier_BOURRIAUD)\
**Post date:** [May 11, 2021, 10:37am UTC](https://forum.ansible.com/t/jinja-interpreted-values-in-play-get-vars-or-task-get-vars/35148/2 "2021-05-11T10:37:25Z")

</div>

Hi again,

I found a way to apply the Jinja template on the string. After some research, Templar object works. I don’y really know by the way of this is the best practice to do this.

**So, the modified Code :**  
from ansible.template import Templar

def v2\_playbook\_on\_play\_start(self, play):  
self.playbook\_on\_play\_start([play.name](http://play.name/))

templar = Templar(loader=play.get\_loader(), variables=play.get\_variable\_manager().get\_vars(play=self.play))  
play\_vars = play.get\_vars()  
if “Ansiboard” in play\_vars:  
ansiconf = play\_vars[“Ansiboard”]  
project = templar.template(ansiconf[“project”])

And now, the content of project var is well : myproj

Don’t hesitate to correct or purpose a better way to acheive this.
