rvm1-ansible
rvm1-ansible copied to clipboard
Gems installed by root user lands in `/root/.gem`
I install some ruby with this dependency:
---
dependencies:
- role: rvm_io.rvm1-ruby
rvm1_rubies:
- ruby-2.0.0-p643
rvm1_default_ruby_version: ruby-2.0.0-p643
and later on install a gem with following task:
- name: install backup gem
tags: focus
gem: name=backup version=4.2 state=present executable=/usr/local/rvm/rubies/ruby-2.0.0-p643/bin/gem
them gem lands into /root/.gem/ruby/2.0.0/gems/
instead of rvm's path. There is only a wrapper in /usr/local/rvm
for backup
binary.
I've tried with manually overriding environment like this:
environment:
PATH: "/usr/local/rvm/gems/{{default_ruby}}/bin:/usr/local/rvm/gems/{{default_ruby}}@global/bin:/usr/local/rvm/rubies/{{default_ruby}}/bin:{{ansible_env.PATH}}"
GEM_HOME: /usr/local/rvm/gems/{{default_ruby}}
GEM_PATH: /usr/local/rvm/gems/{{default_ruby}}:/usr/local/rvm/gems/{{default_ruby}}@global
but without any luck.
Is it even possible to use gem_module
to install gems for rvm rubies? Or i should fallback to some shell:
with creates:
trickery?
Thanks for any help!
My versions:
ansible 1.9.3
rvm1-ansible v1.3.7
A response would be greatly appreciated. I am quite new to ansible and have the exact same issue with latest version of this role and ansible.
+1
I'll take a look at this and post something here ASAP.
The Ansible 'gem' task is the issue here (although I haven't tested with RVM to verify, I've bumped into the same issue elsewhere). It's actually in the docs, but by default the 'gem' task does a 'user-install', so it'll end up in whatever user the task is running as (in your case, that's root).
Change your gem task to this:
- name: install backup gem
tags: focus
gem: name=backup user_install=no version=4.2 state=present executable=/usr/local/rvm/rubies/ruby-2.0.0-p643/bin/gem