diff --git a/tasks/rubies.yml b/tasks/rubies.yml index 3477197..bdcfcbe 100644 --- a/tasks/rubies.yml +++ b/tasks/rubies.yml @@ -1,7 +1,7 @@ --- - name: Detect if rubies are installed - command: '{{ rvm1 }} {{ item }} do true' + command: '{{ rvm1_rvm }} {{ item }} do true' changed_when: False failed_when: False register: detect_rubies @@ -9,36 +9,38 @@ when: rvm1_rubies - name: Install rubies - command: '{{ rvm1 }} install {{ item.item }}' + command: '{{ rvm1_rvm }} install {{ item.item }}' when: rvm1_rubies and item.rc != 0 with_items: detect_rubies.results - name: Detect default ruby version - command: '{{ rvm1 }} alias list default' + command: '{{ rvm1_rvm }} alias list default' changed_when: False register: detect_default_ruby_version - name: Select default ruby - command: '{{ rvm1 }} alias create default {{ rvm1_default_ruby_version }}' + command: '{{ rvm1_rvm }} alias create default {{ rvm1_default_ruby_version }}' when: detect_default_ruby_version.stdout == '' or rvm1_default_ruby_version not in detect_default_ruby_version.stdout -- name: Set rvm install path permissions +- name: Symlink ruby related binaries on the system path file: - path: '{{ rvm1_install_path }}' - state: 'directory' - recurse: True - owner: '{{ rvm1_user }}' - group: '{{ rvm1_group }}' + state: 'link' + src: '{{ rvm1_install_path }}/wrappers/default/{{ item }}' + dest: '{{ rvm1_symlink_to }}/{{ item }}' + owner: 'root' + group: 'root' + when: not '--user-install' in rvm1_install_flags + with_items: rvm1_symlink_binaries - name: Detect if ruby version can be deleted - command: '{{ rvm1 }} {{ rvm1_delete_ruby }} do true' + command: '{{ rvm1_rvm }} {{ rvm1_delete_ruby }} do true' changed_when: False failed_when: False register: detect_delete_ruby when: rvm1_delete_ruby - name: Delete ruby version - command: '{{ rvm1 }} remove {{ rvm1_delete_ruby }}' + command: '{{ rvm1_rvm }} remove {{ rvm1_delete_ruby }}' changed_when: False when: rvm1_delete_ruby and detect_delete_ruby.rc == 0 diff --git a/tasks/rvm.yml b/tasks/rvm.yml index d0729de..8ee6c1f 100644 --- a/tasks/rvm.yml +++ b/tasks/rvm.yml @@ -1,7 +1,7 @@ --- - name: Detect rvm binary - stat: path='{{ rvm1 }}' + stat: path='{{ rvm1_rvm }}' register: rvm_binary - name: Detect rvm installer @@ -9,7 +9,7 @@ register: rvm_installer - name: Detect current rvm version - command: '{{ rvm1 }} version' + command: '{{ rvm1_install_path }} version' changed_when: False register: rvm_current_version when: rvm_binary.stat.exists @@ -35,16 +35,15 @@ - name: Install rvm stable command: > - {{ rvm1_temp_download_path }}/rvm-installer.sh - --path {{ rvm1_install_path }} - --auto-dotfiles stable + {{ rvm1_temp_download_path }}/rvm-installer.sh stable + --path {{ rvm1_install_path }} {{ rvm1_install_flags }} when: not rvm_binary.stat.exists - name: Update rvm - shell: '{{ rvm1 }} get stable && {{ rvm1 }} reload' + shell: '{{ rvm1_rvm }} get stable && {{ rvm1_rvm }} reload' when: rvm_binary.stat.exists and rvm_stable_version_number.content | default(rvm1_rvm_stable_version_number) | replace('\n', '') > rvm_current_version.stdout.split()[1] - name: Configure rvm - command: '{{ rvm1 }} autolibs 3' + command: '{{ rvm1_rvm }} autolibs 3' when: not rvm_binary.stat.exists diff --git a/vars/main.yml b/vars/main.yml index 892a5d4..05bf820 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,8 +1,22 @@ --- + +rvm1_temp_download_path: '/tmp' + rvm1_default_ruby_version: '{{ rvm1_rubies | last if rvm1_rubies and rvm1_rubies is iterable else "" }}' -rvm1: '{{ rvm1_install_path }}/bin/rvm' -rvm1_default_wrappers: '{{ rvm1_install_path }}/wrappers/default' -rvm1_ruby: '{{ rvm1_default_wrappers }}/ruby' -rvm1_gem: '{{ rvm1_default_wrappers }}/gem' -rvm1_bundle: '{{ rvm1_default_wrappers }}/bundle' -rvm1_rake: '{{ rvm1_bundle }} exec rake' \ No newline at end of file + +rvm1_rvm: '{{ rvm1_install_path }}/bin/rvm' + +rvm1_symlink_binaries: + - 'bundle' + - 'bundler' + - 'erb' + - 'executable-hooks-uninstaller' + - 'gem' + - 'irb' + - 'rake' + - 'rdoc' + - 'ri' + - 'ruby' + - 'testrb' + +rvm1_symlink_to: '/usr/local/bin'