Skip to content

Instantly share code, notes, and snippets.

@proffalken
Created March 8, 2012 15:43
Show Gist options
  • Save proffalken/2001575 to your computer and use it in GitHub Desktop.
Save proffalken/2001575 to your computer and use it in GitHub Desktop.
Error on Environment
## Check to see which environment we are in
if node.chef_environment == "_default" then
text = "\n\n\nENVIRONMENT ERROR\n=================\n\nYou are currently in environment #{node.chef_environment} which does not"
text << "\nhave any roles, recipes or attributes associate with it.\n\nPlease update the node to use one of the following environments:\n\n"
Chef::Environment.list.each do | name,uri |
if name != "_default"
text << "\t* #{name}\n"
end
end
text << "\n\n\n"
Chef::Application.fatal! text
else
puts "\n\nENVIRONMENT IS SAFE: Node configured to use #{node.chef_environment}\n\n"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment