Skip to content
This repository has been archived by the owner on Dec 31, 2022. It is now read-only.

Commit

Permalink
Added symlinking defaults. Resolves #16
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Rzegocki committed Apr 18, 2016
1 parent fbb07dc commit 4a1edd9
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 5 deletions.
13 changes: 13 additions & 0 deletions attributes/default.rb
@@ -1,4 +1,17 @@
# frozen_string_literal: true

# deploy
default['defaults']['deploy']['symlinks'] = {
'system' => 'public/system',
'assets' => 'public/assets',
'cache' => 'tmp/cache',
'pids' => 'tmp/pids',
'log' => 'log'
}
default['defaults']['deploy']['create_dirs_before_symlink'] =
%w(tmp public config ../../shared/cache ../../shared/assets)
default['defaults']['deploy']['purge_before_symlink'] = %w(log tmp/cache tmp/pids public/system public/assets)

# ruby

default['build-essential']['compile_time'] = true
Expand Down
10 changes: 7 additions & 3 deletions recipes/deploy.rb
Expand Up @@ -24,11 +24,15 @@
rollback_on_error true
environment framework.out[:deploy_environment]

create_dirs_before_symlink deploy[:create_dirs_before_symlink]
keep_releases deploy[:keep_releases]
purge_before_symlink deploy[:purge_before_symlink] if deploy[:purge_before_symlink]
create_dirs_before_symlink(
(node['defaults']['deploy']['create_dirs_before_symlink'] + Array.wrap(deploy[:create_dirs_before_symlink])).uniq
)
purge_before_symlink(
(node['defaults']['deploy']['purge_before_symlink'] + Array.wrap(deploy[:purge_before_symlink])).uniq
)
symlink_before_migrate deploy[:symlink_before_migrate]
symlinks deploy[:symlinks] if deploy[:symlinks]
symlinks(node['defaults']['deploy']['symlinks'].merge(deploy[:symlinks] || {}))

scm.out.each do |scm_key, scm_value|
send(scm_key, scm_value)
Expand Down
16 changes: 15 additions & 1 deletion spec/fixtures/node.rb
Expand Up @@ -42,10 +42,24 @@ def node(override = {})
framework: {
adapter: 'rails',
migrate: false
}
},
create_dirs_before_symlink: %(../shared/test),
purge_before_symlink: %w(public/test),
symlinks: { 'test' => 'public/test' }
}
},
defaults: {
deploy: {
symlinks: {
system: 'public/system',
assets: 'public/assets',
cache: 'tmp/cache',
pids: 'tmp/pids',
log: 'log'
},
create_dirs_before_symlink: %w(tmp public config ../../shared/cache ../../shared/assets),
purge_before_symlink: %w(log tmp/cache tmp/pids public/system public/assets)
},
appserver: {
adapter: 'unicorn',
worker_processes: 8
Expand Down
12 changes: 11 additions & 1 deletion spec/unit/recipes/deploy_spec.rb
Expand Up @@ -43,7 +43,17 @@
revision: 'master',
scm_provider: Chef::Provider::Git,
enable_submodules: false,
ssh_wrapper: '/tmp/ssh-git-wrapper.sh'
ssh_wrapper: '/tmp/ssh-git-wrapper.sh',
symlinks: {
'system' => 'public/system',
'assets' => 'public/assets',
'cache' => 'tmp/cache',
'pids' => 'tmp/pids',
'log' => 'log',
'test' => 'public/test'
},
'create_dirs_before_symlink' => %w(tmp public config ../../shared/cache ../../shared/assets ../shared/test),
'purge_before_symlink' => %w(log tmp/cache tmp/pids public/system public/assets public/test)
)

expect(chef_run).to run_execute('stop unicorn')
Expand Down

0 comments on commit 4a1edd9

Please sign in to comment.