Add in the ability to download or pass in the latest stable rvm version number

This commit is contained in:
Nick Janetakis
2014-06-03 08:25:34 -04:00
parent eb244bc702
commit 71e3e121de
2 changed files with 12 additions and 10 deletions

View File

@@ -26,16 +26,16 @@ ruby_rvm_install_path: /usr/local/rvm
# If you use a url, it must include http:// or https:// at the start. # If you use a url, it must include http:// or https:// at the start.
ruby_rvm_latest_installer: https://raw.githubusercontent.com/wayneeseguin/rvm/master/binscripts/rvm-installer ruby_rvm_latest_installer: https://raw.githubusercontent.com/wayneeseguin/rvm/master/binscripts/rvm-installer
# Which url or local path contains the stable version number of rvm? # Which url or value contains the stable version number of rvm?
# If you use a url, it must include http:// or https:// at the start. # If you use a url, it must include http:// or https:// at the start.
# If you use a value, it should be something like 1.25.27 or any legal version number.
# If you want to lock rvm to a specific version you could enter in the version number
# that you have installed and the role would assume you always have the latest stable version.
ruby_rvm_stable_version_number: https://raw.githubusercontent.com/wayneeseguin/rvm/master/VERSION ruby_rvm_stable_version_number: https://raw.githubusercontent.com/wayneeseguin/rvm/master/VERSION
# Force upgrade the rvm-installer to the latest installer. # Force upgrade the rvm-installer to the latest installer.
ruby_rvm_force_upgrade_installer: false ruby_rvm_force_upgrade_installer: false
# If you are concerned rvm stable might not be stable then
# you can set this to true so that rvm itself never upgrades.
ruby_rvm_skip_upgrade: false
``` ```
## Example playbook ## Example playbook
@@ -53,11 +53,12 @@ To use this role edit your `site.yml` file to look something like this:
- { role: nickjj.ruby, tags: ruby } - { role: nickjj.ruby, tags: ruby }
``` ```
Let's say you want to edit the default version, you can do this by opening or creating `group_vars/app.yml` which is located relative to your `inventory` directory and then making it look something like this: Let's say you want to edit a few values, you can do this by opening or creating `group_vars/app.yml` which is located relative to your `inventory` directory and then making it look something like this:
``` ```
--- ---
ruby_version: 2.0.0 ruby_version: 2.0.0
ruby_rvm_stable_version_number: 1.25.26
``` ```
## Installation ## Installation

View File

@@ -12,17 +12,18 @@
register: rvm_current_version register: rvm_current_version
when: rvm_profile.stat.exists when: rvm_profile.stat.exists
- name: detect stable rvm version - name: detect stable rvm version from url
uri: url={{ ruby_rvm_stable_version_number }} return_content=yes uri: url={{ ruby_rvm_stable_version_number }} return_content=yes
register: rvm_stable_version_number register: rvm_stable_version_number
when: "'://' in ruby_rvm_stable_version_number"
- name: ensure rvm installer is downloaded - name: ensure rvm installer is copied from url
get_url: get_url:
url: "{{ ruby_rvm_latest_installer }}" url: "{{ ruby_rvm_latest_installer }}"
dest: "{{ ruby_temp_download_path }}/rvm-installer.sh" 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" when: "'://' in ruby_rvm_latest_installer and not rvm_installer.stat.exists or ruby_rvm_force_upgrade_installer"
- name: ensure rvm installer is copied - name: ensure rvm installer is copied from local file
copy: src="{{ ruby_rvm_latest_installer }}" dest="{{ ruby_temp_download_path }}/rvm-installer.sh" 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 when: not "://" in ruby_rvm_latest_installer and not rvm_installer.stat.exists or ruby_rvm_force_upgrade_installer
@@ -38,7 +39,7 @@
- name: ensure rvm is upgraded - name: ensure rvm is upgraded
shell: "{{ ruby_rvm_install_path }}/bin/rvm get stable && {{ ruby_rvm_install_path }}/bin/rvm reload" shell: "{{ ruby_rvm_install_path }}/bin/rvm get stable && {{ ruby_rvm_install_path }}/bin/rvm reload"
when: not rvm_stable_version_number.content[:-1] in rvm_current_version.stdout and rvm_profile.stat.exists and not ruby_rvm_skip_upgrade when: rvm_stable_version_number.content|default(ruby_rvm_stable_version_number)|replace("\n", "") > rvm_current_version.stdout.split()[1] and rvm_profile.stat.exists
- name: ensure rvm installs ruby dependencies - name: ensure rvm installs ruby dependencies
command: "{{ ruby_rvm_install_path }}/bin/rvm autolibs 3" command: "{{ ruby_rvm_install_path }}/bin/rvm autolibs 3"