From b7c771a1ceb07113d6d61b4c6f24aa919b3c4276 Mon Sep 17 00:00:00 2001 From: Nick Janetakis Date: Mon, 23 Jun 2014 10:23:52 -0400 Subject: [PATCH] Fix default ruby selection for both local and system installs --- tasks/main.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 00ec4b0..868a853 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -57,6 +57,14 @@ command: "{{ ruby_rvm_install_path }}/bin/rvm alias list default" register: ruby_selected -- name: ensure default ruby is selected - command: "{{ ruby_rvm_install_path }}/bin/rvm --default use {{ ruby_version }}" - when: ruby_selected.stdout == '' or ruby_version not in ruby_selected.stdout \ No newline at end of file +- name: detect if rvm is system installed + stat: path=/etc/profile.d/rvm.sh + register: rvm_system_install + +- name: ensure default ruby is selected (home install) + command: "{{ ruby_rvm_install_path }}/bin/rvm --default use ruby-{{ ruby_version }}" + when: not rvm_system_install.stat.exists and (ruby_selected.stdout == '' or ruby_version not in ruby_selected.stdout) + +- name: ensure default ruby is selected (system install) + shell: source /etc/profile.d/rvm.sh && rvm --default use ruby-{{ ruby_version }} executable=/bin/bash + when: rvm_system_install.stat.exists and (ruby_selected.stdout == '' or ruby_version not in ruby_selected.stdout)