PageRenderTime 56ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/config/deploy.rb

https://bitbucket.org/funollet/gurb-platform
Ruby | 63 lines | 51 code | 10 blank | 2 comment | 7 complexity | 517443d1c28810c95ffafd958fb73575 MD5 | raw file
  1. load "config/cap_nodes"
  2. set :application, "gurb-app"
  3. set :repository, "ssh://git@bitbucket.org/funollet/gurb-platform.git"
  4. set :repository, "https://funollet@bitbucket.org/funollet/gurb-platform.git"
  5. set :user, "ubuntu"
  6. set :ssh_options, { :forward_agent => true }
  7. namespace :puppet do
  8. desc "Initialize puppet configuration."
  9. task :init, :roles => :web do
  10. # Clean old config.
  11. run "sudo rm -rf /etc/puppet"
  12. run "sudo mkdir -p /etc/puppet && sudo chown #{user} /etc/puppet"
  13. run "git clone #{repository} /etc/puppet"
  14. run "mkdir /etc/puppet/modules"
  15. end
  16. desc "Run puppet (updates repository, too)."
  17. task :apply, :roles => :web do
  18. run "cd /etc/puppet && git pull"
  19. upload "hieradata/secrets.yaml", "/etc/puppet/hieradata/secrets.yaml", {:mode => 0600}
  20. run "cd /etc/puppet && librarian-puppet install"
  21. run "cd /etc/puppet && sudo puppet apply manifests/site.pp"
  22. end
  23. desc "Run puppet with --noop (updates repository, too)."
  24. task :dryrun, :roles => :web do
  25. run "cd /etc/puppet && git pull"
  26. upload "hieradata/secrets.yaml", "/etc/puppet/hieradata/secrets.yaml", {:mode => 0600}
  27. run "cd /etc/puppet && librarian-puppet install"
  28. run "cd /etc/puppet && sudo puppet apply manifests/site.pp --noop"
  29. end
  30. end
  31. # Deploy a minimalistic application to test Nginx + Unicorn.
  32. namespace :deploy do
  33. desc "Initial setup."
  34. task :setup, :roles => :web do
  35. run "cd /home/#{user} && mkdir -p #{application}"
  36. run "cd /home/#{user}/#{application} && mkdir -p config shared/pids shared/log"
  37. upload "config.ru", "/home/#{user}/#{application}/config.ru"
  38. upload "config/unicorn.rb", "/home/#{user}/#{application}/config/unicorn.rb"
  39. run "sudo start unicorn"
  40. end
  41. desc "Update application."
  42. task :update, :roles => :web do
  43. upload "config.ru", "/home/#{user}/#{application}/config.ru"
  44. upload "config/unicorn.rb", "/home/#{user}/#{application}/config/unicorn.rb"
  45. end
  46. after "deploy:update", "unicorn:restart"
  47. end
  48. namespace :unicorn do
  49. desc "Restart Unicorn."
  50. task :restart, :roles => :web do
  51. run "kill -HUP $(cat /home/#{user}/#{application}/shared/pids/unicorn.pid)"
  52. end
  53. end