As we've seen so far, any machine (henceforth referred to as node) can be described through Chef by means of recipes, roles, and environment that it is associated with. However, throughout all this there are a few properties associated with a node as well. A node will have properties such as name, IP address, kernel, FQDN, OS type, and so on, associated with it. All these properties help in defining a system in a more meaningful way. The more properties are associated with a node, the better the quality of its definition. Some of these properties are tightly coupled to the system—for example, OS type, kernel, IP address, and so on—while some are abstract in nature. For example, we might have different kinds of web applications in our setup, some related to finance and others perhaps related to HR. All these applications may be deployed on different machines and they all use the same underlying technology stack; hence, they all have a common role, say...
You're reading from Mastering Chef
This can be confusing for some people, especially those who aren't coming from the Ruby world. You looked up two different cookbooks and, in one of them, you found something like the following in the attributes file:
default[:app][:user] = "web-admin"
On the other hand, the other cookbook had something like the following:
default['app]['user'] = "web-admin"
These are two different styles of specifying the keys in a Ruby hash. In one, you are making use of symbols; in the other, you are using strings. You can choose either of these but, for the sake of sanity, try to be consistent. There are some pitfalls in using either approach and there are some inherent benefits too. For example, symbols are immutable and are allocated just once, which is a performance gain. On the other hand, they can be pretty irritating if you are trying to include stuff such as hyphens in their names. If symbols confuse you, stick with strings or vice-versa.
Chef provides six different types of attributes, as listed in the following table:
Attribute type |
Description |
---|---|
|
This attribute is reset upon the start of every chef-client run and has the lowest attribute precedence. A cookbook should make the most use of the |
|
Say you've specified the same |
|
A |
|
An |
|
Similar to the |
Setting |
Description |
---|---|
|
This can be used to specify a hash that whitelists the |