# Reference AWX Username

**URL:** <https://forum.ansible.com/t/reference-awx-username/4952>\
**Category:** Get Help\
**Tags:** variables, playbook, awx\
**Created:** [April 15, 2024, 2:16pm UTC](https://forum.ansible.com/t/reference-awx-username/4952 "2024-04-15T14:16:52Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dustin](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dustin/32/2573_2.png) [@Dustin](https://forum.ansible.com/u/Dustin)\
**Post date:** [April 15, 2024, 2:16pm UTC](https://forum.ansible.com/t/reference-awx-username/4952/1 "2024-04-15T14:16:52Z")

</div>

In AWX, I’m looking for a way to reference the details of the user who executes a job.

Specifically, I want to get either their username or email address. Then, during one of my playbooks that creates records in ServiceNow I can associate those new records to them instead of me.

Right now, all records that my playbooks create in SNOW (Changes, INC, REQ, etc.) get assigned to me and then I look to see who created the job and manually change ownership.

If there is nothing built in, I’m thinking of using the AWX API:

1. Look for the current running Job
2. Find who executed the job
3. Pull the details of the user who executed the job
4. Lookup the user in SNOW based on info pulled from AWX API

Thoughts? Recommendations?

Thank you,

Dustin

---

<div class="post-metadata">

**Author:** ![Denney-tech](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/denney-tech/32/1556_2.png) [@Denney-tech](https://forum.ansible.com/u/Denney-tech)\
**Post date:** [April 15, 2024, 2:29pm UTC](https://forum.ansible.com/t/reference-awx-username/4952/2 "2024-04-15T14:29:39Z")

</div>

There are awx\_meta\_vars that I think you can leverage. I haven’t actually tried this, but it was mentioned by @fosterseth in another thread. Looking at what’s there, I think you can get awx\_\* vars for the job/workflow, schedule, user, and inventory as shown here:

> <https://github.com/ansible/awx/blob/d06ce8f9119267862fcca00fc85af3a9f323d61c/awx/main/models/unified_jobs.py#L1529>

---

<div class="post-metadata">

**Author:** ![Dustin](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dustin/32/2573_2.png) [@Dustin](https://forum.ansible.com/u/Dustin)\
**Post date:** [April 15, 2024, 2:51pm UTC](https://forum.ansible.com/t/reference-awx-username/4952/3 "2024-04-15T14:51:35Z")

</div>

Thank you. While searching, all I could find were references to AWX/Tower/AAP Credentials; which is not what I wanted.

I’ll give this a try and report back.

---

<div class="post-metadata">

**Author:** ![jpmens](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jpmens/32/5543_2.png) [@jpmens](https://forum.ansible.com/u/jpmens)\
**Post date:** [April 16, 2024, 4:17am UTC](https://forum.ansible.com/t/reference-awx-username/4952/4 "2024-04-16T04:17:32Z")

</div>

Both `{{ awx_user_id }}` and `{{ awx_user_email }}` work as well as the others @Denney-tech refers to, but beware the two I mention are specifically **not** set when the job template is triggered by an incoming Webhook.

---

<div class="post-metadata">

**Author:** ![Dustin](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dustin/32/2573_2.png) [@Dustin](https://forum.ansible.com/u/Dustin)\
**Post date:** [April 17, 2024, 8:17pm UTC](https://forum.ansible.com/t/reference-awx-username/4952/5 "2024-04-17T20:17:09Z")

</div>

I have not yet gotten time to go back and start playing with this. I appreciate the followup and when I get time, I’ll definitely get to it.

The laundry list is too big!!!

---

<div class="post-metadata">

**Author:** ![Dustin](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dustin/32/2573_2.png) [@Dustin](https://forum.ansible.com/u/Dustin)\
**Post date:** [April 25, 2024, 11:46am UTC](https://forum.ansible.com/t/reference-awx-username/4952/6 "2024-04-25T11:46:51Z")

</div>

`"{{ tower_user_email }}"` worked perfectly. I finally got a chance to test this one last night.

After finding the variable name, I was able to find the documentations here:  
[Ansible Tower Documentation](https://docs.ansible.com/ansible-tower/3.5.0/html/userguide/job_templates.html)

---

<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:** [May 25, 2024, 11:47am UTC](https://forum.ansible.com/t/reference-awx-username/4952/7 "2024-05-25T11:47:20Z")

</div>

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