/
Capfile
36 lines (29 loc) · 874 Bytes
/
Capfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
default_run_options[:pty] = true
ssh_options[:user] = 'root'
ssh_options[:forward_agent] = true
set :dataroot, "/data/ops"
set :chefroot, "/data/ops/current/chef/repository"
set :repository, "git@github.com:davidx/ops-minimal.git"
set :timestamp, Time.now.strftime("%s")
set :release_path, "#{dataroot}/releases/#{timestamp}"
namespace :ops do
task :deploy do
cmd = "mkdir -p #{dataroot}/releases &&"
cmd << "cd #{dataroot} && git clone #{repository} #{release_path} &&"
cmd << "rm -f #{dataroot}/current && ln -sf #{release_path} #{dataroot}/current"
run cmd
end
end
namespace :chef do
task :runsolo do
update
solo
end
task :solo do
run "cd #{chefroot} && rake runsolo"
end
task :update do
git_command = ENV['branch'] ? "git checkout #{ENV['branch']}" : "git pull"
run "cd #{chefroot} && #{git_command}"
end
end