Creating API endpoints with AWX

397 views
Skip to first unread message

dufusk

unread,
May 30, 2018, 3:57:56 PM5/30/18
to AWX Project
I'm posting this here because searching for this topic on google always returns the Ansible Tower API reference guide, and that's not what i'm looking for.

We are using AWX for quite a few projects, one of them being automated infrastructure deployments.  I have a few playbooks that we presenting to a different application (Service Now) as an API endpoint in AWX.

Service Now is able to launch this job via the API, and everything is working great, but the issue is how we pass data back to SerivceNow.

The only way we can find to return data back is using the debug module, which seems a bit janky.  It does in fact work, but searching pages and pages of job_events seems a bit wasteful.

Any suggestions on how we should actually be controlling how data is sent back?

I realize this is a bit of a ramble so I can clarify if needed.


Bill Nottingham

unread,
May 30, 2018, 4:02:27 PM5/30/18
to dufusk, AWX Project
dufusk (duf...@gmail.com) said:
> I'm posting this here because searching for this topic on google always
> returns the Ansible Tower API reference guide, and that's not what i'm
> looking for.
>
> We are using AWX for quite a few projects, one of them being automated
> infrastructure deployments. I have a few playbooks that we presenting to a
> different application (Service Now) as an API endpoint in AWX.
>
> Service Now is able to launch this job via the API, and everything is
> working great, but the issue is how we pass data back to SerivceNow.
>
> The only way we can find to return data back is using the debug module,
> which seems a bit janky. It does in fact work, but searching pages and
> pages of job_events seems a bit wasteful.

Just post to whatever API you need to post whatever data.

Example modules:
- http://docs.ansible.com/ansible/latest/modules/jira_module.html
- https://docs.ansible.com/ansible/latest/modules/snow_record_module.html

Or use the URI module.

Bill

Graham Mainwaring

unread,
May 30, 2018, 4:03:55 PM5/30/18
to dufusk, AWX Project
Maybe have your playbooks call an API endpoint in ServiceNow and post the data?

--
You received this message because you are subscribed to the Google Groups "AWX Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to awx-project+unsubscribe@googlegroups.com.
To post to this group, send email to awx-p...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/awx-project/abfa95e7-696c-4f3b-ad25-0e2100b1c566%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Graham Mainwaring
Back-End/API Manager, Ansible Engineering
Ansible by Red Hat 

+1 919 332 6966 | ansible.com

dufusk

unread,
May 30, 2018, 4:34:28 PM5/30/18
to AWX Project
Due to some internal shortcomings we aren't allowed access to the ServiceNow API's, but yes ideally this would be the right way to do it.


On Wednesday, May 30, 2018 at 3:03:55 PM UTC-5, Graham Mainwaring wrote:
Maybe have your playbooks call an API endpoint in ServiceNow and post the data?
On Wed, May 30, 2018 at 3:57 PM, dufusk <duf...@gmail.com> wrote:
I'm posting this here because searching for this topic on google always returns the Ansible Tower API reference guide, and that's not what i'm looking for.

We are using AWX for quite a few projects, one of them being automated infrastructure deployments.  I have a few playbooks that we presenting to a different application (Service Now) as an API endpoint in AWX.

Service Now is able to launch this job via the API, and everything is working great, but the issue is how we pass data back to SerivceNow.

The only way we can find to return data back is using the debug module, which seems a bit janky.  It does in fact work, but searching pages and pages of job_events seems a bit wasteful.

Any suggestions on how we should actually be controlling how data is sent back?

I realize this is a bit of a ramble so I can clarify if needed.


--
You received this message because you are subscribed to the Google Groups "AWX Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to awx-project...@googlegroups.com.

To post to this group, send email to awx-p...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/awx-project/abfa95e7-696c-4f3b-ad25-0e2100b1c566%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

John Westcott

unread,
May 31, 2018, 2:47:22 PM5/31/18
to dufusk, AWX Project
If you are calling a playbook (not a workflow) and want to pass data back you can use the set_stats Ansible module.

For example:

    - set_stats:
        data:
          my_var: my_value

Then in the JSON response of GET /api/v2/jobs/<job id>/ there will be an artifacts entry like:
    "artifacts": {
        "my_var": "my_value"
    },


os

unread,
Feb 11, 2019, 9:16:45 AM2/11/19
to AWX Project
It works with per_host=no, but if I change it to per_host=yes, the artifact list is empty {} on AWX (it is properly shown as custom stats, though).

Is there any way to have per host stats except to combine them in the playbook?

Also what about workflow results? Can they be made accessible in the similar way?

Reply all
Reply to author
Forward
0 new messages