Attributes in Chef
- If we create variables in the recipe, changes to the variables might need change in cookbook versions, if we want to handle the variables in such a way that without uploading new version of cookbook if we can change variable values it would be better.
- In chef for this we have attributes.
- Attributes in Chef can be set from
- recipe
- attribute file in cookbook
- roles
- environment
- Creating an attribute file in chef cookbook
- Exploring command line

- Lets create the attribute file

- Exploring command line
- For adding attributes we need to follow the following syntax
<attribute_type>['attribute-name']='value'
- For now we will be using only one attribute type
defaultand we will be following the convention
default['cookbook_name']['attribute_name'] = 'value'
- To use the attributes in the recipe file replace default with node
node['cookbook_name']['attribute_name']
- Refer Here this changeset for the changes done to accomodate attributes.
Chef Infra Language checking platforms
- Refer Here for the official documentation
- Refer Here for the changes using chef infra language checking platforms
- Refer Here for returning a value based on platform & its version and Refer Here for the changeset containing the changes
Common Resource Functionality: Gaurds
- Every resource in chef can have two properties
only_ifandnot_ifwhich gets executed during converge - A gaurd property accepts either string value of ruby block
- Refer Here for the changeset and Refer Here for the documentation.
Common Resource Functionality: Notifications
- Refer Here for the official docs
- The syntax for notification
- notifies: `notifies :action, ‘resource[name]’, :timer
- Refer Here for usage of notifies
