title: How to use group_vars from a relative path in Ansible
body: <p>I have a requirement where i need to use the <code>group_vars</code> in Ansible but it does not need to be on the same path. Basically my playbooks are in SVN and whenever we want to deploy we actually checkout the latest playbook with release version and then deploy.</p>
  <p>Playbook which actually executes the deployment has this structure -</p>
  <pre><code>/home/ansible/myapp/ansible-myapp-release/deploy/ansible-myapp-5.80.0-05
   - bin
   - roles
   - myapp-main.yml
   - myapp-full-deployment.yml
   - myapp-config.yml
  </code></pre>
  <p>The other thing which i checkout from SVN is this which contains the configuration for my application and <strong>it does not contain any plays</strong> and it could be different for different environments like preprod, prod, test etc.</p>
  <pre><code>/home/ansible/myapp/ansible-myapp-release/configuration/5.80.0-05/preprod
   - config
   - group_vars
      - preprod.yml
   - inventory
       - myapp
  </code></pre>
  <p>inventory <code>myapp</code> -</p>
  <pre><code>[preprod]
  myapp-preprod
  </code></pre>
  <p>Now when i execute my first playbook I want to use this <code>group_vars</code> because that's where my configuration is in <code>preprod.yml</code> which will be loaded into jinja templates at run time.</p>
  <p>How can i use this <code>inventory</code> and <code>group_vars</code> from this <code>path</code> OR do i need to copy these folders from here to the original playbook <code>root</code> directory and then execute the playbook?</p>
  <p>Please let me know if someone can advice on this.</p>
  <p>The documentation says the path should be relative to where your inventory is stored
  <a href="https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html#organizing-host-and-group-variables" rel="nofollow noreferrer">https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html#organizing-host-and-group-variables</a></p>