rvm / rvm1-ansible

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

Allow --user-install symlinking #22

Closed mrcrilly closed 7 years ago

mrcrilly commented 9 years ago

When using a user install, the symbolic links will usually be skipped. This means Bundler, as well as the other gems being installed by this role, aren't accessible from a shell script uploaded and executed by Ansible. Here is a very simple, example shell script, followed by the Playbook uploading it, and the Playbook wrapping all of these efforts:

Bundle install our project requirements:

#!/bin/bash
bundle install

The Playbook uploading and executing the above:


---
- name: Upload our Gemfile
  copy: src=Gemfile dest=/home/vagrant/
- name: Run our script 
  script: bundle_install.sh

The "site.yml" Playbook implementing the above:


---
- hosts: all
  sudo: no
  vars:
    rvm1_install_path: '/home/vagrant/.rvm'
    rvm1_install_flags: '--auto-dotfiles --user-install'
    rvm1_rvm_check_for_updates: False
    rvm1_symlink_to: '/home/vagrant/.rvm/bin'
    rvm1_symlink_user: 'vagrant'
    rvm1_symlink_group: 'vagrant'
  roles:
    - rvm_io.rvm1-ruby
    - rubyproject

("rubyproject" just being a dummy project with a Gemfile)

When attempting to execute the Bash script, it was unable to find Bundler. This is because the symbolic link in '/usr/local/bin/' does not exist at this point. With the changes I have implemented in this PR, the symbolic links are created in the user's home directory, under '.rvm/bin', making the core gems (Bundler, etc) available from the shell and from shell scripts. The shell script can now execute, finds Bundler, and successfully installs my gems.

lpaulmp commented 7 years ago

I don't think that use an external script instead of shell module or command module is necessary. I'm closing this one.

mrcrilly commented 7 years ago

ha ha! ok.