Capistrano
DSL
ほとんど SSHKit の DSL っぽい。デプロイ固有の部分は Capistrano にある。とりあえずは、SSHKit の DSL を調べるのがよさそう。SSHKit に定義されている DSL と同名の DSL が Capistrano の方にも定義されている。
within
with
test
capture
as
upload!
download!
run_locally Capistrano::DSL と SSHKit::DSL に run_locally が定義してあるけど、中身は同じ内容だった
on Capistrano::DSL と SSHKit::DSL 両方ともにあるが、少し中身が違う
Capistrano::DSL の方は、渡されたホストをフィルタリングしている
shared_path
current_path
release_path
ローカルでタスクを実行
code: (ruby)
desc 'local task'
task :local_task do
run_locally do
execute :say, :hi
end
# or
on :local do
end
end
リモートでタスクを実行
code: (ruby)
desc 'remote task'
task :remote_task do
on roles(:all) do |host|
execute :say, :hi
end
end
test する
code: (ruby)
task :test_dir_exist do
on roles(:all) do |host|
info '/foo/bar directory exists'
else
info '/foo/bar directory not exists'
end
end
end