# include\_vars and include before hosts play i need to implement

**URL:** <https://forum.ansible.com/t/include-vars-and-include-before-hosts-play-i-need-to-implement/22698>\
**Category:** Ansible Project\
**Created:** [October 1, 2016, 11:22am UTC](https://forum.ansible.com/t/include-vars-and-include-before-hosts-play-i-need-to-implement/22698 "2016-10-01T11:22:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pinky](https://avatars.discourse-cdn.com/v4/letter/p/3d9bf3/32.png) [@pinky](https://forum.ansible.com/u/pinky)\
**Post date:** [October 1, 2016, 11:22am UTC](https://forum.ansible.com/t/include-vars-and-include-before-hosts-play-i-need-to-implement/22698/1 "2016-10-01T11:22:00Z")

</div>

Hi,

I have created my own custom library , i added my custom library in the common folder of my repository.In that i need to pass variables dyanamically .Its a confidential password,so iam using “vault” in ansible.

In that my requirement is how to pass include\_vars in the tasks\main.yml before hosts.

e.g: mytasks.yml

- include\_vars: sample\_vault.yml
- include: sample\_tasks.yml
- hosts: localhost  
tasks:  
name: “free task”  
command: ls -a

my directory structure like this:

myfolder

- common  
-library  
-my file.py

- sample\_tasks.yml

- mytasks  
-mytasks.yml(my main master playbook file)  
-sample\_vault.yml (note:i create this using vault for confidential purpose)

- roles  
-myrole

Here i need to run sample\_tasks file using a variables passed in sample\_vault.yml file before i execute the hosts tasks using ansible.If i use extra variable means password is visible so i dont need that.

When i use include\_vars in my tasks/main.yml file, it shows the following error:

“ERROR! ‘include\_vars’ is not a valid attribute for a Play”

Thanks

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [October 3, 2016, 4:26am UTC](https://forum.ansible.com/t/include-vars-and-include-before-hosts-play-i-need-to-implement/22698/2 "2016-10-03T04:26:22Z")

</div>

No tasks can live outside of a play, except for `include` and this exception only applies when it is including plays.

include\_vars must be inside a play.
