# Lauching template job via api on custom host (ie. not on an inventory)

**URL:** <https://forum.ansible.com/t/lauching-template-job-via-api-on-custom-host-ie-not-on-an-inventory/31401>\
**Category:** Ansible Project\
**Tags:** awx\
**Created:** [October 1, 2019, 2:00pm UTC](https://forum.ansible.com/t/lauching-template-job-via-api-on-custom-host-ie-not-on-an-inventory/31401 "2019-10-01T14:00:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![MrAquilinux](https://avatars.discourse-cdn.com/v4/letter/m/5daacb/32.png) [@MrAquilinux](https://forum.ansible.com/u/MrAquilinux)\
**Post date:** [October 1, 2019, 2:00pm UTC](https://forum.ansible.com/t/lauching-template-job-via-api-on-custom-host-ie-not-on-an-inventory/31401/1 "2019-10-01T14:00:56Z")

</div>

Hi all, i don’t know if this is really possibile or i can use tower/awx for this.  
Anyway, i’d like to setup a trigger on my monitoring system that, if the trigger is fired on a particular host, launches a template/job/playbook on that host.

For example, a trigger for “low disk space” is fired for host _myhost.local_ on my monitoring software.  
The trigger generates an action that will call via REST API a template on my tower server, ie. a POST to [http://tower.local/job\_templates/13/launch/](http://tower.local/job_templates/13/launch/) .

Now, the job will be lauched for the inventory associated to htat template but i’d like the job to be run only on _myhost.local._

I know i can pass an _inventory id_ via REST API but really id’ like to pass only a _host_ .

How can i do that? Does it make sense?  
Do i have to: create an inventory containing _myhost.local →_ get that _inventory id →_ pass the _inventory id_ via POST when launching template → delete the inventory ?

Thanks!

---

<div class="post-metadata">

**Author:** ![Fabio\_Maia](https://avatars.discourse-cdn.com/v4/letter/f/b4bc9f/32.png) [@Fabio\_Maia](https://forum.ansible.com/u/Fabio_Maia)\
**Post date:** [October 1, 2019, 6:00pm UTC](https://forum.ansible.com/t/lauching-template-job-via-api-on-custom-host-ie-not-on-an-inventory/31401/2 "2019-10-01T18:00:10Z")

</div>

Hi,

You may be able to pass host.local as parameters within content to enable an API using “limit”

`

{  
“name”: “”,  
“description”: “”,  
“job\_type”: “run”,  
“inventory”: null,  
“project”: null,  
“playbook”: “”,  
“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,  
“host\_config\_key”: “”,  
“ask\_scm\_branch\_on\_launch”: false,  
“ask\_diff\_mode\_on\_launch”: false,  
“ask\_variables\_on\_launch”: false,  
“ask\_limit\_on\_launch”: false,  
“ask\_tags\_on\_launch”: false,  
“ask\_skip\_tags\_on\_launch”: false,  
“ask\_job\_type\_on\_launch”: false,  
“ask\_verbosity\_on\_launch”: false,  
“ask\_inventory\_on\_launch”: false,  
“ask\_credential\_on\_launch”: false,  
“survey\_enabled”: false,  
“become\_enabled”: false,  
“diff\_mode”: false,  
“allow\_simultaneous”: false,  
“custom\_virtualenv”: null,  
“job\_slice\_count”: 1  
}

`

---

<div class="post-metadata">

**Author:** ![MrAquilinux](https://avatars.discourse-cdn.com/v4/letter/m/5daacb/32.png) [@MrAquilinux](https://forum.ansible.com/u/MrAquilinux)\
**Post date:** [October 1, 2019, 6:59pm UTC](https://forum.ansible.com/t/lauching-template-job-via-api-on-custom-host-ie-not-on-an-inventory/31401/3 "2019-10-01T18:59:41Z")

</div>

Hi Fabio, thanks for you answer, I’ll give it a try.  
However, I managed to get the desired behaviour just setting hosts value as a var, like

hosts: {{ host\_to\_check }}

and passing the desired host in extra\_vars like

{ “extra\_vars”: { “host\_to\_check”: “my host.local” } }

This wasn’t working before until I flagged the prompt checkbox for extra\_vars in template.

Thanks!

---

<div class="post-metadata">

**Author:** ![dpowell](https://avatars.discourse-cdn.com/v4/letter/d/e95f7d/32.png) [@dpowell](https://forum.ansible.com/u/dpowell)\
**Post date:** [December 11, 2019, 8:17pm UTC](https://forum.ansible.com/t/lauching-template-job-via-api-on-custom-host-ie-not-on-an-inventory/31401/4 "2019-12-11T20:17:22Z")

</div>

Hello aquilinux. Was wondering if you knew what I might be doing wrong or what might have changed. When using your example I get the below errors. Thanks for your time.

`

**[WARNING]: provided hosts list is empty, only localhost is available. Note**

3  
**that the implicit localhost does not match ‘all’**

4

5  
**[WARNING]: Could not match supplied host pattern, ignoring:**

`
