title: Pass environment variable to provisioner in Vagrant
body: <p>I am using the Ansible (local) provisioner for my Vagrant setup. Is there a recommended way to pass an environment variable to the provisioner?</p>
  
  <p>For example, I want to run <code>ENV=development vagrant up</code> and have Vagrant pass the environment variable <code>ENV</code> to Ansible.</p>
  
  <p>I tried using <code>extra_vars</code>, taken from the <a href="https://www.vagrantup.com/docs/provisioning/ansible_common.html#extra_vars" rel="noreferrer">Vagrant documentation</a>:</p>
  
  <pre><code>Vagrant.configure(2) do |vagrant|
      # other configuration
      vagrant.vm.provision :ansible_local do |ansible|
          ansible.playbook = "ansible/server.yml"
          ansible.extra_vars = {
            env: ENV.fetch("ENV", "development")
          }
      end
  end
  </code></pre>
  
  <p>However, when I run <code>vagrant provision</code> (without even using the <code>env</code> variable in Ansible), I get the following:</p>
  
  <pre><code>$ vagrant provision
   ==&gt; default: Running provisioner: ansible_local...
      default: Running ansible-playbook...
  ERROR: Expecting property name: line 1 column 2 (char 1)
  Ansible failed to complete successfully. Any error output should be
  visible above. Please fix these errors and try again.
  </code></pre>
  
  <p>Removing <code>ansible.extra_vars</code> fixes this error, but then I can't accomplish what I wanted to.</p>