Get the hostname of the server where the AWX-EE is being triggered

,

Im using AWX version 24.6.0

I have a template which gets executed in the instance group.
This instance group consist of 4 servers and when the template is executed, the job can be assigned on any of the server attached to the instance group.

Lets say these servers as server-A, server-B, server-C, server-D

As part of my template execution, i need to display the hostname where the job is being executed.

Is there a way to expose the details of the server where the job is being executed?

I don’t know if there is a straightforward answer here.

If you are managing instance groups, then you likely have a K8s manifest for the pods that are launched when AWX is launched.

If so, you can use the K8s downward API in that manifest where you can set an environment variable using spec.nodeName.

Then, within that AWX job, a simple lookup(ansible.buitin.env, <ENV_VAR>) will give you the node that pod (and worker container) are running on.

I’m not quite sure since I have not been using AWX much lately., but by referencing awx_execution_node in the playbook, we might be able to obtain the hostname.

AWX automatically sets special variables called meta variables. Search awx_execution_node in this page: 20. Job Templates — Ansible AWX community documentation

1 Like

Thank you @kurokobo your suggestion was helpful.

To test, i created a simple playbook like below and executed from AWX with the instance group containing 4 servers (execution nodes). I got the desired output.

  • name: Display the AWX execution node
    hosts: localhost
    tasks:
    • name: Print the execution node name
      debug:
      msg: “This job is being executed on: {{ awx_execution_node }}”