# Tower "loopback" jobs

**URL:** <https://forum.ansible.com/t/tower-loopback-jobs/29833>\
**Category:** AWX Project\
**Created:** [March 6, 2019, 4:00pm UTC](https://forum.ansible.com/t/tower-loopback-jobs/29833 "2019-03-06T16:00:06Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![dmakovey](https://avatars.discourse-cdn.com/v4/letter/d/4da419/32.png) [@dmakovey](https://forum.ansible.com/u/dmakovey)\
**Post date:** [March 6, 2019, 4:00pm UTC](https://forum.ansible.com/t/tower-loopback-jobs/29833/1 "2019-03-06T16:00:06Z")

</div>

I'm trying to write a playbook that would invoke other playbooks (to use  
for bulk playbook launches):

roles/tower\_job

---

<div class="post-metadata">

**Author:** ![Ben\_Spencer](https://avatars.discourse-cdn.com/v4/letter/b/e274bd/32.png) [@Ben\_Spencer](https://forum.ansible.com/u/Ben_Spencer)\
**Post date:** [March 7, 2019, 1:37pm UTC](https://forum.ansible.com/t/tower-loopback-jobs/29833/2 "2019-03-07T13:37:56Z")

</div>

Not sure I understand “bulk playbook launches”, but does/should workflows be used for this?

Are you running into authentication issues or something else?

(throwing out ideas - I’ve never done this)

---

<div class="post-metadata">

**Author:** ![dmakovey](https://avatars.discourse-cdn.com/v4/letter/d/4da419/32.png) [@dmakovey](https://forum.ansible.com/u/dmakovey)\
**Post date:** [March 7, 2019, 4:44pm UTC](https://forum.ansible.com/t/tower-loopback-jobs/29833/3 "2019-03-07T16:44:39Z")

</div>

> Not sure I understand "bulk playbook launches", but does/should  
> workflows be used for this?

Workflows don't seem to allow flexibility I seek. I need to:

\* collect from user which jobs are to be fired off (pre-populated  
multiple choice list)  
\* launch all selected jobs

> Are you running into authentication issues or something else?

I think those are auth issues, and I would like to know what is the  
purpose of "Ansible Tower" credentials if not for covering something  
like described above...

> (throwing out ideas - I've never done this)

yeah, neither have I ☹

---

<div class="post-metadata">

**Author:** ![jowestco](https://avatars.discourse-cdn.com/v4/letter/j/85f322/32.png) [@jowestco](https://forum.ansible.com/u/jowestco)\
**Post date:** [March 7, 2019, 5:21pm UTC](https://forum.ansible.com/t/tower-loopback-jobs/29833/4 "2019-03-07T17:21:56Z")

</div>

I have something similar with my customer where we have metadata that defines roles and then we have a job that will apply roles from the metadata to selected inventory.  
For calling back to Tower you should be able to use the Ansible Tower credential type with the tower\_ modules so it looks like it should work.  
What are you getting in the log of a run? Can you see the job launches in Tower?  
Note this module is just kicking off the job, not waiting for it to complete, you would also need to include a call to tower\_job\_wait to get the results back in your ansible code.

-John

---

<div class="post-metadata">

**Author:** ![dmakovey](https://avatars.discourse-cdn.com/v4/letter/d/4da419/32.png) [@dmakovey](https://forum.ansible.com/u/dmakovey)\
**Post date:** [March 7, 2019, 6:01pm UTC](https://forum.ansible.com/t/tower-loopback-jobs/29833/5 "2019-03-07T18:01:18Z")

</div>

This is what I'm getting:

Traceback (most recent call last):  
&nbsp;&nbsp;File  
"/home/ansible/.ansible/tmp/ansible-tmp-1551887155.09-262196206232843/AnsiballZ\_tower\_job\_launch.py",  
line 113, in \<module\>  
&nbsp;&nbsp;&nbsp;&nbsp;\_ansiballz\_main()  
&nbsp;&nbsp;File  
"/home/ansible/.ansible/tmp/ansible-tmp-1551887155.09-262196206232843/AnsiballZ\_tower\_job\_launch.py",  
line 105, in \_ansiballz\_main  
&nbsp;&nbsp;&nbsp;&nbsp;invoke\_module(zipped\_mod, temp\_path, ANSIBALLZ\_PARAMS)  
&nbsp;&nbsp;File  
"/home/ansible/.ansible/tmp/ansible-tmp-1551887155.09-262196206232843/AnsiballZ\_tower\_job\_launch.py",  
line 48, in invoke\_module  
&nbsp;&nbsp;&nbsp;&nbsp;imp.load\_module('\_\_main\_\_', mod, module, MOD\_DESC)  
&nbsp;&nbsp;File "/tmp/ansible\_tower\_job\_launch\_payload\_e2rKQ3/\_\_main\_\_.py", line  
145, in \<module\>  
&nbsp;&nbsp;File "/tmp/ansible\_tower\_job\_launch\_payload\_e2rKQ3/\_\_main\_\_.py", line  
129, in main  
&nbsp;&nbsp;File "/usr/lib/python2.7/site-packages/tower\_cli/models/base.py", line  
499, in get  
&nbsp;&nbsp;&nbsp;&nbsp;response = self.read(pk=pk, fail\_on\_no\_results=True,  
fail\_on\_multiple\_results=True, \*\*kwargs)  
&nbsp;&nbsp;File "/usr/lib/python2.7/site-packages/tower\_cli/models/base.py", line  
301, in read  
&nbsp;&nbsp;&nbsp;&nbsp;r = client.get(url, params=params)  
&nbsp;&nbsp;File "/usr/lib/python2.7/site-packages/requests/sessions.py", line  
521, in get  
&nbsp;&nbsp;&nbsp;&nbsp;return self.request('GET', url, \*\*kwargs)  
&nbsp;&nbsp;File "/usr/lib/python2.7/site-packages/tower\_cli/api.py", line 268, in  
request  
&nbsp;&nbsp;&nbsp;&nbsp;raise exc.AuthError('Invalid Tower authentication credentials (HTTP  
401).')  
tower\_cli.exceptions.AuthError: Invalid Tower authentication credentials  
(HTTP 401).

so it sounds like it can't authenticate, but I am using same credentials  
from one of the CI jobs I'm running (outside of Tower) successfully.

So to recap: I've got Ansible Tower Credentials set up, Job template is  
configured to use those credentials and playbook is using tower\_\*  
commands... did I miss something along the way?

---

<div class="post-metadata">

**Author:** ![Andy\_Wang](https://avatars.discourse-cdn.com/v4/letter/a/aca169/32.png) [@Andy\_Wang](https://forum.ansible.com/u/Andy_Wang)\
**Post date:** [March 12, 2019, 7:58pm UTC](https://forum.ansible.com/t/tower-loopback-jobs/29833/6 "2019-03-12T19:58:12Z")

</div>

I find it much easier to orchestrate Ansible Tower jobs using something like Jenkins to call the API.

---

<div class="post-metadata">

**Author:** ![Andy\_Wang](https://avatars.discourse-cdn.com/v4/letter/a/aca169/32.png) [@Andy\_Wang](https://forum.ansible.com/u/Andy_Wang)\
**Post date:** [March 12, 2019, 7:59pm UTC](https://forum.ansible.com/t/tower-loopback-jobs/29833/7 "2019-03-12T19:59:58Z")

</div>

For orchestration we’ve found it’s better to use Jenkins or some such to call the API. We are using Tower so we are behind a few versions, maybe the interface has improved.
