Chef resources
Chef uses Ruby to define configuration items. A configuration item is defined as a resource. A cookbook contains a set of resources for one feature.
Chef manages types of resources. Each resource has a type, a name, one or more properties, and one action. Every property has a value. The value specifies the state desired for the resource. You can specify the state of a device by setting values for properties regardless of how the device enters the state. The following resource example shows how to configure a device to create VLAN 2 and configure the description for VLAN 2.
netdev_vlan 'vlan2' do vlan_id 2 description 'chef-vlan2' action :create end
The following are the resource type, resource name, properties, and actions:
netdev_vlan—Type of the resource.
vlan2—Name of the resource. The name is the unique identifier of the resource.
do/end—Indicates the beginning and end of a Ruby block that contains properties and actions. All Chef resources must be written by using the do/end syntax.
vlan_id—Property for specifying a VLAN. In this example, VLAN 2 is specified.
description—Property for configuring the description. In this example, the description for VLAN 2 is chef-vlan2.
create—Action for creating or modifying a resource. If the resource does not exist, this action creates the resource. If the resource already exists, this action modifies the resource with the new settings. This action is the default action for Chef. If you do not specify an action for a resource, the create action is used.
delete—Action for deleting a resource.
Chef supports only the create and delete actions.
For more information about resource types supported by Chef, see "Chef resources."