Reputation: 101
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
if node[:instance_role] == 'vagrant'
but that doesn't seem to work for me. node[:instance_role] is just blank.
Do you know any other way of doing it?
I'm using chef_solo with vagrant provisioning
Upvotes: 4
Views: 1449
Reputation: 54211
Look under node['virtualization']
for information about the VM runtime. Vagrant isn't actually a VM system though, so you won't see anything about that. A better option for Vagrant-specific behavior is to set a node attribute in your Vagrantfile and reference that in your recipe code.
Upvotes: 5