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

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,

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.

leima2046@gmail.com (leima2046@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&gt;\. 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

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.

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/

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.

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.

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

Lei Ma (leima2046@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

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

Lei Ma (leima2046@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

This was put on the agenda for the saved launch-time configuration feature

https://github.com/ansible/awx/issues/169

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