Created
March 8, 2012 15:43
-
-
Save proffalken/2001575 to your computer and use it in GitHub Desktop.
Error on Environment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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