- From: Jay Feldblum <
>
- To:
- Subject: [chef] Re: How to validate attribute before recipe is being executed?
- Date: Wed, 13 Mar 2013 14:50:20 -0400
Howard,
You can do something like this in your recipe:
my_value = node["my-cookbook"]["my-namespace"]["my-key"]
unless my_value.kind_of?(Integer) && (1..100).include?(my_value)
Chef::Application.fatal! "Fix your value! It was: #{my_value.inspect}"
end
This will be executed after the attributes from all roles are applied.
This will be executed before any resources from any recipes in the run-list are converged (i.e., before the system is altered).
Cheers,
Jay
On Wed, Mar 13, 2013 at 11:18 AM, howard chen
<
" target="_blank">
> wrote:
For some attributes, our use case is it must be overrided by user, and
it need to follow our validation scheme, e.g. must be an integer <
100, is it possible to validate it before the recipe is being
executed?
Archive powered by MHonArc 2.6.16.