Is it possible to configure Capistrano 3 to link different files based on a role using built-in linked_files
?
I have servers with a role worker
, which don't need to have web-stuff related files linked (i.e. sitemap.xml
file).
Short answer: no, variables in Capistrano (e.g. :linked_files
) are global and cannot have different values per host/role.
You could possibly make it work by redefining the deploy:symlink:linked_files
and deploy:check:linked_files
tasks with your own custom implementation. That implementation could, for example, perform different linking for different roles.
Rake::Task["deploy:symlink:linked_files"].clear_actions
task "deploy:symlink:linked_files" do
on release_roles(:web) do
execute :ln, "-s", ...
execute :ln, "-s", ...
# etc.
end
on release_roles(:app) do
execute :ln, "-s", ...
execute :ln, "-s", ...
# etc.
end
end
However, I would recommend against this for two reasons:
:linked_files