# Getting ERROR: include\_vars is not a legal parameter in an Ansible task or handler. while running a playbook.

**URL:** <https://forum.ansible.com/t/getting-error-include-vars-is-not-a-legal-parameter-in-an-ansible-task-or-handler-while-running-a-playbook/18115>\
**Category:** Ansible Project\
**Created:** [April 28, 2015, 8:38pm UTC](https://forum.ansible.com/t/getting-error-include-vars-is-not-a-legal-parameter-in-an-ansible-task-or-handler-while-running-a-playbook/18115 "2015-04-28T20:38:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![trupti\_mali](https://avatars.discourse-cdn.com/v4/letter/t/73ab20/32.png) [@trupti\_mali](https://forum.ansible.com/u/trupti_mali)\
**Post date:** [April 28, 2015, 8:38pm UTC](https://forum.ansible.com/t/getting-error-include-vars-is-not-a-legal-parameter-in-an-ansible-task-or-handler-while-running-a-playbook/18115/1 "2015-04-28T20:38:58Z")

</div>

I have seen the earlier thread related to this error.  
[https://groups.google.com/forum/#!search/ERROR$3A$20include\_vars$20is$20not$20a$20legal$20parameter$20in$20an$20Ansible$20task$20or$20handler.$20while$20running$20a$20playbook./ansible-project/7Lnf5uuCWCY/mklVVJ58PwYJ](https://groups.google.com/forum/#!search/ERROR$3A$20include_vars$20is$20not$20a$20legal$20parameter$20in$20an$20Ansible$20task$20or$20handler.$20while$20running$20a$20playbook./ansible-project/7Lnf5uuCWCY/mklVVJ58PwYJ)

And I also tried the solution suggested here. But I am continuing to get this error. Any idea?

Thanks in advance  
Trupti

---

<div class="post-metadata">

**Author:** ![Yassen\_Damyanov](https://avatars.discourse-cdn.com/v4/letter/y/9fc29f/32.png) [@Yassen\_Damyanov](https://forum.ansible.com/u/Yassen_Damyanov)\
**Post date:** [April 30, 2015, 6:42am UTC](https://forum.ansible.com/t/getting-error-include-vars-is-not-a-legal-parameter-in-an-ansible-task-or-handler-while-running-a-playbook/18115/2 "2015-04-30T06:42:01Z")

</div>

You didn’t share your playbook code, but AFAICT, you should place that “include\_vars” directive into a separate task, like this:

`

- include\_vars: “{{ packages\_path }}/vars/packages/prod-env.yml”

# `do something with those vars, e.g. install packages`

- name: install packages  
yum: name={{ item }} state=present update\_cache=yes  
with\_flattened:
- prod\_env\_packages

`

HTH,  
-Y.
