---
title: Launch an Ansible job template
source: https://docs.newrelic.com/docs/workflow-automation/setup-and-configure/actions-catalog/ansible/ansible-job-launch
---

This page provides a reference for the `ansible.job.launch` action available in the workflow automation actions catalog. Use this action to launch an Ansible Automation Platform (Automation Controller) job template from a workflow step.

For prerequisites, see [Ansible job actions](https://docs.newrelic.com/docs/workflow-automation/setup-and-configure/actions-catalog/ansible/ansible-job#prerequisites).

## Launch an Ansible job template

The action identifier is `ansible.job.launch`.

Launches an Ansible Automation Platform (Automation Controller) job template and returns the created job. On success, returns a job `id` you can use with [`ansible.job.getStatus`](https://docs.newrelic.com/docs/workflow-automation/setup-and-configure/actions-catalog/ansible/ansible-job-getstatus) to poll the job until it reaches a terminal state. The endpoint is `POST https://{host}/api/controller/v2/job_templates/{jobTemplateId}/launch/`.

### Inputs

The following table describes all available input fields for this action.

| Input             | Type   | Description                                                                                                                                   | Example                                                                                 |
| ----------------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
| **host**          | String | **Required.** Hostname (and optional port) of the Automation Controller, without scheme.                                                      | `${{ :secrets:host }}`                                                                  |
| **authToken**     | String | **Required.** OAuth2 token sent as `Authorization: Bearer <token>`. Create under **Automation Controller > Users > Tokens** with write scope. | `${{ :secrets:ansibleControllerToken }}`                                                |
| **jobTemplateId** | Int    | **Required.** Numeric ID of the job template to launch.                                                                                       | `42`                                                                                    |
| **extraVars**     | Map    | **Optional.** Extra variables passed as `extra_vars`. Requires `ask_variables_on_launch` enabled on the template.                             | `{"target_env": "staging", "app_version": "1.2.3"}`                                     |
| **limit**         | String | **Optional.** Ansible host pattern passed as `limit`. Requires `ask_limit_on_launch`.                                                         | `web-servers`                                                                           |
| **inventory**     | String | **Optional.** Numeric inventory ID overriding the template default. Requires `ask_inventory_on_launch`.                                       | `7`                                                                                     |
| **jobTags**       | String | **Optional.** Comma-separated tags passed as `job_tags`. Requires `ask_tags_on_launch`.                                                       | `deploy,restart`                                                                        |
| **skipTags**      | String | **Optional.** Comma-separated tags to skip, passed as `skip_tags`. Requires `ask_skip_tags_on_launch`.                                        | `notifications`                                                                         |
| **selectors**     | List   | **Optional.** JQ selectors to extract specific fields from the action output.                                                                 | `[{"name": "jobId", "expression": ".id"}, {"name": "status", "expression": ".status"}]` |

### Outputs

The following table describes all output fields returned by this action.

| Output           | Type    | Description                                                                                                                                                                                               |
| ---------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **success**      | Boolean | `true` on success, `false` on failure.                                                                                                                                                                    |
| **response**     | Object  | The created job object. Use the `id` field with `ansible.job.getStatus` to poll status. ```json {   "id": 128,   "status": "pending",   "job_template": 42,   "url": "/api/controller/v2/jobs/128/" } ``` |
| **errorMessage** | String  | Error message on failure. `null` on success.                                                                                                                                                              |

### Example

The following example launches an Ansible job template and captures the job ID for polling.

| Workflow example                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| ```yaml name: launch-ansible-remediation description: Launch an Ansible job template to remediate an incident steps:   - name: launch_job     type: action     action: ansible.job.launch     version: 1     inputs:       host: ${{ :secrets:host }}       authToken: ${{ :secrets:ansibleControllerToken }}       jobTemplateId: "42"       extraVars:         target_env: staging         app_version: "1.2.3"       selectors:         - name: jobId           expression: ".id"     next: end ``` |
