Attributes are defined in a cookbook and then used to override the default settings on a machine. When chef-client executes, it loads all the recipes and checks for all the attributes in a node. Attributes defined in a cookbook take precedence over the default attributes. The chef-client applies new settings and values accordingly on a new node.
The order of the attributes' precedence is mentioned as follows:
Now, we will create a database name in our
attributes/default.rb file and use it in the
# wpblog/recipes/default.rb Default.wpblog.database = 'wpblog' # Replace the name of database with attribute, now final resource will look like this: mysql_database node['wpblog']['database'] do connection ( :host => 'localhost', :username => 'root', :password => node['mysql']['server_root_password...