Hi,
I am using ansible AWX for issuing REST calls for calling playbook. Playbook connects to downstream servers and provisions storage using underlying storage API's and registers o/p of rest call. My requirement is to get back a o/p of rest call as a part of job status call, however i am not able to do that as of now. Here is test playbook.
---
- name: Get REST o/p
connection: local
gather_facts: false
hosts: localhost
tasks:
- name: print a sample message
debug:
msg: "Test playbook"
- name: get value and print
debug:
var=key
register: outputvalue
Calling it using REST at endpoint <AWX server>/api/v2/job_templates/11/launch/ results in getting back job id
{
"job": 55,
"ignored_fields": {
"extra_vars": {
"key": "test key"
}
},
"id": 55,
"type": "job",
"url": "/api/v2/jobs/55/",
"related": {
"created_by": "/api/v2/users/2/",
"modified_by": "/api/v2/users/2/",
"labels": "/api/v2/jobs/55/labels/",
"inventory": "/api/v2/inventories/1/",
"project": "/api/v2/projects/10/",
"extra_credentials": "/api/v2/jobs/55/extra_credentials/",
"credentials": "/api/v2/jobs/55/credentials/",
"unified_job_template": "/api/v2/job_templates/11/",
"stdout": "/api/v2/jobs/55/stdout/",
"job_events": "/api/v2/jobs/55/job_events/",
"job_host_summaries": "/api/v2/jobs/55/job_host_summaries/",
"activity_stream": "/api/v2/jobs/55/activity_stream/",
"notifications": "/api/v2/jobs/55/notifications/",
"create_schedule": "/api/v2/jobs/55/create_schedule/",
"job_template": "/api/v2/job_templates/11/",
"cancel": "/api/v2/jobs/55/cancel/",
"relaunch": "/api/v2/jobs/55/relaunch/"
},
"summary_fields": {
"inventory": {
"id": 1,
"name": "Demo Inventory",
"description": "",
"has_active_failures": false,
"total_hosts": 1,
"hosts_with_active_failures": 0,
"total_groups": 0,
"has_inventory_sources": false,
"total_inventory_sources": 0,
"inventory_sources_with_failures": 0,
"organization_id": 1,
"kind": ""
},
on querying the job status, api/v2/jobs/55/ the result is :
{
"id": 55,
"type": "job",
"url": "/api/v2/jobs/55/",
"related": {
"created_by": "/api/v2/users/2/",
"labels": "/api/v2/jobs/55/labels/",
"inventory": "/api/v2/inventories/1/",
"project": "/api/v2/projects/10/",
"extra_credentials": "/api/v2/jobs/55/extra_credentials/",
"credentials": "/api/v2/jobs/55/credentials/",
"unified_job_template": "/api/v2/job_templates/11/",
"stdout": "/api/v2/jobs/55/stdout/",
"job_events": "/api/v2/jobs/55/job_events/",
"job_host_summaries": "/api/v2/jobs/55/job_host_summaries/",
"activity_stream": "/api/v2/jobs/55/activity_stream/",
"notifications": "/api/v2/jobs/55/notifications/",
"create_schedule": "/api/v2/jobs/55/create_schedule/",
"job_template": "/api/v2/job_templates/11/",
"cancel": "/api/v2/jobs/55/cancel/",
"relaunch": "/api/v2/jobs/55/relaunch/"
},
"summary_fields": {
"inventory": {
"id": 1,
"name": "Demo Inventory",
"description": "",
"has_active_failures": false,
"total_hosts": 1,
"hosts_with_active_failures": 0,
"total_groups": 0,
"has_inventory_sources": false,
"total_inventory_sources": 0,
"inventory_sources_with_failures": 0,
"organization_id": 1,
"kind": ""
},
"project": {
"id": 10,
"name": "demoproj",
"description": "",
"status": "successful",
"scm_type": "git"
},
"created": "2020-02-24T15:33:28.807983Z",
"modified": "2020-02-24T15:33:29.077686Z",
"name": "demotemplate",
"description": "",
"job_type": "run",
"inventory": 1,
"project": 10,
"playbook": "test.yml",
"scm_branch": "",
"forks": 0,
"limit": "",
"verbosity": 0,
"extra_vars": "{}",
"job_tags": "",
"force_handlers": false,
"skip_tags": "",
"start_at_task": "",
"timeout": 0,
"use_fact_cache": false,
"unified_job_template": 11,
"launch_type": "manual",
"status": "successful",
"failed": false,
"started": "2020-02-24T15:33:29.153003Z",
"finished": "2020-02-24T15:33:31.625738Z",
What I see in response is only status: successful.
How do i attach a variable to JSOn response from job status ?
Thanks and Regards,
Punit