--- - name: Detect if rubies are installed command: '{{ rvm1_rvm }} {{ item }} do true' changed_when: False failed_when: False register: detect_rubies with_items: '{{ rvm1_rubies }}' when: rvm1_rubies - name: Install rubies command: '{{ rvm1_rvm }} install {{ item.item }} {{ rvm1_ruby_install_flags }}' when: rvm1_rubies and item.rc|default(0) != 0 with_items: '{{ detect_rubies.results }}' become: yes become_user: '{{ rvm1_user }}' - name: Detect default ruby version command: '{{ rvm1_rvm }} alias list default' changed_when: False register: detect_default_ruby_version become: yes become_user: '{{ rvm1_user }}' - name: Select default ruby command: '{{ rvm1_rvm }} alias create default {{ rvm1_default_ruby_version }}' when: detect_default_ruby_version.stdout|default() == '' or rvm1_default_ruby_version not in detect_default_ruby_version.stdout become: yes become_user: '{{ rvm1_user }}' - name: Detect installed ruby patch number shell: > {{ rvm1_rvm }} list strings | grep {{ item }} | tail -n 1 with_items: '{{ rvm1_rubies }}' changed_when: False register: ruby_patch always_run: yes # Run even when in --check mode (http://docs.ansible.com/ansible/playbooks_checkmode.html) become: yes become_user: '{{ rvm1_user }}' - name: Install bundler if not installed shell: > ls {{ rvm1_install_path }}/wrappers/{{ item.stdout }} | if ! grep "^bundler " ; then {{ rvm1_install_path }}/wrappers/{{ item.stdout }}/gem install bundler ; fi args: creates: '{{ rvm1_install_path }}/wrappers/{{ item.stdout }}/bundler' with_items: '{{ ruby_patch.results }}' register: bundler_install changed_when: '"Successfully installed bundler" in bundler_install.stdout' become: yes become_user: '{{ rvm1_user }}' - name: Symlink ruby related binaries on the system path file: 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_rvm }} {{ rvm1_delete_ruby }} do true' changed_when: False failed_when: False register: detect_delete_ruby when: rvm1_delete_ruby become: yes become_user: '{{ rvm1_user }}' - name: Delete ruby version command: '{{ rvm1_rvm }} remove {{ rvm1_delete_ruby }}' changed_when: False when: rvm1_delete_ruby and detect_delete_ruby.rc == 0 become: yes become_user: '{{ rvm1_user }}'