Chef DSL Basics

A recipe is nothing but a list of resources !

Resource Syntax:

type "name" do
   attribute "value"
   action :type_of_action
end
Resource Example I (Directory Resource):

directory "/tmp/folder" do
  owner "root"
  group "root"
  mode 0755
  action :create
end
Resource Example II (Package Resource):

package "tar" do
  version "1.16.1-1"
  action :install
end

Some attributes are available to all resources, for example some attributes are used to send notifications to other resources, whereas others are used to set up conditional execution rules.

All actions have a default value. Only non-default behaviors of actions and attributes need to be specified. For example, the package resource’s default action is to install and the name of the package defaults to the “name” of the resource, therefore it is possible to write a resource block like this:

package "tar"

and the chef-client will use the default action (:install) to install the tar package.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s