Information Technology Reference
In-Depth Information
This declares a package resource in Chef's DSL. The “ntp” package will be upgraded.
Th is declares a service resource in Chef's DSL. The “apache2” service will be accessible
and manageable by Chef.
If you specify an invalid parameter (either one that does not exist or is misspelled), Chef
will raise an exception:
NoMethodError
-------------
undefined method `not_a_real_parameter' for Chef::Resource
Chef uses a multiphase execution model, which lets you include logic switches or loops
inside Chef code. For example, if you wanted to execute a resource on an array of ob-
jects, you could do so using the following code. The file resource is used to manage a
file. content is a Chef DSL expression used to specify a string that is written to the file:
[ 'bacon' , 'eggs' , 'sausage' ]. each ddo | type |
file "/tmp/ #{ type } " ddo
content " #{ type } is delicious!"
end
end
end
end
In the first phase of evaluation, Chef will dynamically expand that Ruby loop. After the
first phase, internally the code becomes equivalent to:
file '/tmp/bacon' ddo
content 'bacon is delicious!'
end
end
file '/tmp/eggs' ddo
content 'eggs is delicious!'
end
end
file '/tmp/sausage' ddo
content 'sausage is delicious!'
end
end
 
Search WWH ::




Custom Search