4

I have ansible-playbook succesfully installing rvm. But now i must change default ruby version. I have tried with:

- name: Install Bundler
  command: bash -lc "rvm use 2.1.2-p95"

or

- name: use 2.1
  shell: /usr/bin/env bash -lc "rvm use 2.1.2-p95"

or

- name: use 2.1
  shell: rvm use 2.1.2-p95

But nothing ansible looks like all works fine but when i log ssh with the same user wich use ansible and run rvm current the ruby version is the same.

I suspect from ssh and bash login shell but I can see solution.

Montells
  • 6,389
  • 4
  • 48
  • 53

1 Answers1

8

try:

- name: Install Bundler
  command: rvm alias create default ruby-2.1.2-p95

btw. have you seen RVMs support for Ansible: https://github.com/rvm/rvm1-ansible

mpapis
  • 52,729
  • 14
  • 121
  • 158
  • works great! Can you explain why your solution works? – neo0 Jan 17 '16 at 06:08
  • 3
    it works because ansible is different session, when you log in RVm will try to find default ruby and load it, if it was not defined - then you get nothing – mpapis Jan 28 '16 at 22:48