Support installing multiple rubies in 1 run and refactor a bit
This commit is contained in:
@@ -1,64 +1,3 @@
|
||||
---
|
||||
- name: detect rvm binary
|
||||
stat: path='{{ ruby_rvm }}'
|
||||
register: rvm_binary
|
||||
|
||||
- name: detect rvm installer
|
||||
stat: path='{{ ruby_rvm_temp_download_path }}/rvm-installer.sh'
|
||||
register: rvm_installer
|
||||
|
||||
- name: detect current rvm version
|
||||
command: '{{ ruby_rvm }} version'
|
||||
changed_when: false
|
||||
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_rvm_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_rvm_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_rvm_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_rvm_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 }} get stable && {{ ruby_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 }} 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 ruby-{{ ruby_version }}'
|
||||
when: not installed_ruby_version.stat.exists
|
||||
|
||||
- name: detect default ruby version
|
||||
command: '{{ ruby_rvm }} alias list default'
|
||||
changed_when: false
|
||||
register: ruby_selected
|
||||
|
||||
- name: ensure default ruby is selected
|
||||
command: '{{ ruby_rvm }} alias create default ruby-{{ ruby_version }}'
|
||||
when: ruby_selected.stdout == '' or ruby_version not in ruby_selected.stdout
|
||||
- include: 'rvm.yml'
|
||||
- include: 'rubies.yml'
|
||||
22
tasks/rubies.yml
Normal file
22
tasks/rubies.yml
Normal file
@@ -0,0 +1,22 @@
|
||||
---
|
||||
- name: detect if rubies are installed
|
||||
command: '{{ ruby_rvm }} {{ item }} do true'
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
register: detect_rubies
|
||||
with_items: ruby_rubies
|
||||
when: ruby_rubies
|
||||
|
||||
- name: ensure rubies are installed
|
||||
command: '{{ ruby_rvm }} install {{ item.item }}'
|
||||
when: ruby_rubies and item.rc != 0
|
||||
with_items: detect_rubies.results
|
||||
|
||||
- name: detect default ruby version
|
||||
command: '{{ ruby_rvm }} alias list default'
|
||||
changed_when: false
|
||||
register: detect_default_ruby_version
|
||||
|
||||
- name: ensure default ruby is selected
|
||||
command: '{{ ruby_rvm }} alias create default {{ ruby_default_ruby_version }}'
|
||||
when: detect_default_ruby_version.stdout == '' or ruby_default_ruby_version not in detect_default_ruby_version.stdout
|
||||
47
tasks/rvm.yml
Normal file
47
tasks/rvm.yml
Normal file
@@ -0,0 +1,47 @@
|
||||
---
|
||||
- name: detect rvm binary
|
||||
stat: path='{{ ruby_rvm }}'
|
||||
register: rvm_binary
|
||||
|
||||
- name: detect rvm installer
|
||||
stat: path='{{ ruby_rvm_temp_download_path }}/rvm-installer.sh'
|
||||
register: rvm_installer
|
||||
|
||||
- name: detect current rvm version
|
||||
command: '{{ ruby_rvm }} version'
|
||||
changed_when: false
|
||||
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_rvm_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_rvm_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_rvm_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_rvm_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 }} get stable && {{ ruby_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 }} autolibs 3'
|
||||
when: not rvm_binary.stat.exists
|
||||
Reference in New Issue
Block a user