nickjj / orats

Opinionated rails application templates.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

msg: /usr/local/rvm/scripts/set: line 19: exec: bundle: not found

pacuna opened this issue · comments

I'm getting the next error using the playbook:

TASK: [nickjj.pumacorn | ensure pumacorn starts on a fresh reboot] ************ 
<107.170.201.218> ESTABLISH CONNECTION FOR USER: deployer
<107.170.201.218> REMOTE_MODULE service name=myapp state=started enabled=yes
<107.170.201.218> EXEC ['sshpass', '-d8', 'ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/pacuna/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'Port=22', '-o', 'GSSAPIAuthentication=no', '-o', 'PubkeyAuthentication=no', '-o', 'User=deployer', '-o', 'ConnectTimeout=10', '107.170.201.218', "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1403651816.59-42859357481591 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1403651816.59-42859357481591 && echo $HOME/.ansible/tmp/ansible-tmp-1403651816.59-42859357481591'"]
<107.170.201.218> PUT /tmp/tmpWUjBXm TO /home/deployer/.ansible/tmp/ansible-tmp-1403651816.59-42859357481591/service
<107.170.201.218> EXEC ['sshpass', '-d8', 'ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/pacuna/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'Port=22', '-o', 'GSSAPIAuthentication=no', '-o', 'PubkeyAuthentication=no', '-o', 'User=deployer', '-o', 'ConnectTimeout=10', '107.170.201.218', u'/bin/sh -c \'sudo -k && sudo -H -S -p "[sudo via ansible, key=toerzndmimjybpgtnybjeryiaaqgmvwd] password: " -u root /bin/sh -c \'"\'"\'echo SUDO-SUCCESS-toerzndmimjybpgtnybjeryiaaqgmvwd; LC_CTYPE=C LANG=C /usr/bin/python /home/deployer/.ansible/tmp/ansible-tmp-1403651816.59-42859357481591/service; rm -rf /home/deployer/.ansible/tmp/ansible-tmp-1403651816.59-42859357481591/ >/dev/null 2>&1\'"\'"\'\'']
failed: [107.170.201.218] => {"failed": true}
msg: /usr/local/rvm/scripts/set: line 19: exec: bundle: not found


FATAL: all hosts have already failed -- aborting

Thanks in advance!!

There was a bug with the rvm ansible role which I fixed the other day but I didn't bump the version in orats yet.

Try this for now as a manual fix:

  1. On your workstation: ansible-galaxy install nickjj.ruby --force
    [run the above with sudo if you get a permission error]
  2. Login to your server: sudo rm -rf /usr/local/rvm && sudo rm /etc/profile.d/rvm.sh
  3. Git push a new build of your app (just edit the readme file or something for now)
  4. Run the ansible playbook as normal but add --tags ruby,rails.

Thanks for the answer. Now I'm having this error:

TASK: [nickjj.pumacorn | ensure pumacorn starts on a fresh reboot] ************ 
<107.170.201.218> ESTABLISH CONNECTION FOR USER: deployer
<107.170.201.218> REMOTE_MODULE service name=myapp state=started enabled=yes
<107.170.201.218> EXEC ['sshpass', '-d8', 'ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/pacuna/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'Port=22', '-o', 'GSSAPIAuthentication=no', '-o', 'PubkeyAuthentication=no', '-o', 'User=deployer', '-o', 'ConnectTimeout=10', '107.170.201.218', "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1403656771.11-215157253081438 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1403656771.11-215157253081438 && echo $HOME/.ansible/tmp/ansible-tmp-1403656771.11-215157253081438'"]
<107.170.201.218> PUT /tmp/tmpgeTi9P TO /home/deployer/.ansible/tmp/ansible-tmp-1403656771.11-215157253081438/service
<107.170.201.218> EXEC ['sshpass', '-d8', 'ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/pacuna/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'Port=22', '-o', 'GSSAPIAuthentication=no', '-o', 'PubkeyAuthentication=no', '-o', 'User=deployer', '-o', 'ConnectTimeout=10', '107.170.201.218', u'/bin/sh -c \'sudo -k && sudo -H -S -p "[sudo via ansible, key=hjjsmgvnrrluqgfwoaxmcstvauthopry] password: " -u root /bin/sh -c \'"\'"\'echo SUDO-SUCCESS-hjjsmgvnrrluqgfwoaxmcstvauthopry; LC_CTYPE=C LANG=C /usr/bin/python /home/deployer/.ansible/tmp/ansible-tmp-1403656771.11-215157253081438/service; rm -rf /home/deployer/.ansible/tmp/ansible-tmp-1403656771.11-215157253081438/ >/dev/null 2>&1\'"\'"\'\'']
failed: [107.170.201.218] => {"failed": true}
msg: /usr/local/rvm/gems/ruby-2.1.2@global/gems/bundler-1.6.2/lib/bundler/spec_set.rb:92:in `block in materialize': Could not find rake-10.3.2 in any of the sources (Bundler::GemNotFound)
        from /usr/local/rvm/gems/ruby-2.1.2@global/gems/bundler-1.6.2/lib/bundler/spec_set.rb:85:in `map!'
        from /usr/local/rvm/gems/ruby-2.1.2@global/gems/bundler-1.6.2/lib/bundler/spec_set.rb:85:in `materialize'
        from /usr/local/rvm/gems/ruby-2.1.2@global/gems/bundler-1.6.2/lib/bundler/definition.rb:133:in `specs'
        from /usr/local/rvm/gems/ruby-2.1.2@global/gems/bundler-1.6.2/lib/bundler/definition.rb:178:in `specs_for'
        from /usr/local/rvm/gems/ruby-2.1.2@global/gems/bundler-1.6.2/lib/bundler/definition.rb:167:in `requested_specs'
        from /usr/local/rvm/gems/ruby-2.1.2@global/gems/bundler-1.6.2/lib/bundler/environment.rb:18:in `requested_specs'
        from /usr/local/rvm/gems/ruby-2.1.2@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:13:in `setup'
        from /usr/local/rvm/gems/ruby-2.1.2@global/gems/bundler-1.6.2/lib/bundler.rb:120:in `setup'
        from /usr/local/rvm/gems/ruby-2.1.2@global/gems/bundler-1.6.2/lib/bundler/setup.rb:17:in `<top (required)>'
        from /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'


FATAL: all hosts have already failed -- aborting

Looks like an error with the gem path. I tried bundle install directly on the server and then the deploy was successful

I feel like you may have needed to run bundle install manually because the rails portion of the ansible run is trying to be as idempotent as possible.

It will not run many of the commands (including bundle install) if the git repo has not changed.

You can verify the bundle install task here to see what I mean:
https://github.com/nickjj/ansible-rails/blob/master/tasks/deploy.yml#L6

Your server just happened to be in a state where an error occurred which caused bundle install to fail but your repo didn't change, so the gems were never installed but then pumacorn tried to start the puma server which failed because you have no gems installed.

That's why I included step 3 earlier to modify your git repo first. You can verify this by logging into your server and deleting the entire project directory, then re-run your playbook with --tags rails. It should run without issues.

Yes, so now I tried again with a fresh droplet and had no issues.
Just have this doubt, how the environments variables are being managed in production? If I want to add a new environment variable, for example a Facebook API key, what would be the procedure? also, it's possible to use another branch for deploying? (not master)
Thanks for all the help,

The environment variables on the production server are controlled in inventory/group_vars/all.yml. It's very easy to add one, just add it to the rails_deploy_env dict.

That all.yml file also contains links to what variables you can adjust for each role along with a description on what it does. For example: https://github.com/nickjj/ansible-rails/#role-variables

There is rails_deploy_git_version: master. If you wanted to use a different branch just add that variable to your all.yml and use whatever branch you want. You can overwrite any value you need.

@pacuna

This is fixed in v0.7.1

Patch notes:
https://github.com/nickjj/orats/releases/tag/v0.7.1

Everyone who experienced this bug should generate a new playbook. You can also now upgrade roles without having to upgrade orats once you have v0.7.1, check the documentation https://github.com/nickjj/orats#playbook-faq.

great!, thanks :)