# Extra\_vars from rulebook appears undefined in the playbook triggered by run\_job\_template

**URL:** <https://forum.ansible.com/t/extra-vars-from-rulebook-appears-undefined-in-the-playbook-triggered-by-run-job-template/11229>\
**Category:** Get Help\
**Tags:** windows\
**Created:** [November 29, 2024, 3:57pm UTC](https://forum.ansible.com/t/extra-vars-from-rulebook-appears-undefined-in-the-playbook-triggered-by-run-job-template/11229 "2024-11-29T15:57:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![carlyle705](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/carlyle705/32/5552_2.png) [@carlyle705](https://forum.ansible.com/u/carlyle705)\
**Post date:** [November 29, 2024, 3:57pm UTC](https://forum.ansible.com/t/extra-vars-from-rulebook-appears-undefined-in-the-playbook-triggered-by-run-job-template/11229/1 "2024-11-29T15:57:52Z")

</div>

The rulebook:

```auto
- name: Listen for events on a webhook
  hosts: all
  # Define our source for events
  sources:
    - ansible.eda.webhook:
        host: 0.0.0.0
        port: 5000
  # Define the conditions we are looking for
  rules:
    - name: Demo rule 
      condition: event.meta["headers"]["Os"] == "linux"
      action:
        run_job_template:
          name: Ansible-Windows-Template
          organization: default
          job_args:
            extra_vars:
              payload: "{{ event.payload.data }}"

```

The template playbook:

```auto
---
- name: Check Connectivity and Report on Windows Hosts
  hosts: G_WIN
  gather_facts: false
  tasks:
    - name: 00 - Display payload from the rulebook
      ansible.builtin.debug:
        msg: "Payload from the rulebook: {{ payload }}"
      delegate_to: localhost

```

Error message:

```auto
{
  "msg": "The task includes an option with an undefined variable. The error was: 'payload' is undefined. 'payload' is undefined\n\nThe error appears to be in '/runner/project/win.yml': line 6, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n tasks:\n - name: 00 - Display payload from the rulebook\n ^ here\n",
  "_ansible_no_log": false
}

```

Reference document: [variables](https://ansible.readthedocs.io/projects/rulebook/en/stable/variables.html)  
AAP Version: **2.5**  
Any help would be appreciated 🙂

---

<div class="post-metadata">

**Author:** ![carlyle705](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/carlyle705/32/5552_2.png) [@carlyle705](https://forum.ansible.com/u/carlyle705)\
**Post date:** [December 1, 2024, 11:42pm UTC](https://forum.ansible.com/t/extra-vars-from-rulebook-appears-undefined-in-the-playbook-triggered-by-run-job-template/11229/2 "2024-12-01T23:42:26Z")

</div>

I just figured it out:

1. In the playbook, I have to define the variables like this:

```auto
  vars_prompt:
    - name: payload
      prompt: ""
      private: false

```

1. When creating the template, “Prompt on launch” has to be checked.

You can pass the whole headers and payload to the job template.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [December 31, 2024, 11:42pm UTC](https://forum.ansible.com/t/extra-vars-from-rulebook-appears-undefined-in-the-playbook-triggered-by-run-job-template/11229/3 "2024-12-31T23:42:55Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
