class Chef::Resource::Deploy

Deploy: Deploy apps from a source control repository.

Callbacks: Callbacks can be a block or a string. If given a block, the code is evaluated as an embedded recipe, and run at the specified point in the deploy process. If given a string, the string is taken as a path to a callback file/recipe. Paths are evaluated relative to the release directory. Callback files can contain chef code (resources, etc.)

Public Class Methods

new(name, run_context=nil) click to toggle source
Calls superclass method Chef::Resource.new
# File lib/chef/resource/deploy.rb, line 60
def initialize(name, run_context=nil)
  super
  @resource_name = :deploy
  @deploy_to = name
  @environment = nil
  @repository_cache = 'cached-copy'
  @copy_exclude = []
  @purge_before_symlink = %w{log tmp/pids public/system}
  @create_dirs_before_symlink = %w{tmp public config}
  @symlink_before_migrate = {"config/database.yml" => "config/database.yml"}
  @symlinks = {"system" => "public/system", "pids" => "tmp/pids", "log" => "log"}
  @revision = 'HEAD'
  @action = :deploy
  @migrate = false
  @rollback_on_error = false
  @remote = "origin"
  @enable_submodules = false
  @shallow_clone = false
  @scm_provider = Chef::Provider::Git
  @svn_force_export = false
  @provider = Chef::Provider::Deploy::Timestamped
  @allowed_actions.push(:force_deploy, :deploy, :rollback)
  @additional_remotes = Hash[]
  @keep_releases = 5
  @enable_checkout = true
  @checkout_branch = "deploy"
end

Public Instance Methods

additional_remotes(arg=nil) click to toggle source
# File lib/chef/resource/deploy.rb, line 395
def additional_remotes(arg=nil)
  set_or_return(
    :additional_remotes,
    arg,
    :kind_of => Hash
  )
end
after_restart(arg=nil, &block) click to toggle source

Callback fires after restart

# File lib/chef/resource/deploy.rb, line 390
def after_restart(arg=nil, &block)
  arg ||= block
  set_or_return(:after_restart, arg, :kind_of => [Proc, String])
end
before_migrate(arg=nil, &block) click to toggle source

Callback fires before migration is run.

# File lib/chef/resource/deploy.rb, line 372
def before_migrate(arg=nil, &block)
  arg ||= block
  set_or_return(:before_migrate, arg, :kind_of => [Proc, String])
end
before_restart(arg=nil, &block) click to toggle source

Callback fires before restart

# File lib/chef/resource/deploy.rb, line 384
def before_restart(arg=nil, &block)
  arg ||= block
  set_or_return(:before_restart, arg, :kind_of => [Proc, String])
end
branch(arg=nil)
Alias for: revision
checkout_branch(arg=nil) click to toggle source
# File lib/chef/resource/deploy.rb, line 411
def checkout_branch(arg=nil)
  set_or_return(
    :checkout_branch,
    arg,
    :kind_of => String
  )
end
copy_exclude(arg=nil) click to toggle source
# File lib/chef/resource/deploy.rb, line 215
def copy_exclude(arg=nil)
  set_or_return(
    :copy_exclude,
    arg,
    :kind_of => [ String ]
  )
end
current_path() click to toggle source

where the deployed version of your code goes

# File lib/chef/resource/deploy.rb, line 99
def current_path
  @current_path ||= @deploy_to + "/current"
end
deploy_to(arg=nil) click to toggle source

note: #deploy_to is your application “meta-root.”

# File lib/chef/resource/deploy.rb, line 108
def deploy_to(arg=nil)
  set_or_return(
    :deploy_to,
    arg,
    :kind_of => [ String ]
  )
end
depth() click to toggle source
# File lib/chef/resource/deploy.rb, line 103
def depth
  @shallow_clone ? "5" : nil
end
destination() click to toggle source

where the checked out/cloned code goes

# File lib/chef/resource/deploy.rb, line 89
def destination
  @destination ||= shared_path + "/#{@repository_cache}"
end
enable_checkout(arg=nil) click to toggle source
# File lib/chef/resource/deploy.rb, line 403
def enable_checkout(arg=nil)
  set_or_return(
    :enable_checkout,
    arg,
    :kind_of => [TrueClass, FalseClass]
  )
end
enable_submodules(arg=nil) click to toggle source
# File lib/chef/resource/deploy.rb, line 191
def enable_submodules(arg=nil)
  set_or_return(
    :enable_submodules,
    arg,
    :kind_of => [ TrueClass, FalseClass ]
  )
end
environment(arg=nil) click to toggle source
# File lib/chef/resource/deploy.rb, line 293
def environment(arg=nil)
  if arg.is_a?(String)
    Chef::Log.debug "Setting RAILS_ENV, RACK_ENV, and MERB_ENV to `#{arg}'"
    Chef::Log.warn "[DEPRECATED] please modify your deploy recipe or attributes to set the environment using a hash"
    arg = {"RAILS_ENV"=>arg,"MERB_ENV"=>arg,"RACK_ENV"=>arg}
  end
  set_or_return(
    :environment,
    arg,
    :kind_of => [ Hash ]
  )
end
git_ssh_wrapper(arg=nil) click to toggle source
# File lib/chef/resource/deploy.rb, line 232
def git_ssh_wrapper(arg=nil)
  set_or_return(
    :git_ssh_wrapper,
    arg,
    :kind_of => [ String ]
  )
end
Also aliased as: ssh_wrapper
group(arg=nil) click to toggle source
# File lib/chef/resource/deploy.rb, line 183
def group(arg=nil)
  set_or_return(
    :group,
    arg,
    :kind_of => [ String ]
  )
