rvm / rvm1-ansible

The official ansible RVM role to install and manage your Ruby versions.
MIT License
271 stars 136 forks source link

Install hangs indefinitely when rvm needs to install ruby version not pre-compiled #70

Open gmalouf opened 8 years ago

gmalouf commented 8 years ago

We are using ruby-2.0.0 on Ubuntu Trusty for our ec2 machines. We've been experiencing a behavior where the ansible deployment hangs indefinitely even after rvm has finished installing ruby as a part of this command:

Restarting ansible (after ensuring ruby was installed on the box manually) allows the deployment to continue to the next tasks.

nickjj commented 8 years ago

How long did you give it to compile? On lower end instances it could take a long time.

gmalouf commented 8 years ago

It takes like 20 minutes to compile - the issue is that ansible just keeps hanging even after this has finished... I logged into the box and confirmed that the ruby version I was installing had in fact finished. I think somehow the response is not getting back to the command that runs the compilation task.

Cryptophobia commented 8 years ago

Hi, I am encountering this problem as well. Installer hangs for very long time on the install rubies step. Any fix for this?

nickjj commented 8 years ago

Not that I know of. I haven't been able to reproduce it. Are you also using ruby-2.0.0 specifically @Careerbuilder2016?

Cryptophobia commented 8 years ago

I am testing the playbook on Ubuntu Trusty Vagrant images. Any ruby version hangs for me, but when I log into the VMs, I see RVM and all ruby versions installed even when ansible hangs.

Cryptophobia commented 8 years ago

Update: So it turns out that rvm calls a lot on apt-get. So when you actually run rvm install, apt-get is called right before installing the ruby binary and apt-get updates the repository sources needed to be updated. If any one of the sources returns a 401 or 404, it breaks. If you force the apt-get update in a task before rvm install, it makes sure that rvm can call on apt-get update and install the dependencies for that ruby version. Also it helps if the target OS version has the rvm binaries. :+1:

rvm list remote to check if your OS has the rvm binaries.

The work around for me was to add a task in tasks/rubies/yml before the Install rubies task to force apt-get to update so to ensure that no error will happen when rvm install command runs next:

- name: Update apt-get to avoid errors
  command: 'sudo apt-get update'
  sudo_user: '{{ rvm1_user }}'

We still have not tested this in Ansible Tower. Maybe we won't need this custom fix there.

nickjj commented 8 years ago

This seems out of scope for this role. You should always be running an apt-get update on a fresh server.

Glad to see this was the issue tho.

Cryptophobia commented 8 years ago

Yes, but the reason Ansible hangs up on the "install rubies" task is because apt-get update has not been ran before. Therefore, the RVM script does not exit properly when that first apt-get call returns improper output and Ansible hangs as a result of that.

I did not plan to run apt-get before running this rvm role or right after provisioning a server. For a Ruby Rails server, rvm should manage my commands to apt-get and download my first ruby. Otherwise, what good is rvm to me? Should I just run apt-get and manage my ruby versions myself? That's what rvm is for...

I am not arguing that you should run apt-get update in a separate task before the "install rubies task" like I did, but you should document somewhere that apt-get should run before the "install rubies" step as rvm is likely to hang Ansible.

This is actually a combination of issues with how rvm script handles apt-get, not just an Ansible issue.

Thanks Nick!

nickjj commented 8 years ago

Running an apt-get update is something you would typically run when spinning up a fresh server, with or without ruby. You absolutely should be running this in a task before using this role, it's a general thing to do.

rvm's use case is to install and manage ruby for you. Either by pulling down pre-compiled binaries, or compiling it for you.

If you feel that rvm should report a proper error for this, then I recommend opening a ticket in the rvm repo because this project just uses rvm under the hood to automate installing/managing ruby with ansible.

holms commented 8 years ago

@nickjj i just had this problem already with your role, and i've found what's the problem. rvm want's to install some dependencies, and it does apt-get update first, and then install few packages. I've solved this by finding rvm dependencies with rvm requirements command (i had to add user to sudoers for this), I've added missing dependencies to task of your role, and now it doesn't ask for sudo anymore :+1: