how to use include_vars in ansible
<p>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 dynamically. It's a confidential password, so I am using "vault" in ansible.</p>

<p>In that my requirement is how to pass <code>include_vars</code> in the <code>tasks\main.yml</code> before hosts.</p>

<p>e.g: mytasks.yml</p>

<pre><code>- include_vars: sample_vault.yml
- include: sample_tasks.yml
- hosts: localhost
  tasks:
    name: "free task"
    command: ls -a
</code></pre>

<p>my directory structure like this:</p>

<pre><code>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
</code></pre>

<p>Here I need to run sample_tasks file using a variables passed in <code>sample_vault.yml</code> file before I execute the hosts tasks using ansible. If I use extra variable means password is visible so I don't need that.</p>

<p>When I use <code>include_vars</code> in my <code>tasks/main.yml</code> file, it shows the following error:</p>

<blockquote>
  <p>ERROR! 'include_vars' is not a valid attribute for a Play</p>
</blockquote>