GSA/rvm1-ansible

Name: rvm1-ansible

Owner: U.S. General Services Administration

Description: The official ansible rvm role to install and manage your ruby versions.

Forked from: FuhuXia/rvm1-ansible

Created: 2017-06-01 19:58:28.0

Updated: 2016-11-17 12:26:35.0

Pushed: 2016-11-18 05:32:43.0

Homepage:

Size: 95

Language: null

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

What is rvm1-ansible? Build Status

It is an Ansible role to install and manage ruby versions using rvm.

Why should you use rvm?

In production it's useful because compiling a new version of ruby can easily take upwards of 10 minutes. That's 10 minutes of your CPU being pegged at 100%.

rvm has pre-compiled binaries for a lot of operating systems. That means you can install ruby in about 1 minute, even on a slow micro instance.

This role even adds the ruby binaries to your system path when doing a system wide install. This allows you to access them as if they were installed without using a version manager while still benefiting from what rvm has to offer.

Installation

$ ansible-galaxy install rvm_io.rvm1-ruby

Role variables

Below is a list of default values that you can configure:



stall 1 or more versions of ruby
e last ruby listed will be set as the default ruby
_rubies:
'ruby-2.1.3'

stall the bundler gem
_bundler_install: True

lete a specific version of ruby (ie. ruby-2.1.0)
_delete_ruby:

stall path for rvm (defaults to system wide)
_install_path: '/usr/local/rvm'

d or remove any install flags
TE: If you are doing a USER BASED INSTALL then
    make sure you ADD the --user-install flag below
_install_flags: '--auto-dotfiles'

d additional ruby install flags
_ruby_install_flags:

t the owner for the rvm directory
_user: 'root'

L for the latest installer script
_rvm_latest_installer: 'https://raw.githubusercontent.com/wayneeseguin/rvm/master/binscripts/rvm-installer'

m version to use
_rvm_version: 'stable'

eck and update rvm, disabling this will force rvm to never update
_rvm_check_for_updates: True

G key verification, use an empty string if you want to skip this
te: Unless you know what you're doing, just keep it as is
        Identity proof: https://keybase.io/mpapis
        PGP message: https://rvm.io/mpapis.asc
_gpg_keys: '409B6B1796C275462A1703113804BB82D39DC0E3'

e GPG key server
_gpg_key_server: 'hkp://keys.gnupg.net'

tolib mode, see https://rvm.io/rvm/autolibs
_autolib_mode: 3
Example playbooks


me: Configure servers with ruby support
sts: all

les:
- { role: rvm_io.rvm1-ruby, tags: ruby, become: yes }

If you need to pass a list of ruby versions, pass it in an array like so.


sts: all
les:
- { role: rvm_io.rvm1-ruby,
    tags: ruby,
    rvm1_rubies: ['ruby-2.2.2','ruby-2.2.5'],
  }

rvm_rubies must be specified via ruby-x.x.x so that if you want ruby 2.2.2, you will need to pass in an array rvm_rubies: ['ruby-2.2.2']

System wide installation

The above example would setup ruby system wide. It's very important that you run the play with sudo because it will need to write to /usr/local/rvm.

To the same user as ansible_ssh_user

In this case, just overwrite rvm_install_path and set the --user-install flag:

Note: you still need to use sudo because during the ruby installation phase rvm will internally make calls using sudo to install certain ruby dependencies.

_install_flags: '--auto-dotfiles --user-install'
_install_path: '/home/{{ ansible_ssh_user }}/.rvm'
To a user that is not ansible_ssh_user

You will need sudo here because you will be writing outside the ansible user's home directory. Other than that it's the same as above, except you will supply a different user account:

_install_flags: '--auto-dotfiles --user-install'
_install_path: '/home/someuser/.rvm'
A quick note about rvm1_user

In some cases you may want the rvm folder and its files to be owned by a specific user instead of root. Simply set rvm1_user: 'foo' and when ruby gets installed it will ensure that foo owns the rvm directory.

Upgrading and removing old versions of ruby

A common work flow for upgrading your ruby version would be:

  1. Install the new version
  2. Run your application role so that bundle install re-installs your gems
  3. Delete the previous version of ruby
Leverage ansible's --extra-vars

Just add --extra-vars 'rvm1_delete_ruby=ruby-2.1.0' to the end of your play book command and that version will be removed.

Requirements
Ansible galaxy

You can find it on the official ansible galaxy if you want to rate it.

License

MIT


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.