DevOps Classroom Series – 09/Nov/2021

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
  • 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 default and 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_if and not_if which 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

Leave a comment

Turn on JavaScript to leave a comment.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Social Network Integration by Acurax Social Media Branding Company
Exit mobile version
%%footer%%