title: Ansible variable undefined
body: <p>Why can't I access the variable I defined as group var in the <em>inventory file</em> from the <code>playbook.yml</code>?</p>
  
  <p>Here is the content of <code>playbook.yml</code>:</p>
  
  <pre><code>---
  - name: test ansible local provisioning
    hosts: all
    vars:
      playbook_var: "playbook_var"
    tasks:
      - name: Test ansible is working
        debug: msg="Ansible seems to be working, this variable is from plabook {{ playbook_var }} and this variable is from hosts file {{ hosts_file_var }}"
  </code></pre>
  
  <p>And here is <code>hosts</code>:</p>
  
  <pre><code>[all:vars]
  hosts_file_var="hosts_file_var"
  </code></pre>
  
  <p>Ansible throws the following error:</p>
  
  <pre><code>TASK [Test ansible is working] *************************************************  
  fatal: [ansible_host]: FAILED! =&gt; {"failed": true, "msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: 'hosts_file_var' is undefined
  
  The error appears to have been in '/vagrant/provisioning/ansible_host/playbook.yml': line 7, column 7, but may
  be elsewhere in the file depending on the exact syntax problem.
  
  The offending line appears to be:
    tasks:
      - name: Test ansible is working
        ^ here
  "}
  </code></pre>
  
  <p>Is there some aspect I don't understand about how Ansible processes variables?</p>
  
  <p>Here is also the <code>ansible.cfg</code>. I'm willing to use Ansible for Vagrant provisioning:</p>
  
  <pre><code>[defaults]
  inventory = hosts
  remote_user = vagrant
  </code></pre>