# Injecting information about the running job into a template

**URL:** <https://forum.ansible.com/t/injecting-information-about-the-running-job-into-a-template/11022>\
**Category:** Get Help\
**Created:** [November 20, 2024, 4:40pm UTC](https://forum.ansible.com/t/injecting-information-about-the-running-job-into-a-template/11022 "2024-11-20T16:40:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kevin\_Knox](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kevin_knox/32/3926_2.png) [@Kevin\_Knox](https://forum.ansible.com/u/Kevin_Knox)\
**Post date:** [November 20, 2024, 4:40pm UTC](https://forum.ansible.com/t/injecting-information-about-the-running-job-into-a-template/11022/1 "2024-11-20T16:40:57Z")

</div>

I’m sending my users an email, not a notification, via a task at the end of the play. I want to send them a link to the job they just ran. I would like to make that variable a part of the template. What variable do I use?

> ```
> - name: Email the requestor the status of their renewal  
> community.general.mail:
> host: mail.host
> port: 25
> subject: "Certificate Renewal by Definition invoked for {{ fqdn }}"
> body: "{{ lookup('template', ('certificatedefinitionlog_body.txt.j2')) }}"
> to:
> - "{{ email_contact }}"
> charset: us-ascii
> delegate_to: localhost
> 
> ```

Given this line as a part of certificatedefinitionlog\_body.txt.j2, how do I inject information about the running task? And, actually, this job is the last job template in a workflow job. How would I link to that workflow job? Or is there a variable I can use to inject the System variable for Miscellaneous\Base URL?

> {{ ansible\_user }} launched a Certificate renewal by Definition Document on your certificate, {{ fqdn }}. The renewal log can be viewed at {{ ??? }}

---

<div class="post-metadata">

**Author:** ![Kevin\_Knox](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kevin_knox/32/3926_2.png) [@Kevin\_Knox](https://forum.ansible.com/u/Kevin_Knox)\
**Post date:** [November 20, 2024, 9:22pm UTC](https://forum.ansible.com/t/injecting-information-about-the-running-job-into-a-template/11022/2 "2024-11-20T21:22:41Z")

</div>

ChatGPT and my searches indicated I should be able to use variables with names like {{tower.??}}, {{awx.??}}, and {{job.??}}. That advice was bogus. As nearly as I can tell, this is not something many people are doing. That’s a surprise to me. I have mildly trained people running AWX automations from Powershell, and I want to email them a link to their workflow job log. I would not have expected this to be as hard as it turns out to be.

---

<div class="post-metadata">

**Author:** ![mikemorency](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mikemorency/32/2672_2.png) [@mikemorency](https://forum.ansible.com/u/mikemorency)\
**Post date:** [November 20, 2024, 9:39pm UTC](https://forum.ansible.com/t/injecting-information-about-the-running-job-into-a-template/11022/3 "2024-11-20T21:39:37Z")

</div>

Heres a list of variable set while running a playbook: [Special Variables — Ansible Community Documentation](https://docs.ansible.com/ansible/latest/reference_appendices/special_variables.html)

Heres a list of variables set while running a job template from tower (they are listed towards the end of this section. and these are in addition to the variables above.): [16. Job Templates — Ansible Tower User Guide v3.5.0](https://docs.ansible.com/ansible-tower/3.5.0/html/userguide/job_templates.html#launch-a-job-template)

And heres an example of a playbook that will print all the variables available to a host: [How can I print out the actual values of all the variables used by an Ansible playbook? - Stack Overflow](https://stackoverflow.com/questions/72368575/how-can-i-print-out-the-actual-values-of-all-the-variables-used-by-an-ansible-pl)

---

<div class="post-metadata">

**Author:** ![Kevin\_Knox](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kevin_knox/32/3926_2.png) [@Kevin\_Knox](https://forum.ansible.com/u/Kevin_Knox)\
**Post date:** [November 21, 2024, 3:49pm UTC](https://forum.ansible.com/t/injecting-information-about-the-running-job-into-a-template/11022/4 "2024-11-21T15:49:54Z")

</div>

Thank you, @mikemorency . That is exactly the document I could not find, and its contents worked perfectly.

It would be nice if there were a variable for “Base URL” of the AWX system, but I can hard code that easily enough. Thank you!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [December 22, 2024, 4:43am UTC](https://forum.ansible.com/t/injecting-information-about-the-running-job-into-a-template/11022/6 "2024-12-22T04:43:43Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
