Install the rvm.ruby Ansible role
masterInstall the rvm.ruby role using ansible-galaxy to begin managing Ruby versions with RVM via Ansible.
$ ansible-galaxy install rvm.rubyrepository·master·Indexed 43 days ago
https://github.com/rvm/rvm1-ansibleAn Ansible role (rvm.ruby) designed to install and manage multiple Ruby versions using RVM (Ruby Version Manager). It supports single-user and system-wide installations and provides pre-compiled binaries to accelerate deployment.
Install the rvm.ruby role using ansible-galaxy to begin managing Ruby versions with RVM via Ansible.
$ ansible-galaxy install rvm.rubyTo remove a specific Ruby version, use the rvm1_delete_ruby variable. You can pass this via Ansible's --extra-vars flag during playbook execution.
ansible-playbook playbook.yml --extra-vars 'rvm1_delete_ruby=ruby-2.1.0'The following variables are available to configure the behavior of the rvm.ruby role. Note that specific configurations are required depending on whether you are performing a single-user or a system-wide (root-based) installation.
# Install 1 or more versions of ruby
# The last ruby listed will be set as the default ruby
rvm1_rubies:
- 'ruby-2.3.1'
# Install the bundler gem
rvm1_bundler_install: True
# Delete a specific version of ruby (ie. ruby-2.1.0)
rvm1_delete_ruby:
# Install path for rvm (defaults to single user)
# NOTE: If you are doing a ROOT BASED INSTALL then make sure you
# set the install path to something like '/usr/local/rvm'
rvm1_install_path: '~/.rvm'
# Add or remove any install flags
# NOTE: If you are doing a ROOT BASED INSTALL then make sure you
# REMOVE the --user-install flag below
rvm1_install_flags: '--auto-dotfiles --user-install'
# Add additional ruby install flags
rvm1_ruby_install_flags:
# Set the owner for the rvm directory
# NOTE: If you are doing a ROOT BASED INSTALL then make sure you
# set rvm1_user to 'root'
rvm1_user: 'ubuntu'
# URL for the latest 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, disabling this will force rvm to never update
rvm1_rvm_check_for_updates: True
# GPG key verification, use an empty string if you want to skip this
rvm1_gpg_keys: '409B6B1796C275462A1703113804BB82D39DC0E3'
# The GPG key server
rvm1_gpg_key_server: 'hkp://keys.openpgp.org'
# autolib mode, see https://rvm.io/rvm/autolibs
rvm1_autolib_mode: 3
# Symlink binaries to system path
rvm1_symlink: trueTo install Ruby for a single user (the default behavior), use the following playbook structure. This uses the default --user-install flag and installs to the user's home directory.
---
- name: Configure servers with ruby support for single user
hosts: all
roles:
- { role: rvm.ruby,
tags: ruby,
rvm1_rubies: ['ruby-2.3.1'],
rvm1_user: 'ubuntu'
}To install Ruby to a user other than the ansible_user, you must use become (root access) because you are writing to a directory outside the current user's home. Set rvm1_install_path to the target user's RVM directory and keep the --user-install flag.
rvm1_install_flags: '--auto-dotfiles --user-install'
rvm1_install_path: '/home/someuser/.rvm'To perform a system-wide installation, you must run the playbook with become: yes (root privileges). You must also modify rvm1_install_flags to remove --user-install and specify a system-level rvm1_install_path (e.g., /usr/local/rvm).
---
- name: Configure servers with ruby support system wide
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 account to access system location
}