Information Technology Reference
In-Depth Information
logout
Connection to 127.0.0.1 closed.
You should notice:
▪ The node['motd-attributes']['company'] value set in the recipe 'My Company' has
a higher priority than the value 'Chef' set in the attribute file, so this is the value dis-
played in the template.
▪ The node['ipaddress'] value set in the recipe '1.1.1.1' has a lower priority than the
automatic value 10.0.2.15 set by ohai , so the value set in the recipe is ignored, and the
template displays the higher priority value.
These priorities represent how the variables are intended to be used. Values set in an attribute
file are intended to be defaults that can be overridden by a recipe. On the other hand, the
automatic values set by ohai should never be overridden as they represent important inform-
ation about a system, such as the fact that it shouldn't be easy to reset the node's IP address,
for example.
Include_Recipe
You might wonder why there is a need for this priority mechanism with Chef attributes. It's
because like in most other programming languages, a Chef recipe can reference other Chef
recipe files using an “include” statement: include_recipe . So when your Chef code is pro-
cessed during a Chef run, it could possibly include a chain of references to multiple recipe
files that might even be in other cookbooks, as shown in Figure 8-4 . Because you can use
include_recipe , Chef code might contain conflicting attribute assignments, and there needs
to be some guidelines for how these conflicts are resolved.
Search WWH ::




Custom Search