end
keep_releases(arg=nil) click to toggle source

The number of old release directories to keep around after cleanup

# File lib/chef/resource/deploy.rb, line 307
def keep_releases(arg=nil)
  [set_or_return(
    :keep_releases,
    arg,
    :kind_of => [ Integer ]), 1].max
end
migrate(arg=nil) click to toggle source
# File lib/chef/resource/deploy.rb, line 151
def migrate(arg=nil)
  set_or_return(
    :migrate,
    arg,
    :kind_of => [ TrueClass, FalseClass ]
  )
end
migration_command(arg=nil) click to toggle source
# File lib/chef/resource/deploy.rb, line 159
def migration_command(arg=nil)
  set_or_return(
    :migration_command,
    arg,
    :kind_of => [ String ]
  )
end
remote(arg=nil) click to toggle source
# File lib/chef/resource/deploy.rb, line 125
def remote(arg=nil)
  set_or_return(
    :remote,
    arg,
    :kind_of => [ String ]
  )
end
repo(arg=nil) click to toggle source
# File lib/chef/resource/deploy.rb, line 116
def repo(arg=nil)
  set_or_return(
    :repo,
    arg,
    :kind_of => [ String ]
  )
end
Also aliased as: repository
repository(arg=nil)
Alias for: repo
repository_cache(arg=nil) click to toggle source
# File lib/chef/resource/deploy.rb, line 207
def repository_cache(arg=nil)
  set_or_return(
    :repository_cache,
    arg,
    :kind_of => [ String ]
  )
end
restart(arg=nil, &block)
Alias for: restart_command
restart_command(arg=nil, &block) click to toggle source
# File lib/chef/resource/deploy.rb, line 141
def restart_command(arg=nil, &block)
  arg ||= block
  set_or_return(
    :restart_command,
    arg,
    :kind_of => [ String, Proc ]
  )
end
Also aliased as: restart
revision(arg=nil) click to toggle source
# File lib/chef/resource/deploy.rb, line 223
def revision(arg=nil)
  set_or_return(
    :revision,
    arg,
    :kind_of => [ String ]
  )
end
Also aliased as: branch
role(arg=nil) click to toggle source
# File lib/chef/resource/deploy.rb, line 133
def role(arg=nil)
  set_or_return(
    :role,
    arg,
    :kind_of => [ String ]
  )
end
rollback_on_error(arg=nil) click to toggle source
# File lib/chef/resource/deploy.rb, line 167
def rollback_on_error(arg=nil)
  set_or_return(
    :rollback_on_error,
    arg,
    :kind_of => [ TrueClass, FalseClass ]
  )
end
scm_provider(arg=nil) click to toggle source
# File lib/chef/resource/deploy.rb, line 272
def scm_provider(arg=nil)
  klass = if arg.kind_of?(String) || arg.kind_of?(Symbol)
            lookup_provider_constant(arg)
          else
            arg
          end
  set_or_return(
    :scm_provider,
    klass,
    :kind_of => [ Class ]
  )
end
shallow_clone(arg=nil) click to toggle source
# File lib/chef/resource/deploy.rb, line 199
def shallow_clone(arg=nil)
  set_or_return(
    :shallow_clone,
    arg,
    :kind_of => [ TrueClass, FalseClass ]
  )
end
shared_path() click to toggle source

where shared stuff goes, i.e., logs, tmp, etc. goes here

# File lib/chef/resource/deploy.rb, line 94
def shared_path
  @shared_path ||= @deploy_to + "/shared"
end
ssh_wrapper(arg=nil)
Alias for: git_ssh_wrapper
svn_arguments(arg=nil) click to toggle source
# File lib/chef/resource/deploy.rb, line 257
def svn_arguments(arg=nil)
  set_or_return(
    :svn_arguments,
    arg,
    :kind_of => [ String ]
  )
end
svn_force_export(arg=nil) click to toggle source
# File lib/chef/resource/deploy.rb, line 285
def svn_force_export(arg=nil)
  set_or_return(
    :svn_force_export,
    arg,
    :kind_of => [ TrueClass, FalseClass ]
  )
end
svn_info_args(arg=nil) click to toggle source
# File lib/chef/resource/deploy.rb, line 265
def svn_info_args(arg=nil)
  set_or_return(
    :svn_arguments,
    arg,
    :kind_of => [ String ])
end
svn_password(arg=nil) click to toggle source
# File lib/chef/resource/deploy.rb, line 249
def svn_password(arg=nil)
  set_or_return(
    :svn_password,
    arg,
    :kind_of => [ String ]
  )
end
svn_username(arg=nil) click to toggle source
# File lib/chef/resource/deploy.rb, line 241
def svn_username(arg=nil)
  set_or_return(
    :svn_username,
    arg,
    :kind_of => [ String ]
  )
end
timeout(arg=nil) click to toggle source

FIXME The Deploy resource may be passed to an SCM provider as its resource. The SCM provider knows that SCM resources can specify a timeout for SCM operations. The deploy resource must therefore support a timeout method, but the timeout it describes is for SCM operations, not the overall deployment. This is potentially confusing.

# File lib/chef/resource/deploy.rb, line 424
def timeout(arg=nil)
  set_or_return(
    :timeout,
    arg,
    :kind_of => Integer
  )
end
user(arg=nil) click to toggle source
# File lib/chef/resource/deploy.rb, line 175
def user(arg=nil)
  set_or_return(
    :user,
    arg,
    :kind_of => [ String ]
  )
end