Getting ERROR: include_vars is not a legal parameter in an Ansible task or handler. while running a playbook.

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

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

Thanks in advance
Trupti

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.