Reputation: 13
If I have a line like the below in an .erb:
TMP_DIR=$(mktemp -d <%= @temp_dir %>/tmp_dir.XXXXXX)
Is there a way I can get Chef to fail, or at least report, if the @temp_dir variable is undefined?
Ideally I'd like to do this with a single call at the top of the recipe, or at the command line with a config option (I'm using chef-client).
Thanks ahead!
Upvotes: 0
Views: 133
Reputation: 1525
You can throw an error and exit Chef with:
Chef::Application.fatal!("Temporary directory is undefined") unless defined? temp_dir
It will not cover empty variable, so you might add temp_dir.empty?
check or whatever applies to your case
Upvotes: 0