71 lines
3.0 KiB
YAML
71 lines
3.0 KiB
YAML
---
|
|
- name: detect rvm binary
|
|
stat: path={{ ruby_rvm_install_path }}/bin/rvm
|
|
register: rvm_binary
|
|
|
|
- name: detect rvm installer
|
|
stat: path={{ ruby_temp_download_path }}/rvm-installer.sh
|
|
register: rvm_installer
|
|
|
|
- name: detect current rvm version
|
|
shell: "{{ ruby_rvm_install_path }}/bin/rvm version"
|
|
register: rvm_current_version
|
|
when: rvm_binary.stat.exists
|
|
|
|
- name: detect stable rvm version from url
|
|
uri: url={{ ruby_rvm_stable_version_number }} return_content=yes
|
|
register: rvm_stable_version_number
|
|
when: "'://' in ruby_rvm_stable_version_number"
|
|
|
|
- name: ensure rvm installer is copied from url
|
|
get_url:
|
|
url: "{{ ruby_rvm_latest_installer }}"
|
|
dest: "{{ ruby_temp_download_path }}/rvm-installer.sh"
|
|
when: "'://' in ruby_rvm_latest_installer and not rvm_installer.stat.exists or ruby_rvm_force_upgrade_installer"
|
|
|
|
- name: ensure rvm installer is copied from local file
|
|
copy: src="{{ ruby_rvm_latest_installer }}" dest="{{ ruby_temp_download_path }}/rvm-installer.sh"
|
|
when: not "://" in ruby_rvm_latest_installer and not rvm_installer.stat.exists or ruby_rvm_force_upgrade_installer
|
|
|
|
- name: ensure rvm installer is configured
|
|
file:
|
|
path: "{{ ruby_temp_download_path }}/rvm-installer.sh"
|
|
mode: 0755
|
|
when: not rvm_binary.stat.exists or ruby_rvm_force_upgrade_installer
|
|
|
|
- name: ensure rvm stable is installed
|
|
command: "{{ ruby_temp_download_path }}/rvm-installer.sh --path {{ ruby_rvm_install_path }} stable"
|
|
when: not rvm_binary.stat.exists
|
|
|
|
- name: ensure rvm is upgraded
|
|
shell: "{{ ruby_rvm_install_path }}/bin/rvm get stable && {{ ruby_rvm_install_path }}/bin/rvm reload"
|
|
when: rvm_binary.stat.exists and rvm_stable_version_number.content|default(ruby_rvm_stable_version_number)|replace("\n", "") > rvm_current_version.stdout.split()[1]
|
|
|
|
- name: ensure rvm installs ruby dependencies
|
|
command: "{{ ruby_rvm_install_path }}/bin/rvm autolibs 3"
|
|
when: not rvm_binary.stat.exists
|
|
|
|
- name: detect if ruby version is installed
|
|
stat: path={{ ruby_rvm_install_path }}/rubies/ruby-{{ ruby_version }}
|
|
register: installed_ruby_version
|
|
|
|
- name: ensure ruby is installed
|
|
command: "{{ ruby_rvm_install_path }}/bin/rvm install ruby-{{ ruby_version }}"
|
|
when: not installed_ruby_version.stat.exists
|
|
|
|
- name: detect default ruby version
|
|
command: "{{ ruby_rvm_install_path }}/bin/rvm alias list default"
|
|
register: ruby_selected
|
|
|
|
- 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)
|