Chef

Table Of Contents

subversion

A resource defines the desired state for a single configuration item present on a node that is under management by Chef. A resource collection—one (or more) individual resources—defines the desired state for the entire node. During every chef-client run, the current state of each resource is tested, after which the chef-client will take any steps that are necessary to repair the node and bring it back into the desired state.

Use the subversion resource to manage source control resources that exist in a Subversion repository.

Note

This resource is often used in conjunction with the deploy resource.

Syntax

The syntax for using the subversion resource in a recipe is as follows:

subversion "name" do
  attribute "value" # see attributes section below
  ...
  action :action # see actions section below
end

where

  • subversion tells the chef-client to use the Chef::Provider::Subversion provider during the chef-client run.
  • "name" is the location in which the source files will be placed and/or synchronized with the files under source control management
  • attribute is zero (or more) of the attributes that are available for this resource
  • :action is the step that the resource will ask the provider to take during the chef-client run

The following is an example shows the subversion resource:

subversion "CouchDB Edge" do
  repository "http://svn.apache.org/repos/asf/couchdb/trunk"
  revision "HEAD"
  destination "/opt/mysources/couch"
  action :sync
end

where

  • the name of the resource is CouchDB Edge
  • the repository and reference nodes tell the chef-client which repository and revision to use

Actions

This resource has the following actions:

Action Description
:sync Default. Use to update the source to the specified version, or to get a new clone or checkout.
:checkout Use to clone or check out the source. When a checkout is available, this provider does nothing.
:export Use to export the source, excluding or removing any version control artifacts.
:force_export Use to export the source, excluding or removing any version control artifacts and to force an export of the source that is overwriting the existing copy (if it exists).

Attributes

This resource has the following attributes:

Attribute Description
destination The path to the location to which the source will be cloned, checked out, or exported. Default value: the name of the resource block (see Syntax section above).
group The system group that is responsible for the checked-out code.
provider Optional. Use to specify a provider by using its long name. For example: provider Chef::Provider::Long::Name.
repository The URI for the Subversion repository.
revision The revision to be checked out. This can be symbolic, like HEAD or it can be a source control management-specific revision identifier. Default value: HEAD.
svn_arguments The extra arguments that are passed to the Subversion command.
svn_info_args Use when the svn info command is used by the chef-client and arguments need to be passed. (The svn_arguments command does not work when the svn info command is used.)
svn_password The password for the user that has access to the Subversion repository.
svn_username The user name for a user that has access to the Subversion repository.
user The system user that is responsible for the checked-out code.

Providers

The chef-client will attempt to determine the correct provider during the chef-client run, and then choose the best/correct provider based on configuration data collected at the start of the chef-client run. In general, a specific provider does not need to be specified. In situations where a specific provider must be specified, there are two approaches:

  • Using a provider’s short name as the name of the resource, e.g. short_name "foo" do
  • Using the provider attribute to specify the long name as an attribute of a resource, e.g. provider Chef::Provider::Long::Name

Whenever possible, try using the short name first, and then use the long name when necessary.

This resource has the following providers:

Long name Short name Notes
Chef::Provider::Subversion subversion This provider work only with Subversion.

Examples

The following examples demonstrate various approaches for using resources in recipes. If you want to see examples of how Chef uses resources in recipes, take a closer look at the cookbooks that Chef authors and maintains: https://github.com/opscode-cookbooks.

Get the latest version of an application

subversion "CouchDB Edge" do
  repository "http://svn.apache.org/repos/asf/couchdb/trunk"
  revision "HEAD"
  destination "/opt/mysources/couch"
  action :sync
end