Class: Chef::Resource::Deploy
- Inherits:
-
Chef::Resource
- Object
- Chef::Resource
- Chef::Resource::Deploy
- Defined in:
- lib/chef/resource/deploy.rb
Overview
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.)
Direct Known Subclasses
Constant Summary
Constants inherited from Chef::Resource
Instance Attribute Summary
Attributes inherited from Chef::Resource
#allowed_actions, #cookbook_name, #default_guard_interpreter, #elapsed_time, #enclosing_provider, #not_if_args, #only_if_args, #params, #provider, #recipe_name, #resource_name, #retries, #retry_delay, #run_context, #source_line, #updated
Instance Method Summary collapse
- #additional_remotes(arg = nil) ⇒ Object
-
#after_restart(arg = nil, &block) ⇒ Object
Callback fires after restart.
-
#before_migrate(arg = nil, &block) ⇒ Object
Callback fires before migration is run.
-
#before_restart(arg = nil, &block) ⇒ Object
Callback fires before restart.
-
#before_symlink(arg = nil, &block) ⇒ Object
Callback fires before symlinking.
- #checkout_branch(arg = nil) ⇒ Object
- #copy_exclude(arg = nil) ⇒ Object
-
#create_dirs_before_symlink(arg = nil) ⇒ Object
An array of paths, relative to your app’s root, where you expect dirs to exist before symlinking.
-
#current_path ⇒ Object
where the deployed version of your code goes.
-
#deploy_to(arg = nil) ⇒ Object
note: deploy_to is your application “meta-root.”.
- #depth ⇒ Object
-
#destination ⇒ Object
where the checked out/cloned code goes.
- #enable_checkout(arg = nil) ⇒ Object
- #enable_submodules(arg = nil) ⇒ Object
- #environment(arg = nil) ⇒ Object
- #git_ssh_wrapper(arg = nil) ⇒ Object (also: #ssh_wrapper)
- #group(arg = nil) ⇒ Object
-
#initialize(name, run_context = nil) ⇒ Deploy
constructor
A new instance of Deploy.
-
#keep_releases(arg = nil) ⇒ Object
The number of old release directories to keep around after cleanup.
- #migrate(arg = nil) ⇒ Object
- #migration_command(arg = nil) ⇒ Object
-
#purge_before_symlink(arg = nil) ⇒ Object
An array of paths, relative to your app’s root, to be purged from a SCM clone/checkout before symlinking.
- #remote(arg = nil) ⇒ Object
- #repo(arg = nil) ⇒ Object (also: #repository)
- #repository_cache(arg = nil) ⇒ Object
- #restart_command(arg = nil, &block) ⇒ Object (also: #restart)
- #revision(arg = nil) ⇒ Object (also: #branch)
- #role(arg = nil) ⇒ Object
- #rollback_on_error(arg = nil) ⇒ Object
- #scm_provider(arg = nil) ⇒ Object
- #shallow_clone(arg = nil) ⇒ Object
-
#shared_path ⇒ Object
where shared stuff goes, i.e., logs, tmp, etc.
- #svn_arguments(arg = nil) ⇒ Object
- #svn_force_export(arg = nil) ⇒ Object
- #svn_info_args(arg = nil) ⇒ Object
- #svn_password(arg = nil) ⇒ Object
- #svn_username(arg = nil) ⇒ Object
-
#symlink_before_migrate(arg = nil) ⇒ Object
A Hash of shared/dir/path => release/dir/path.
-
#symlinks(arg = nil) ⇒ Object
A Hash of shared/dir/path => release/dir/path.
-
#timeout(arg = nil) ⇒ Object
FIXME The Deploy resource may be passed to an SCM provider as its resource.
- #user(arg = nil) ⇒ Object
Methods inherited from Chef::Resource
#action, #after_created, #as_json, #cookbook_version, #custom_exception_message, #customize_exception, #defined_at, #delayed_notifications, dsl_name, #epic_fail, #events, #guard_interpreter, #identity, identity_attr, #ignore_failure, #immediate_notifications, #inspect, #is, json_create, #load_prior_resource, #method_missing, #name, #node, node_map, #noop, #not_if, #notifies, #notifies_delayed, #notifies_immediately, #only_if, provider_base, #provider_for_action, provides, #resolve_notification_references, resource_for_node, resource_matching_short_name, #resources, #run_action, #sensitive, #should_skip?, #state, state_attrs, strict_const_defined?, #subscribes, #supports, #to_hash, #to_json, #to_s, #to_text, #updated?, #updated_by_last_action, #updated_by_last_action?, #validate_action, #validate_resource_spec!
Methods included from Mixin::ConvertToClassName
#constantize, #convert_to_class_name, #convert_to_snake_case, #filename_to_qualified_string, #snake_case_basename
Methods included from Mixin::DescendantsTracker
#descendants, descendants, direct_descendants, #direct_descendants, find_descendants_by_name, #find_descendants_by_name, #inherited, store_inherited
Methods included from Mixin::Deprecation
Methods included from DSL::RebootPending
Methods included from DSL::PlatformIntrospection
#platform?, #platform_family?, #value_for_platform, #value_for_platform_family
Methods included from DSL::RegistryHelper
#registry_data_exists?, #registry_get_subkeys, #registry_get_values, #registry_has_subkeys?, #registry_key_exists?, #registry_value_exists?
Methods included from Mixin::ParamsValidate
#lazy, #set_or_return, #validate
Methods included from DSL::DataQuery
#data_bag, #data_bag_item, #search
Methods included from EncryptedDataBagItem::CheckEncrypted
Constructor Details
#initialize(name, run_context = nil) ⇒ Deploy
Returns a new instance of Deploy.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# 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 @allowed_actions.push(:force_deploy, :deploy, :rollback) @additional_remotes = Hash[] @keep_releases = 5 @enable_checkout = true @checkout_branch = "deploy" end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Chef::Resource
Instance Method Details
#additional_remotes(arg = nil) ⇒ Object
394 395 396 397 398 399 400 |
# File 'lib/chef/resource/deploy.rb', line 394 def additional_remotes(arg=nil) set_or_return( :additional_remotes, arg, :kind_of => Hash ) end |
#after_restart(arg = nil, &block) ⇒ Object
Callback fires after restart
389 390 391 392 |
# File 'lib/chef/resource/deploy.rb', line 389 def after_restart(arg=nil, &block) arg ||= block set_or_return(:after_restart, arg, :kind_of => [Proc, String]) end |
#before_migrate(arg = nil, &block) ⇒ Object
Callback fires before migration is run.
371 372 373 374 |
# File 'lib/chef/resource/deploy.rb', line 371 def before_migrate(arg=nil, &block) arg ||= block set_or_return(:before_migrate, arg, :kind_of => [Proc, String]) end |
#before_restart(arg = nil, &block) ⇒ Object
Callback fires before restart
383 384 385 386 |
# File 'lib/chef/resource/deploy.rb', line 383 def before_restart(arg=nil, &block) arg ||= block set_or_return(:before_restart, arg, :kind_of => [Proc, String]) end |
#before_symlink(arg = nil, &block) ⇒ Object
Callback fires before symlinking
377 378 379 380 |
# File 'lib/chef/resource/deploy.rb', line 377 def before_symlink(arg=nil, &block) arg ||= block set_or_return(:before_symlink, arg, :kind_of => [Proc, String]) end |
#checkout_branch(arg = nil) ⇒ Object
410 411 412 413 414 415 416 |
# File 'lib/chef/resource/deploy.rb', line 410 def checkout_branch(arg=nil) set_or_return( :checkout_branch, arg, :kind_of => String ) end |
#copy_exclude(arg = nil) ⇒ Object
214 215 216 217 218 219 220 |
# File 'lib/chef/resource/deploy.rb', line 214 def copy_exclude(arg=nil) set_or_return( :copy_exclude, arg, :kind_of => [ String ] ) end |
#create_dirs_before_symlink(arg = nil) ⇒ Object
An array of paths, relative to your app’s root, where you expect dirs to exist before symlinking. This runs after #purge_before_symlink, so you can use this to recreate dirs that you had previously purged. For example, if you plan to use a shared directory for pids, and you want it to be located in $APP_ROOT/tmp/pids, you could purge tmp, then specify tmp here so that the tmp directory will exist when you symlink the pids directory in to the current release. Default: [“tmp”, “public”, “config”]
333 334 335 336 337 338 339 |
# File 'lib/chef/resource/deploy.rb', line 333 def create_dirs_before_symlink(arg=nil) set_or_return( :create_dirs_before_symlink, arg, :kind_of => Array ) end |
#current_path ⇒ Object
where the deployed version of your code goes
98 99 100 |
# File 'lib/chef/resource/deploy.rb', line 98 def current_path @current_path ||= @deploy_to + "/current" end |
#deploy_to(arg = nil) ⇒ Object
note: deploy_to is your application “meta-root.”
107 108 109 110 111 112 113 |
# File 'lib/chef/resource/deploy.rb', line 107 def deploy_to(arg=nil) set_or_return( :deploy_to, arg, :kind_of => [ String ] ) end |
#depth ⇒ Object
102 103 104 |
# File 'lib/chef/resource/deploy.rb', line 102 def depth @shallow_clone ? "5" : nil end |
#destination ⇒ Object
where the checked out/cloned code goes
88 89 90 |
# File 'lib/chef/resource/deploy.rb', line 88 def destination @destination ||= shared_path + "/#{@repository_cache}" end |
#enable_checkout(arg = nil) ⇒ Object
402 403 404 405 406 407 408 |
# File 'lib/chef/resource/deploy.rb', line 402 def enable_checkout(arg=nil) set_or_return( :enable_checkout, arg, :kind_of => [TrueClass, FalseClass] ) end |
#enable_submodules(arg = nil) ⇒ Object
190 191 192 193 194 195 196 |
# File 'lib/chef/resource/deploy.rb', line 190 def enable_submodules(arg=nil) set_or_return( :enable_submodules, arg, :kind_of => [ TrueClass, FalseClass ] ) end |
#environment(arg = nil) ⇒ Object
292 293 294 295 296 297 298 299 300 301 302 303 |
# File 'lib/chef/resource/deploy.rb', line 292 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) ⇒ Object Also known as: ssh_wrapper
231 232 233 234 235 236 237 |
# File 'lib/chef/resource/deploy.rb', line 231 def git_ssh_wrapper(arg=nil) set_or_return( :git_ssh_wrapper, arg, :kind_of => [ String ] ) end |
#group(arg = nil) ⇒ Object
182 183 184 185 186 187 188 |
# File 'lib/chef/resource/deploy.rb', line 182 def group(arg=nil) set_or_return( :group, arg, :kind_of => [ String ] ) end |
#keep_releases(arg = nil) ⇒ Object
The number of old release directories to keep around after cleanup
306 307 308 309 310 311 |
# File 'lib/chef/resource/deploy.rb', line 306 def keep_releases(arg=nil) [set_or_return( :keep_releases, arg, :kind_of => [ Integer ]), 1].max end |
#migrate(arg = nil) ⇒ Object
150 151 152 153 154 155 156 |
# File 'lib/chef/resource/deploy.rb', line 150 def migrate(arg=nil) set_or_return( :migrate, arg, :kind_of => [ TrueClass, FalseClass ] ) end |
#migration_command(arg = nil) ⇒ Object
158 159 160 161 162 163 164 |
# File 'lib/chef/resource/deploy.rb', line 158 def migration_command(arg=nil) set_or_return( :migration_command, arg, :kind_of => [ String ] ) end |
#purge_before_symlink(arg = nil) ⇒ Object
An array of paths, relative to your app’s root, to be purged from a SCM clone/checkout before symlinking. Use this to get rid of files and directories you want to be shared between releases. Default: [“log”, “tmp/pids”, “public/system”]
317 318 319 320 321 322 323 |
# File 'lib/chef/resource/deploy.rb', line 317 def purge_before_symlink(arg=nil) set_or_return( :purge_before_symlink, arg, :kind_of => Array ) end |
#remote(arg = nil) ⇒ Object
124 125 126 127 128 129 130 |
# File 'lib/chef/resource/deploy.rb', line 124 def remote(arg=nil) set_or_return( :remote, arg, :kind_of => [ String ] ) end |
#repo(arg = nil) ⇒ Object Also known as: repository
115 116 117 118 119 120 121 |
# File 'lib/chef/resource/deploy.rb', line 115 def repo(arg=nil) set_or_return( :repo, arg, :kind_of => [ String ] ) end |
#repository_cache(arg = nil) ⇒ Object
206 207 208 209 210 211 212 |
# File 'lib/chef/resource/deploy.rb', line 206 def repository_cache(arg=nil) set_or_return( :repository_cache, arg, :kind_of => [ String ] ) end |
#restart_command(arg = nil, &block) ⇒ Object Also known as: restart
140 141 142 143 144 145 146 147 |
# File 'lib/chef/resource/deploy.rb', line 140 def restart_command(arg=nil, &block) arg ||= block set_or_return( :restart_command, arg, :kind_of => [ String, Proc ] ) end |
#revision(arg = nil) ⇒ Object Also known as: branch
222 223 224 225 226 227 228 |
# File 'lib/chef/resource/deploy.rb', line 222 def revision(arg=nil) set_or_return( :revision, arg, :kind_of => [ String ] ) end |
#role(arg = nil) ⇒ Object
132 133 134 135 136 137 138 |
# File 'lib/chef/resource/deploy.rb', line 132 def role(arg=nil) set_or_return( :role, arg, :kind_of => [ String ] ) end |
#rollback_on_error(arg = nil) ⇒ Object
166 167 168 169 170 171 172 |
# File 'lib/chef/resource/deploy.rb', line 166 def rollback_on_error(arg=nil) set_or_return( :rollback_on_error, arg, :kind_of => [ TrueClass, FalseClass ] ) end |
#scm_provider(arg = nil) ⇒ Object
271 272 273 274 275 276 277 278 279 280 281 282 |
# File 'lib/chef/resource/deploy.rb', line 271 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) ⇒ Object
198 199 200 201 202 203 204 |
# File 'lib/chef/resource/deploy.rb', line 198 def shallow_clone(arg=nil) set_or_return( :shallow_clone, arg, :kind_of => [ TrueClass, FalseClass ] ) end |
#shared_path ⇒ Object
where shared stuff goes, i.e., logs, tmp, etc. goes here
93 94 95 |
# File 'lib/chef/resource/deploy.rb', line 93 def shared_path @shared_path ||= @deploy_to + "/shared" end |
#svn_arguments(arg = nil) ⇒ Object
256 257 258 259 260 261 262 |
# File 'lib/chef/resource/deploy.rb', line 256 def svn_arguments(arg=nil) set_or_return( :svn_arguments, arg, :kind_of => [ String ] ) end |
#svn_force_export(arg = nil) ⇒ Object
284 285 286 287 288 289 290 |
# File 'lib/chef/resource/deploy.rb', line 284 def svn_force_export(arg=nil) set_or_return( :svn_force_export, arg, :kind_of => [ TrueClass, FalseClass ] ) end |
#svn_info_args(arg = nil) ⇒ Object
264 265 266 267 268 269 |
# File 'lib/chef/resource/deploy.rb', line 264 def svn_info_args(arg=nil) set_or_return( :svn_arguments, arg, :kind_of => [ String ]) end |
#svn_password(arg = nil) ⇒ Object
248 249 250 251 252 253 254 |
# File 'lib/chef/resource/deploy.rb', line 248 def svn_password(arg=nil) set_or_return( :svn_password, arg, :kind_of => [ String ] ) end |
#svn_username(arg = nil) ⇒ Object
240 241 242 243 244 245 246 |
# File 'lib/chef/resource/deploy.rb', line 240 def svn_username(arg=nil) set_or_return( :svn_username, arg, :kind_of => [ String ] ) end |
#symlink_before_migrate(arg = nil) ⇒ Object
A Hash of shared/dir/path => release/dir/path. This attribute determines which files in the shared directory get symlinked to the current release directory and where they go. Unlike map_shared_files, these are symlinked before any migration is run. For a rails/merb app, this is used to link in a known good database.yml (with the production db password) before running migrate. Default => “config/database.yml”
362 363 364 365 366 367 368 |
# File 'lib/chef/resource/deploy.rb', line 362 def symlink_before_migrate(arg=nil) set_or_return( :symlink_before_migrate, arg, :kind_of => Hash ) end |
#symlinks(arg = nil) ⇒ Object
A Hash of shared/dir/path => release/dir/path. This attribute determines which files and dirs in the shared directory get symlinked to the current release directory, and where they go. If you have a directory $shared/pids that you would like to symlink as $current_release/tmp/pids you specify it as “pids” => “tmp/pids” Default => “public/system”, “pids” => “tmp/pids”, “log” => “log”
347 348 349 350 351 352 353 |
# File 'lib/chef/resource/deploy.rb', line 347 def symlinks(arg=nil) set_or_return( :symlinks, arg, :kind_of => Hash ) end |
#timeout(arg = nil) ⇒ Object
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.
423 424 425 426 427 428 429 |
# File 'lib/chef/resource/deploy.rb', line 423 def timeout(arg=nil) set_or_return( :timeout, arg, :kind_of => Integer ) end |