title: How can you tell if chef is running on a VM (i.e. vagrant)
body: <p>I have a chef recipe that can either run on virtual machines or real machines. I need to be able to tell the difference between them inside chef, because I need to treat them differently. I've found something on the internet that said I should just use</p>
  
  <pre><code>if node[:instance_role] == 'vagrant'
  </code></pre>
  
  <p>but that doesn't seem to work for me. node[:instance_role] is just blank.</p>
  
  <p>Do you know any other way of doing it?</p>
  
  <p>I'm using chef_solo with vagrant provisioning</p>