silverlogic.rvm

rvm1-ansible

Build Status OpenCollective OpenCollective Ansible Role

What is rvm1-ansible?

It is an Ansible role that helps you install and manage different versions of Ruby using RVM (Ruby Version Manager).

Why use RVM?

When you're in production, installing a new Ruby version can take over 10 minutes, using up all your CPU. RVM offers pre-compiled Ruby versions for many operating systems, allowing you to install Ruby in about 1 minute, even on lower-end servers.

This role also adds Ruby binaries to your system path for easier access, allowing you to use Ruby without a version manager while still enjoying the benefits of RVM.

Installation

To install, run:

$ ansible-galaxy install rvm.ruby

Role Variables

You can configure the following default values:

---

# Install one or more versions of Ruby
# The last listed Ruby will be set as the default
rvm1_rubies:
  - 'ruby-2.3.1'

# Install the Bundler gem
rvm1_bundler_install: True

# Bundler version - leave blank for the latest version
rvm1_bundler_version: ''
rvm1_bundler_install_command: '{{ rvm1_bundler_version | ternary("gem install -v {{ rvm1_bundler_version }} bundler", "gem install bundler") }}'

# Delete a specific Ruby version (e.g., ruby-2.1.0)
rvm1_delete_ruby:

# Installation path for RVM (defaults to single user)
rvm1_install_path: '~/.rvm'

# Installation flags
rvm1_install_flags: '--auto-dotfiles --user-install'

# Additional Ruby installation flags
rvm1_ruby_install_flags:

# Set owner for the RVM directory; use 'root' for root installations
rvm1_user: 'ubuntu'

# URL for the latest RVM installer script
rvm1_rvm_latest_installer: 'https://raw.githubusercontent.com/rvm/rvm/master/binscripts/rvm-installer'

# RVM version to use
rvm1_rvm_version: 'stable'

# Check and update RVM; false disables updates
rvm1_rvm_check_for_updates: True

# GPG key for verification
rvm1_gpg_keys: '409B6B1796C275462A1703113804BB82D39DC0E3'

# GPG key server
rvm1_gpg_key_server: 'hkp://pool.sks-keyservers.net'

# Autolib mode settings, see https://rvm.io/rvm/autolibs
rvm1_autolib_mode: 3

Example Playbooks

Single User Configuration

---

- name: Configure servers with Ruby support for a single user
  hosts: all

  roles:
    - { role: rvm.ruby,
        tags: ruby,
        rvm1_rubies: ['ruby-2.3.1'],
        rvm1_user: 'ubuntu'
      }

System-Wide Configuration

To pass multiple Ruby versions:

---
- name: Configure servers with system-wide Ruby support
  hosts: all
  roles:
    - { role: rvm.ruby,
        tags: ruby,
        become: yes,
        rvm1_rubies: ['ruby-2.2.5', 'ruby-2.3.1'],
        rvm1_install_flags: '--auto-dotfiles',     # Remove --user-install from defaults
        rvm1_install_path: /usr/local/rvm,         # Set to system location
        rvm1_user: root                            # Need root access for system location
      }

Make sure to specify rvm_rubies in the format ruby-x.x.x, for example: rvm_rubies: ['ruby-2.2.5'].

System-Wide Installation Notes

Run as root to write to a system location defined by rvm1_install_path.

Installation for ansible_user

Just adjust the rvm_install_path:

rvm1_install_flags: '--auto-dotfiles --user-install'
rvm1_install_path: '/home/{{ ansible_user }}/.rvm'

Different User

You will need root access to install Ruby for a different user:

rvm1_install_flags: '--auto-dotfiles --user-install'
rvm1_install_path: '/home/someuser/.rvm'

Note on rvm1_user

Specify the user to own the RVM directory if necessary:

rvm1_user: 'foo'

Upgrading and Removing Ruby Versions

  1. Install the new version of Ruby.
  2. Use your application role to reinstall your gems.
  3. Delete the previous Ruby version.

Using --extra-vars

To remove a Ruby version, use:

--extra-vars 'rvm1_delete_ruby=ruby-2.1.0'

Requirements

  • Tested on CentOS 6 and 7
  • Tested on Debian 8 and 9
  • Tested on Ubuntu 14.04 and 16.04

Ansible Galaxy

You can find this role on the Ansible Galaxy.

Contributing

Backers

Support us with a small donation to help us continue our work. Become a backer.

Sponsors

Support us by becoming a sponsor and get your logo featured on our GitHub README.

License

MIT

Informazioni sul progetto

The official RVM role to install and manage your ruby versions

Installa
ansible-galaxy install silverlogic.rvm
Licenza
mit
Download
7.7k
Proprietario