Change the variables to the new role name and set the owner:group
This commit is contained in:
46
README.md
46
README.md
@@ -1,4 +1,4 @@
|
||||
## What is ansible-ruby? [](http://travis-ci.org/nickjj/ansible-ruby)
|
||||
## What is rvm1-ansible? [](http://travis-ci.org/nickjj/ansible-ruby)
|
||||
|
||||
It is an [ansible](http://www.ansible.com/home) role to install and manage ruby versions using rvm.
|
||||
|
||||
@@ -13,21 +13,27 @@ ansible-ruby solves this by using rvm to install 1 or more versions of ruby. It
|
||||
Below is a list of default values along with a description of what they do.
|
||||
|
||||
```
|
||||
# Which user should own all of rvm's files?
|
||||
rvm1_user: '{{ ansible_ssh_user }}'
|
||||
|
||||
# Which group should rvm be installed to?
|
||||
rvm1_group: 'rvm'
|
||||
|
||||
# Install 1 or more versions of ruby, just add them to the list.
|
||||
# The last version listed will be set as the default ruby.
|
||||
# Change it to `ruby_rubies:` if you want no rubies installed.
|
||||
ruby_rubies:
|
||||
rvm1_rubies:
|
||||
- 'ruby-2.1.2'
|
||||
|
||||
# Where should the rvm-installer and other temp files be downloaded to?
|
||||
ruby_rvm_temp_download_path: '/usr/local/src'
|
||||
rvm1_temp_download_path: '/usr/local/src'
|
||||
|
||||
# Where should rvm be installed to?
|
||||
ruby_rvm_install_path: '/usr/local/rvm'
|
||||
rvm1_install_path: '/usr/local/rvm'
|
||||
|
||||
# Which url or local path contains the rvm-installer script?
|
||||
# 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'
|
||||
rvm1_rvm_latest_installer: 'https://raw.githubusercontent.com/wayneeseguin/rvm/master/binscripts/rvm-installer'
|
||||
|
||||
# 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.
|
||||
@@ -35,40 +41,40 @@ ruby_rvm_latest_installer: 'https://raw.githubusercontent.com/wayneeseguin/rvm/m
|
||||
|
||||
# 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'
|
||||
rvm1_rvm_stable_version_number: 'https://raw.githubusercontent.com/wayneeseguin/rvm/master/VERSION'
|
||||
|
||||
# Force upgrade the rvm-installer to the latest version.
|
||||
ruby_rvm_force_upgrade_installer: false
|
||||
rvm1_rvm_force_upgrade_installer: false
|
||||
```
|
||||
|
||||
## Exposed variables for use in other roles
|
||||
|
||||
You will likely want to use various ruby related commands in other roles. This role exposes a number of popular paths for easy access.
|
||||
You will likely want to use various ruby related commands in other roles. This role exposes a number of popular paths and variables for easy access.
|
||||
|
||||
- `ruby_default_ruby_version`
|
||||
- `rvm1_default_ruby_version`
|
||||
- The default ruby version that is selected
|
||||
|
||||
- `ruby_rvm`
|
||||
- `rvm1`
|
||||
- The path to the rvm binary
|
||||
|
||||
- `ruby_rvm_default_wrappers`:
|
||||
- `rvm1_default_wrappers`:
|
||||
- The path containing all of the wrapped ruby related binaries
|
||||
|
||||
- `ruby`
|
||||
- `rvm1_ruby`
|
||||
- The path to the ruby binary
|
||||
|
||||
- `ruby_gem`
|
||||
- `rvm1_gem`
|
||||
- The path to the gem binary
|
||||
|
||||
- `ruby_bundle`
|
||||
- `rvm1_bundle`
|
||||
- The path to the bundle binary
|
||||
|
||||
- `ruby_rake`
|
||||
- `rvm1_rake`
|
||||
- The path to the rake binary with bundle exec already applied
|
||||
|
||||
### Example
|
||||
|
||||
If you wanted to run a database migration in rails you would use `{{ ruby_rake }} db:migrate`.
|
||||
If you wanted to run a database migration in rails you would use `{{ rvm1_rake }} db:migrate`.
|
||||
|
||||
## Example playbook
|
||||
|
||||
@@ -89,13 +95,15 @@ Let's say you want to edit a few values, you can do this by opening or creating
|
||||
|
||||
```
|
||||
---
|
||||
ruby_version: 2.0.0
|
||||
ruby_rvm_stable_version_number: 1.25.26
|
||||
rvm1_rubies:
|
||||
- 'ruby-2.1.0'
|
||||
- 'ruby-2.1.2'
|
||||
rvm1_rvm_stable_version_number: 1.25.26
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
`$ ansible-galaxy install nickjj.ruby`
|
||||
`$ ansible-galaxy install rvm_io.rvm1-ruby`
|
||||
|
||||
## Requirements
|
||||
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
---
|
||||
ruby_rubies:
|
||||
rvm1_user: '{{ ansible_ssh_user }}'
|
||||
rvm1_group: 'rvm'
|
||||
|
||||
rvm1_rubies:
|
||||
- 'ruby-2.1.2'
|
||||
|
||||
ruby_rvm_temp_download_path: '/usr/local/src'
|
||||
ruby_rvm_install_path: '/usr/local/rvm'
|
||||
ruby_rvm_latest_installer: 'https://raw.githubusercontent.com/wayneeseguin/rvm/master/binscripts/rvm-installer'
|
||||
ruby_rvm_stable_version_number: 'https://raw.githubusercontent.com/wayneeseguin/rvm/master/VERSION'
|
||||
rvm1_temp_download_path: '/usr/local/src'
|
||||
rvm1_install_path: '/usr/local/rvm'
|
||||
|
||||
ruby_rvm_force_upgrade_installer: false
|
||||
rvm1_rvm_latest_installer: 'https://raw.githubusercontent.com/wayneeseguin/rvm/master/binscripts/rvm-installer'
|
||||
rvm1_rvm_stable_version_number: 'https://raw.githubusercontent.com/wayneeseguin/rvm/master/VERSION'
|
||||
rvm1_rvm_force_upgrade_installer: false
|
||||
@@ -1,22 +1,25 @@
|
||||
---
|
||||
- name: detect if rubies are installed
|
||||
command: '{{ ruby_rvm }} {{ item }} do true'
|
||||
command: '{{ rvm1 }} {{ item }} do true'
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
register: detect_rubies
|
||||
with_items: ruby_rubies
|
||||
when: ruby_rubies
|
||||
with_items: rvm1_rubies
|
||||
when: rvm1_rubies
|
||||
|
||||
- name: ensure rubies are installed
|
||||
command: '{{ ruby_rvm }} install {{ item.item }}'
|
||||
when: ruby_rubies and item.rc != 0
|
||||
command: '{{ rvm1 }} install {{ item.item }}'
|
||||
when: rvm1_rubies and item.rc != 0
|
||||
with_items: detect_rubies.results
|
||||
|
||||
- name: detect default ruby version
|
||||
command: '{{ ruby_rvm }} alias list default'
|
||||
command: '{{ rvm1 }} 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
|
||||
command: '{{ rvm1 }} 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: ensure rvm install path is writable by the set owner:group
|
||||
file: path='{{ rvm1_install_path }}' state=directory recurse=yes owner='{{ rvm1_user }}' group='{{ rvm1_group }}'
|
||||
@@ -1,47 +1,47 @@
|
||||
---
|
||||
- name: detect rvm binary
|
||||
stat: path='{{ ruby_rvm }}'
|
||||
stat: path='{{ rvm1 }}'
|
||||
register: rvm_binary
|
||||
|
||||
- name: detect rvm installer
|
||||
stat: path='{{ ruby_rvm_temp_download_path }}/rvm-installer.sh'
|
||||
stat: path='{{ rvm1_temp_download_path }}/rvm-installer.sh'
|
||||
register: rvm_installer
|
||||
|
||||
- name: detect current rvm version
|
||||
command: '{{ ruby_rvm }} version'
|
||||
command: '{{ rvm1 }} 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
|
||||
uri: url='{{ rvm1_rvm_stable_version_number }}' return_content=yes
|
||||
register: rvm_stable_version_number
|
||||
when: '"://" in ruby_rvm_stable_version_number'
|
||||
when: '"://" in rvm1_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'
|
||||
url: '{{ rvm1_rvm_latest_installer }}'
|
||||
dest: '{{ rvm1_temp_download_path }}/rvm-installer.sh'
|
||||
when: '"://" in rvm1_rvm_latest_installer and not rvm_installer.stat.exists or rvm1_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
|
||||
copy: src='{{ rvm1_rvm_latest_installer }}' dest='{{ rvm1_temp_download_path }}/rvm-installer.sh'
|
||||
when: not '://' in rvm1_rvm_latest_installer and not rvm_installer.stat.exists or rvm1_rvm_force_upgrade_installer
|
||||
|
||||
- name: ensure rvm installer is configured
|
||||
file:
|
||||
path: "{{ ruby_rvm_temp_download_path }}/rvm-installer.sh"
|
||||
path: "{{ rvm1_temp_download_path }}/rvm-installer.sh"
|
||||
mode: 0755
|
||||
when: not rvm_binary.stat.exists or ruby_rvm_force_upgrade_installer
|
||||
when: not rvm_binary.stat.exists or rvm1_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'
|
||||
command: '{{ rvm1_temp_download_path }}/rvm-installer.sh --path {{ rvm1_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]
|
||||
shell: '{{ rvm1 }} get stable && {{ rvm1 }} 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: ensure rvm installs ruby dependencies
|
||||
command: '{{ ruby_rvm }} autolibs 3'
|
||||
command: '{{ rvm1 }} autolibs 3'
|
||||
when: not rvm_binary.stat.exists
|
||||
@@ -1,8 +1,8 @@
|
||||
---
|
||||
ruby_default_ruby_version: '{{ ruby_rubies | last if ruby_rubies and ruby_rubies is iterable else "" }}'
|
||||
ruby_rvm: '{{ ruby_rvm_install_path }}/bin/rvm'
|
||||
ruby_rvm_default_wrappers: '{{ ruby_rvm_install_path }}/wrappers/default'
|
||||
ruby: '{{ ruby_rvm_default_wrappers }}/ruby'
|
||||
ruby_gem: '{{ ruby_rvm_default_wrappers }}/gem'
|
||||
ruby_bundle: '{{ ruby_rvm_default_wrappers }}/bundle'
|
||||
ruby_rake: '{{ ruby_bundle }} exec {{ ruby_rvm_default_wrappers }}/rake'
|
||||
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 {{ rvm1_default_wrappers }}/rake'
|
||||
Reference in New Issue
Block a user