AJ_NOURI
(AJ NOURI)
June 12, 2019, 4:11pm
1
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!!
kdelee
(Elijah)
June 12, 2019, 8:04pm
2
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
kdelee
(Elijah)
June 12, 2019, 8:13pm
3
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
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
},