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:
Look for the current running Job
Find who executed the job
Pull the details of the user who executed the job
Lookup the user in SNOW based on info pulled from AWX API
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:
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.