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.
|
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.
|
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.
|
# Install 1 or more versions of ruby, just add them to the list.
|
||||||
# The last version listed will be set as the default ruby.
|
# The last version listed will be set as the default ruby.
|
||||||
# Change it to `ruby_rubies:` if you want no rubies installed.
|
# Change it to `ruby_rubies:` if you want no rubies installed.
|
||||||
ruby_rubies:
|
rvm1_rubies:
|
||||||
- 'ruby-2.1.2'
|
- 'ruby-2.1.2'
|
||||||
|
|
||||||
# Where should the rvm-installer and other temp files be downloaded to?
|
# 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?
|
# 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?
|
# Which url or local path contains the rvm-installer script?
|
||||||
# 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'
|
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?
|
# 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.
|
||||||
@@ -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
|
# 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.
|
# 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.
|
# 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
|
## 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
|
- The default ruby version that is selected
|
||||||
|
|
||||||
- `ruby_rvm`
|
- `rvm1`
|
||||||
- The path to the rvm binary
|
- The path to the rvm binary
|
||||||
|
|
||||||
- `ruby_rvm_default_wrappers`:
|
- `rvm1_default_wrappers`:
|
||||||
- The path containing all of the wrapped ruby related binaries
|
- The path containing all of the wrapped ruby related binaries
|
||||||
|
|
||||||
- `ruby`
|
- `rvm1_ruby`
|
||||||
- The path to the ruby binary
|
- The path to the ruby binary
|
||||||
|
|
||||||
- `ruby_gem`
|
- `rvm1_gem`
|
||||||
- The path to the gem binary
|
- The path to the gem binary
|
||||||
|
|
||||||
- `ruby_bundle`
|
- `rvm1_bundle`
|
||||||
- The path to the bundle binary
|
- The path to the bundle binary
|
||||||
|
|
||||||
- `ruby_rake`
|
- `rvm1_rake`
|
||||||
- The path to the rake binary with bundle exec already applied
|
- The path to the rake binary with bundle exec already applied
|
||||||
|
|
||||||
### Example
|
### 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
|
## 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
|
rvm1_rubies:
|
||||||
ruby_rvm_stable_version_number: 1.25.26
|
- 'ruby-2.1.0'
|
||||||
|
- 'ruby-2.1.2'
|
||||||
|
rvm1_rvm_stable_version_number: 1.25.26
|
||||||
```
|
```
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
`$ ansible-galaxy install nickjj.ruby`
|
`$ ansible-galaxy install rvm_io.rvm1-ruby`
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
---
|
---
|
||||||
ruby_rubies:
|
rvm1_user: '{{ ansible_ssh_user }}'
|
||||||
|
rvm1_group: 'rvm'
|
||||||
|
|
||||||
|
rvm1_rubies:
|
||||||
- 'ruby-2.1.2'
|
- 'ruby-2.1.2'
|
||||||
|
|
||||||
ruby_rvm_temp_download_path: '/usr/local/src'
|
rvm1_temp_download_path: '/usr/local/src'
|
||||||
ruby_rvm_install_path: '/usr/local/rvm'
|
rvm1_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'
|
|
||||||
|
|
||||||
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
|
- name: detect if rubies are installed
|
||||||
command: '{{ ruby_rvm }} {{ item }} do true'
|
command: '{{ rvm1 }} {{ item }} do true'
|
||||||
changed_when: false
|
changed_when: false
|
||||||
failed_when: false
|
failed_when: false
|
||||||
register: detect_rubies
|
register: detect_rubies
|
||||||
with_items: ruby_rubies
|
with_items: rvm1_rubies
|
||||||
when: ruby_rubies
|
when: rvm1_rubies
|
||||||
|
|
||||||
- name: ensure rubies are installed
|
- name: ensure rubies are installed
|
||||||
command: '{{ ruby_rvm }} install {{ item.item }}'
|
command: '{{ rvm1 }} install {{ item.item }}'
|
||||||
when: ruby_rubies and item.rc != 0
|
when: rvm1_rubies and item.rc != 0
|
||||||
with_items: detect_rubies.results
|
with_items: detect_rubies.results
|
||||||
|
|
||||||
- name: detect default ruby version
|
- name: detect default ruby version
|
||||||
command: '{{ ruby_rvm }} alias list default'
|
command: '{{ rvm1 }} alias list default'
|
||||||
changed_when: false
|
changed_when: false
|
||||||
register: detect_default_ruby_version
|
register: detect_default_ruby_version
|
||||||
|
|
||||||
- name: ensure default ruby is selected
|
- name: ensure default ruby is selected
|
||||||
command: '{{ ruby_rvm }} alias create default {{ ruby_default_ruby_version }}'
|
command: '{{ rvm1 }} alias create default {{ rvm1_default_ruby_version }}'
|
||||||
when: detect_default_ruby_version.stdout == '' or ruby_default_ruby_version not in detect_default_ruby_version.stdout
|
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
|
- name: detect rvm binary
|
||||||
stat: path='{{ ruby_rvm }}'
|
stat: path='{{ rvm1 }}'
|
||||||
register: rvm_binary
|
register: rvm_binary
|
||||||
|
|
||||||
- name: detect rvm installer
|
- 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
|
register: rvm_installer
|
||||||
|
|
||||||
- name: detect current rvm version
|
- name: detect current rvm version
|
||||||
command: '{{ ruby_rvm }} version'
|
command: '{{ rvm1 }} version'
|
||||||
changed_when: false
|
changed_when: false
|
||||||
register: rvm_current_version
|
register: rvm_current_version
|
||||||
when: rvm_binary.stat.exists
|
when: rvm_binary.stat.exists
|
||||||
|
|
||||||
- name: detect stable rvm version from url
|
- 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
|
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
|
- name: ensure rvm installer is copied from url
|
||||||
get_url:
|
get_url:
|
||||||
url: '{{ ruby_rvm_latest_installer }}'
|
url: '{{ rvm1_rvm_latest_installer }}'
|
||||||
dest: '{{ ruby_rvm_temp_download_path }}/rvm-installer.sh'
|
dest: '{{ rvm1_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 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
|
- name: ensure rvm installer is copied from local file
|
||||||
copy: src='{{ ruby_rvm_latest_installer }}' dest='{{ ruby_rvm_temp_download_path }}/rvm-installer.sh'
|
copy: src='{{ rvm1_rvm_latest_installer }}' dest='{{ rvm1_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 rvm1_rvm_latest_installer and not rvm_installer.stat.exists or rvm1_rvm_force_upgrade_installer
|
||||||
|
|
||||||
- name: ensure rvm installer is configured
|
- name: ensure rvm installer is configured
|
||||||
file:
|
file:
|
||||||
path: "{{ ruby_rvm_temp_download_path }}/rvm-installer.sh"
|
path: "{{ rvm1_temp_download_path }}/rvm-installer.sh"
|
||||||
mode: 0755
|
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
|
- 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
|
when: not rvm_binary.stat.exists
|
||||||
|
|
||||||
- name: ensure rvm is upgraded
|
- name: ensure rvm is upgraded
|
||||||
shell: '{{ ruby_rvm }} get stable && {{ ruby_rvm }} reload'
|
shell: '{{ rvm1 }} get stable && {{ rvm1 }} 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]
|
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
|
- name: ensure rvm installs ruby dependencies
|
||||||
command: '{{ ruby_rvm }} autolibs 3'
|
command: '{{ rvm1 }} autolibs 3'
|
||||||
when: not rvm_binary.stat.exists
|
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 "" }}'
|
rvm1_default_ruby_version: '{{ rvm1_rubies | last if rvm1_rubies and rvm1_rubies is iterable else "" }}'
|
||||||
ruby_rvm: '{{ ruby_rvm_install_path }}/bin/rvm'
|
rvm1: '{{ rvm1_install_path }}/bin/rvm'
|
||||||
ruby_rvm_default_wrappers: '{{ ruby_rvm_install_path }}/wrappers/default'
|
rvm1_default_wrappers: '{{ rvm1_install_path }}/wrappers/default'
|
||||||
ruby: '{{ ruby_rvm_default_wrappers }}/ruby'
|
rvm1_ruby: '{{ rvm1_default_wrappers }}/ruby'
|
||||||
ruby_gem: '{{ ruby_rvm_default_wrappers }}/gem'
|
rvm1_gem: '{{ rvm1_default_wrappers }}/gem'
|
||||||
ruby_bundle: '{{ ruby_rvm_default_wrappers }}/bundle'
|
rvm1_bundle: '{{ rvm1_default_wrappers }}/bundle'
|
||||||
ruby_rake: '{{ ruby_bundle }} exec {{ ruby_rvm_default_wrappers }}/rake'
|
rvm1_rake: '{{ rvm1_bundle }} exec {{ rvm1_default_wrappers }}/rake'
|
||||||
Reference in New Issue
Block a user