popularity question answers views user  
3
Problem with deploy_revision and symlinks

Edit: Is this a bug or intended behavior somehow? I’ve not used Capistrano before and am not sure how closely deploy / deploy_revision fits into its paradigm.

I’m having a similar problem as described at this SO post where Chef is not able to create symlinks in deploy_revision. It seems as though Chef tries to create the symlinks to the releases/{HASH} directory instead of the repository_cache folder, since it’s done pre-migration. I can only get the error to go away if I manually create the hash release folder prior to running chef-client.

$ sudo chef-client -l info
...snip...
Error executing action `deploy` on resource 'deploy_revision[/var/www/vhosts/redacted.com]'


Chef::Exceptions::FileNotFound
Cannot symlink /var/www/vhosts/redacted.com/shared/config.json to /var/www/vhosts/redacted.com/releases/98faa472067f4fb120d97a7cf0eb486a1435f2c9/config.json before migrate: No such file or directory - (/var/www/vhosts/redacted.com/shared/config.json, /var/www/vhosts/redacted.com/releases/98faa472067f4fb120d97a7cf0eb486a1435f2c9/config.json)

I have created the shared/config.json file prior to deploy_revision being run. You can see if I create the releases/98faa472067f4fb120d97a7cf0eb486a1435f2c9 directory before running chef-client, there is no error:

$ sudo -H -u website mkdir -pv /var/www/vhosts/redacted.com/releases/98faa472067f4fb120d97a7cf0eb486a1435f2c9/
$ sudo chef-client -l info
...snip...
  * template[/var/www/vhosts/redacted.com/shared/config.json] action create[2013-03-14T18:07:04+00:00] INFO: Processing template[/var/www/vhosts/redacted.com/shared/config.json] action create (redacted::code line 26) (up to date)
  * deploy_revision[/var/www/vhosts/redacted.com] action deploy[2013-03-14T18:07:04+00:00] INFO: Processing deploy_revision[/var/www/vhosts/redacted.com] action deploy (redacted::code line 75)
...snip...
    - link shared paths into current release:  [2013-03-14T18:07:04+00:00] INFO: deploy_revision[/var/www/vhosts/redacted.com] made pre-migration symlinks

    - make pre-migration symliinks: config.json => config.json, node_modules => node_modules[2013-03-14T18:07:04+00:00]
...snip...
[2013-03-14T18:07:19+00:00] INFO: Chef Run complete in 21.972962944 seconds
[2013-03-14T18:07:19+00:00] INFO: Running report handlers
[2013-03-14T18:07:19+00:00] INFO: Report handlers complete
Chef Client finished, 6 resources updated

How am I supposed to make symlinks before the migration with deploy_revision?

FWIW, using symlink or symlink_before_migrate seems to make no difference.

Interestingly, using the force_deploy action fixes this problem, but I really don’t want to have my code redeploy every time chef runs if I’m not upgrading the git reference point.

Is this a bug in chef-client or am I not understanding the correct usage of deploy_revision?

Edit: here’s the compiled resource that fails without making that directory first:

Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/redacted/recipes/code.rb:75:in `from_file'

deploy_revision("/var/www/vhosts/redacted.com") do
  provider Chef::Provider::Deploy::Revision
  action [:deploy]
  retries 0
  retry_delay 2
  deploy_to "/var/www/vhosts/redacted.com"
  repository_cache "cached-copy"
  symlinks {"config.json"=>"config.json", "node_modules"=>"node_modules"}
  revision "develop"
  rollback_on_error true
  remote "origin"
  enable_submodules true
  scm_provider Chef::Provider::Git
  keep_releases 5
  cookbook_name "redacted"
  recipe_name "code"
  repo "git@github.com:redacted/redacted.git"
  user "website"
  group "website"
  before_restart #<Proc:0x9086e44@/var/chef/cache/cookbooks/redacted/recipes/code.rb:94>
  shared_path "/var/www/vhosts/redacted.com/shared"
  destination "/var/www/vhosts/redacted.com/shared/cached-copy"
  current_path "/var/www/vhosts/redacted.com/current"
end
more →
0 144  
0
Perform group command like fabric

I am from fabric and I know how to perform basic system setup using chef-solo now.

What are the equivalent way to perform mass command to nodes like fabric, e.g. perform “apt-get update” on all nodes and make sure they have all executed?

Is it a must to use chef server for this action?

Thanks.

more →
1 551