Why cannot retrieve or launch a Workflow Job Template by using Tower API?

1,520 views
Skip to first unread message

leim...@gmail.com

unread,
Nov 21, 2017, 11:41:18 PM11/21/17
to AWX Project
I tried to launch a Workflow Template on Ansible Tower by calling the APIs. But cannot even get the template information using https://towerIP/api/v2/job_templates/workflowtemplatename. Not mention to launch it. It works fine with those Job Templates. Does anyone know why it cannot work? Or did I just misuse it? 

Thanks,

John Mitchell

unread,
Nov 22, 2017, 10:08:56 AM11/22/17
to leim...@gmail.com, AWX Project
I believe that that the endpoint is unified_job_templates, not job_templates.

For future reference, you point a browser to https://towerIP/api/v2, you'll get a clickable tree of the available routes.

On Tue, Nov 21, 2017 at 11:41 PM, <leim...@gmail.com> wrote:
I tried to launch a Workflow Template on Ansible Tower by calling the APIs. But cannot even get the template information using https://towerIP/api/v2/job_templates/workflowtemplatename. Not mention to launch it. It works fine with those Job Templates. Does anyone know why it cannot work? Or did I just misuse it? 

Thanks,

--
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/3c5bc641-27a1-4e7e-8cdd-82528955492a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

John Mitchell
UI Engineer - Ansible Tower
Ansible by Red Hat

919-394-6667 | ansible.com 

GitHub: jlmitch5

Bill Nottingham

unread,
Nov 22, 2017, 10:14:54 AM11/22/17
to leim...@gmail.com, AWX Project
leim...@gmail.com (leim...@gmail.com) said:
> I tried to launch a Workflow Template on Ansible Tower by calling the APIs.
> But cannot even get the template information using
> https://towerIP/api/v2/job_templates/workflowtemplatename
> <https://towerip/api/v2/job_templates/workflowtemplatename>. Not mention to
> launch it. It works fine with those Job Templates. Does anyone know why it
> cannot work? Or did I just misuse it?

Workflow templates aren't under job_templates, they're under their own API
endpoint.

Bill

Michael Abashian

unread,
Nov 22, 2017, 10:28:22 AM11/22/17
to AWX Project
Just gonna add a bit of extra info to what's already been said - Workflow Job Templates and Job Templates are returned jointly via /api/v2/unified_job_templates but they each have their own endpoints (/api/v2/job_templates and /api/v2/workflow_job_templates).  To launch a workflow via the api you'll need to hit /api/v2/workflow_job_templates/N/launch/ where N is the id of the workflow job template.

Alan Rominger

unread,
Nov 27, 2017, 11:50:45 AM11/27/17
to Michael Abashian, AWX Project
Normally, you would access a WFJT (workflow job template) by its primary key like http://tower.invalid/api/v2/workflow_job_templates/38/

However, you can use its named url. To do this, navigate to its detail view (like the prior link) and see the entry "named_url" under "related".
In my case, I named my WFJT "asdf", but it exists in the "Default" organization.
Names are only unique within a single organization, thus the named URL is a combination of both names.
Thus, the named URL for my WFJT looks like: http://tower.invalid/api/v2/workflow_job_templates/asdf++Default/

Alan
github: AlanCoding

--
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.

John Mitchell

unread,
Nov 28, 2017, 2:25:17 PM11/28/17
to Lei Ma, AWX Project
Hey Lei,
Just a note to reply with awx-p...@googlegroups.com so that people subscribed to the list can see your question/answer as well.

I'm not sure off the top of my head how the API works in terms of extra vars and workflow nodes, Alan and Mike probably know.

On Tue, Nov 28, 2017 at 2:08 AM, Lei Ma <leim...@gmail.com> wrote:
Hi, John,

Thanks for the help. Besides, do you know how to provide "extra variables" in the payload for each node when launching a workflow template job? 

Best Regards,

Lei 

2017-11-23 2:08 GMT+11:00 John Mitchell <jmit...@redhat.com>:
I believe that that the endpoint is unified_job_templates, not job_templates.

For future reference, you point a browser to https://towerIP/api/v2, you'll get a clickable tree of the available routes.
On Tue, Nov 21, 2017 at 11:41 PM, <leim...@gmail.com> wrote:
I tried to launch a Workflow Template on Ansible Tower by calling the APIs. But cannot even get the template information using https://towerIP/api/v2/job_templates/workflowtemplatename. Not mention to launch it. It works fine with those Job Templates. Does anyone know why it cannot work? Or did I just misuse it? 

Thanks,

--
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.

For more options, visit https://groups.google.com/d/optout.
--

John Mitchell
UI Engineer - Ansible Tower
Ansible by Red Hat

919-394-6667 | ansible.com 

GitHub: jlmitch5

Lei Ma

unread,
Nov 28, 2017, 5:53:15 PM11/28/17
to John Mitchell, awx-p...@googlegroups.com
Hi, John,

Thank you.

Alan, Mike or anybody else who knows how to provide "extra variables" in the payload for each node in a workflow template job?

Thanks,

Lei

2017-11-29 6:25 GMT+11:00 John Mitchell <jmit...@redhat.com>:
Hey Lei,
Just a note to reply with awx-project@googlegroups.com so that people subscribed to the list can see your question/answer as well.

Bill Nottingham

unread,
Nov 28, 2017, 7:37:08 PM11/28/17
to Lei Ma, John Mitchell, awx-p...@googlegroups.com
Lei Ma (leim...@gmail.com) said:
> Hi, John,
>
> Thank you.
>
> Alan, Mike or anybody else who knows how to provide "extra variables" in
> the payload for each node in a workflow template job?

As in different vars at launch time to each node? You don't.

Bill

Lei Ma

unread,
Nov 28, 2017, 7:44:15 PM11/28/17
to Bill Nottingham, awx-p...@googlegroups.com
Yes, exactly what I need. Don't quite understand what you mean. There are definitely similar demands in practice. For my case, I need to drive a 3rd party platform by calling its APIs using URI module. And need to provide payload based on the user's input each time. What will you do in this case? 

Thanks,

Lei

Bill Nottingham

unread,
Nov 28, 2017, 8:00:19 PM11/28/17
to Lei Ma, awx-p...@googlegroups.com
Lei Ma (leim...@gmail.com) said:
> Yes, exactly what I need. Don't quite understand what you mean. There are
> definitely similar demands in practice. For my case, I need to drive a 3rd
> party platform by calling its APIs using URI module. And need to provide
> payload based on the user's input each time. What will you do in this case?

I mean it's not a feature that's supported. There is no way to pass, at
launch time, variables for inidividual workflow components.

extra_vars can be passed to the workflow as a whole; those extra vars passed
to the workflow are passed to all job templates in the workflow.

Bill

Alan Rominger

unread,
Nov 29, 2017, 8:13:46 AM11/29/17
to Bill Nottingham, Lei Ma, AWX Project
This was put on the agenda for the saved launch-time configuration feature


It has been implemented in a branch of mine, I'm just trying to wrap this up as quickly as I can.

WFJT nodes:
  • Extra_vars
  • API: add WFJT node extra_vars field w/encrypted values

Alan
github: AlanCoding


Bill

--
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.
Reply all
Reply to author
Forward
0 new messages