you can 'detect' running on vagrant by looking for the presence of the vagrant user:
sudo "vagrant" do
user "vagrant"
only_if { Etc.getpwent("vagrant") }
end
Worth noting that while this is the default on for example VirtualBox boxes, the username is configurable. Especially with cloud providers like vagrant-aws the odds are that the login user is something else.
Unfortunately I don't know any reliable way to detect when running on Vagrant. Earlier versions set node["instance_role"] to "vagrant" but I don't know why that was removed in Vagrant 1.1.