title: Ansible group_vars in template module
body: <p>I want to copy file using jinja2 templating in ansible.</p>
  
  <p>I have one file inside templates/file.j2 and inside that file I have one variable defined</p>
  
  <pre><code>fos.broker.host={{ fos.broker.host }}
  </code></pre>
  
  <p>Inside group_vars/stage I have the value of this variable as</p>
  
  <pre><code>fos.broker.host: 'api_vl.vlstage.fidor.de'
  </code></pre>
  
  <p>And finally I am deploying it via main.yml and it looks like.</p>
  
  <pre><code>---
  - hosts: vlstage
    vars_files:
      - group_vars/vlstage
  
    tasks:
    - name: copy files to host
      template: src=templates/file.j2 dest=/opt/tomcat/lib/file.conf 
      backup=yes owner=zoaib group=zoaib
  </code></pre>
  
  <p>but when I run command <code>ansible-playbook -i hosts main.yml -u zoaib</code></p>
  
  <p>I get below error:</p>
  
  <pre><code>TASK [copy files to host] *************************************************************************************************************************************************************
  fatal: [s-vl-idl-app02.fidor.intern]: FAILED! =&gt; {"changed": false, "msg": "AnsibleUndefinedVariable: 'fos' is undefined"}
  </code></pre>
  
  <p>any leads to solve the issue ?</p>