# AWX API: read a variable or the content of a file after a job completion

**URL:** <https://forum.ansible.com/t/awx-api-read-a-variable-or-the-content-of-a-file-after-a-job-completion/30548>\
**Category:** AWX Project\
**Tags:** awx\
**Created:** [June 12, 2019, 4:11pm UTC](https://forum.ansible.com/t/awx-api-read-a-variable-or-the-content-of-a-file-after-a-job-completion/30548 "2019-06-12T16:11:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AJ\_NOURI](https://avatars.discourse-cdn.com/v4/letter/a/d2c977/32.png) [@AJ\_NOURI](https://forum.ansible.com/u/AJ_NOURI)\
**Post date:** [June 12, 2019, 4:11pm UTC](https://forum.ansible.com/t/awx-api-read-a-variable-or-the-content-of-a-file-after-a-job-completion/30548/1 "2019-06-12T16:11:24Z")

</div>

Hi,

Is it possible to read registered variables or file content with some data as a result of job completion.

The flow s as follow:

- launch a job Template from awx API
- the job Template, do some configuration and store data to a variable or an output file
- use awx API to read the variables or the content of the output file

Thanks a lot guys!!

---

<div class="post-metadata">

**Author:** ![kdelee](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kdelee/32/193_2.png) [@kdelee](https://forum.ansible.com/u/kdelee)\
**Post date:** [June 12, 2019, 8:04pm UTC](https://forum.ansible.com/t/awx-api-read-a-variable-or-the-content-of-a-file-after-a-job-completion/30548/2 "2019-06-12T20:04:38Z")

</div>

Have you considered making a Workflow Job Template with your first Job Template invoking the “set\_stats” module and passing this data to a second node that consumes it?

[https://github.com/ansible/awx/blob/a9c51b737c64bce0175c3dfdf4c488c629552a54/docs/workflow.md#artifacts](https://github.com/ansible/awx/blob/a9c51b737c64bce0175c3dfdf4c488c629552a54/docs/workflow.md#artifacts)

---

<div class="post-metadata">

**Author:** ![kdelee](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kdelee/32/193_2.png) [@kdelee](https://forum.ansible.com/u/kdelee)\
**Post date:** [June 12, 2019, 8:13pm UTC](https://forum.ansible.com/t/awx-api-read-a-variable-or-the-content-of-a-file-after-a-job-completion/30548/3 "2019-06-12T20:13:25Z")

</div>

Actually, re-reading this all you would need to do is use the “set\_stats” module and then on your job, there will be an attribute “artifacts” with your variables.

Example, launching a job using [https://github.com/ansible/test-playbooks/blob/fcdfa0ead5892862ba136bb6605ce2c1b79077dd/test\_set\_stats.yml](https://github.com/ansible/test-playbooks/blob/fcdfa0ead5892862ba136bb6605ce2c1b79077dd/test_set_stats.yml)  
Will render a job that has this present in its detail view in the API: (e.g. /api/v2/jobs/\<job\_id\>/ )

“artifacts”: {  
“none”: null,  
“object”: {  
“none”: null,  
“object”: {},  
“string”: “abc”,  
“float”: 1.0,  
“list”: ,  
“boolean”: true,  
“unicode”: “\u7af3\u466d\u97fd”,  
“integer”: 123  
},  
“string”: “abc”,  
“float”: 1.0,  
“list”: [  
“abc”,  
123,  
1.0,  
“\u7af3\u466d\u97fd”,  
true,  
null,  
,  
{}  
],  
“boolean”: true,  
“unicode”: “\u7af3\u466d\u97fd”,  
“empty\_object”: {},  
“empty\_list”: ,  
“integer”: 123  
},
