Created
February 2, 2012 12:36
-
-
Save fpauser/1723276 to your computer and use it in GitHub Desktop.
Rails, VLAD, RVM, SUDO
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For a working sudo in a non-interactive ssh session: | |
1. Copy askpass to $HOME/bin/askpass & make it executeable (chmod +x $HOME/bin/askpass) | |
2. Change your deploy.rb to setup the SUDO_ASKPASS environment variable (see man sudo) | |
Credits: http://serverfault.com/questions/307366/error-deploying-app-with-vlad-running-a-sudo-command-to-ubuntu-server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
puts gets.chomp! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://upstart.ubuntu.com/ | |
# http://ddollar.github.com/foreman/ | |
namespaace :myapp | |
task :init do | |
set :domain, 'user@domain' | |
set :revision, 'master' | |
set :deploy_to, '/var/www/myapp/rails' | |
set :rvm_init, 'source /usr/local/rvm/scripts/rvm && rvm use ruby-1.9.3' | |
set :sudo_flags, sudo_flags << '-S' | |
set :run_as_sudo, [sudo_cmd, sudo_flags].flatten.compact.join(' ') | |
set :askpass_init, 'export SUDO_ASKPASS=$HOME/bin/askpass' | |
end | |
remote_task :deploy => [:init, "vlad:update"] do | |
run [ | |
"cd #{current_release} && #{rvm_init}", | |
"bundle install --path vendor/bundle", | |
"bundle exec rake assets:precompile", | |
"#{askpass_init} && #{run_as_sudo} restart myapp" | |
].join(" && ") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment