I am trying to have a setup so that when I have new servers, instead of using an image I can just do capistrano deploy setup.
My issues are abundant, which I think are due to me using Capistrano V3. For example, my first thought was to use the rvm-capistrano gem but I am getting the following issue. I did include require "rvm/capistrano" in both my deploy.rb file and capfile just to make sure.
cap staging rvm:install_rvm
cap aborted!
Don't know how to build task 'rvm:install_rvm'
So then I look around and it turns out there is a capistrano-rvm gem apperentally meant specifically for capistrano v3, but it seems to be undeveloped and has the same issue, capistrano does not understand rvm:install_rvm.
So later I decide to just try to install rvm within the task itself, doing
sudo "apt-get -y install curl"
execute "\curl -L https://get.rvm.io | bash"
execute "source ~/.rvm/scripts/rvm"
execute "rvm requirements"
execute "rvm install ruby"
execute "rvm use ruby --default"
execute "rvm rubygems current"
execute "gem install rails"
but I get this and have no idea why the letters cu from curl go away:
INFO [7e26eda7] Running /usr/bin/env rl -L https://get.rvm.io | bash on 192.168.1.126
DEBUG [7e26eda7] Command: rl -L https://get.rvm.io | bash
DEBUG [7e26eda7] bash: $'\025rl': command not found
DEBUG [7e26eda7]
INFO [7e26eda7] Finished in 0.006 seconds command successful.
INFO [14e12c80] Running /usr/bin/env source ~/.rvm/scripts/rvm on 192.168.1.126
DEBUG [14e12c80] Command: source ~/.rvm/scripts/rvm
INFO [14e12c80] Finished in 0.153 seconds command successful.
INFO [a501984d] Running /usr/bin/env rvm requirements on 192.168.1.126
DEBUG [a501984d] Command: rvm requirements
cap aborted!
rvm requirements stdout: Nothing written
rvm requirements stderr: Nothing written
/home/hak8or/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-0.0.34/lib/sshkit/command.rb:94:in `exit_status='
/home/hak8or/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-0.0.34/lib/sshkit/backends/netssh.rb:125:in `block (4 levels) in _execute'
So after some googling I try
execute "curl -L get.rvm.io | bash -s stable --auto"
but in return I get
INFO [0e84ae63] Running /usr/bin/env source ~/.rvm/scripts/rvm on 192.168.1.126
DEBUG [0e84ae63] Command: source ~/.rvm/scripts/rvm
INFO [0e84ae63] Finished in 0.139 seconds command successful.
INFO [9e5a9f02] Running /usr/bin/env rvm requirements on 192.168.1.126
DEBUG [9e5a9f02] Command: rvm requirements
cap aborted!
rvm requirements stdout: Nothing written
rvm requirements stderr: Nothing written
/home/hak8or/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-0.0.34/lib/sshkit/command.rb:94:in `exit_status='
/home/hak8or/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-0.0.34/lib/sshkit/backends/netssh.rb:125:in `block (4 levels) in _execute'
and tons of garbage from the curl command. I assume RVM is not installing correctly.
If I just have capistrano run a script containing all these commands I also get tons of garbage in my terminal window. When I run it locally though, meaning I ssh into the machine and run
\curl -L https://get.rvm.io | bash
rvm requirements
I get no issues. I am thinking it has to do with it running through a ssh connection specifically with Capistrano, but have no clue. I am running all this on a deploy user on a ubuntu server fully updated, and for testing purposes I granted full passwordless sudo to the deploy user.
Here is my complete Install Ruby function that I use to build jenkins servers. Keep in mind I use Capistrano V2. Enjoy.
task :install_ruby, roles => :app do
run "yum --exclude=*.i386 --exclude=*.i586 install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel libxml2-devel libxslt-devel"
run "bash -s stable < <(curl -k -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)"
run "source /etc/profile"
run "rvm install 1.9.3 --autolibs=enabled"
run "rvm use 1.9.3 --default"
run "gem install capistrano", { :shell => 'bash'}
run "gem install railsless-deploy", { :shell => 'bash'}
run "gem install ntlm-http; true", { :shell => 'bash'}
run "gem install domain_name", { :shell => 'bash'}
run "gem install webrobots", { :shell => 'bash'}
run "gem install mechanize", { :shell => 'bash'}
end