Role for installing rbenv.
none
Default variables are:
rbenv_install: system
rbenv_version: v1.0.0
rbenv_force_update: false
rbenv_default_ruby: 2.4.2
rbenv_rubies:
- version: "{{ rbenv_default_ruby }}"
rbenv_clean_up: false
rbenv_repo: "https://github.com/rbenv/rbenv.git"
rbenv_plugins:
- ruby_build
rbenv_plugin_vars:
name: "rbenv-vars"
repo: "https://github.com/rbenv/rbenv-vars.git"
version: "master"
rbenv_plugin_ruby_build:
name: "ruby-build"
repo: "https://github.com/rbenv/ruby-build.git"
version: "master"
force_update: true
rbenv_plugin_default_gems:
name: "rbenv-default-gems"
repo: "https://github.com/rbenv/rbenv-default-gems.git"
version: "master"
rbenv_plugin_installer:
name: "rbenv-installer"
repo: "https://github.com/rbenv/rbenv-installer.git"
version: "master"
rbenv_plugin_update:
name: "rbenv-update"
repo: "https://github.com/rkh/rbenv-update.git"
version: "master"
rbenv_plugin_whatis:
name: "rbenv-whatis"
repo: "https://github.com/rkh/rbenv-whatis.git"
version: "master"
rbenv_plugin_use:
name: "rbenv-use"
repo: "https://github.com/rkh/rbenv-use.git"
version: "master"
rbenv_root: "{% if rbenv_install == 'system' %}/usr/local/rbenv\
{% else %}$HOME/.rbenv{% endif %}"
rbenv_users: []
rbenv_extra_depends: []
rbenv_set_secure_path: yes
Variables to control a system installation (these are not set by default):
rbenv_owner: 'deploy'
rbenv_group: 'deploy'
Description:
rbenv_install
- Type of rbenv installation,system
oruser
. Default issystem
.rbenv_version
- Version of rbenv to install (tag from rbenv releases page or other valid git object ref)rbenv_default_ruby
- Which ruby version to be set as global rbenv ruby.rbenv_rubies
- Versions of ruby to install, see Configuring rubies below.rbenv_force_update
- Whether existing git checkout should be updatedrbenv_clean_up
- Delete all ruby versions not listed above. Default value isfalse
rbenv_repo
- Repository with source code of rbenv to installrbenv_plugins
- List of plugins to install. See configuring plugins below for details.rbenv_plugin_{{ name }}
- Specification of a plugin. See configuring pluginsrbenv_root
- Install pathrbenv_users
- Array of usernames for multiuser install. User must be present in the systemrbenv_extra_depends
- Array of extra system packages to install before compiling rubiesrbenv_default_gems
- Name of default-gems file for rbenv-default-gems plugin (used only whendefault_gems
is enabled in plugins)rbenv_owner
- The user owningrbenv_root
whenrbenv_install
issystem
rbenv_group
- The group owningrbenv_root
whenrbenv_install
issystem
rbenv_tmpdir
- A temporary directory path used for artifacts when installing rubies. Defaults to system's$TMPDIR
rbenv_set_vars
- Set default varsGEM_PATH=$GEM_PATH:$HOME/.gems
for 'user' env. Default value istrue
rbenv_set_secure_path
- whether rbenv'sbin/
directory should be added to secure_path option of sudoers file on system-wide install.
The smallest configuration possible to bring the ruby onto the target machine is to specify the default ruby version:
- hosts: ruby_hosts
roles: timon.rbenv
vars: { rbenv_default_ruby: 2.4.2 }
This will perform system-wide installation of rbenv
(plus ruby_build
plugin), build ruby 2.4.2 and configures 2.4.2 to be the default ruby on the
host.
To install several ruby versions, you'll need to list them in rbenv_rubies
variable. This variable is expected to be a list of hashes that should have
at least version
attribute. The default is to just include
rbenv_default_ruby
version:
rbenv_rubies:
- version: '{{ rbenv_default_ruby }}'
Besides version, you could useenv
attribute to specify additional
variables
for custom build configuration.
rbenv_rubies:
- version: 2.4.2
env: { RUBY_CONFIGURE_OPTS: "--enable-shared" }
If certain ruby version requires a patch to be built, use patch
attribute to
provide URLs to patch(es) to apply. Contents of the URLs listed would be
piped by curl
to rbenv install --patch
command.
The list of plugins that should be installed in addition to base rbenv
distirbution is specified in rbenv_plugins
variable. The definition for each
plugin listed in rbenv_plugins
is loaded from rbenv_plugin_{{plugin_name}}
during role execution.
The default setting is to install ruby_build plugin only. This is what default plugin configuration looks like:
rbenv_plugins:
- ruby_build
rbenv_plugin_ruby_build:
name: "ruby-build"
repo: "https://github.com/rbenv/ruby-build.git"
version: "master"
force_update: true
You can opt-in for the following plugins installation, preserved from the
original zzet.rbenv
role:
Name for rbenv_plugins |
Plugin |
---|---|
rbenv_vars |
rbenv-vars |
default_gems |
rbenv-default-gems |
installer |
rbenv-installer |
update |
rbenv-update |
whatis |
rbenv-whatis |
use |
rbenv-use |
You can add your own plugins to the rbenv_plugins
list, provided that you also
sepecify a plugin definition under rbenv_plugin_{{plugin_name}}
.
Plugin definition should be a hash with keys name
, repo
(git url),
and version
(tag or branch or otherwise valid git object ref).
Optional attribute force_update
controls if git checkout should be performed
when the plugin appears to be installed. The default value for force_update
attribute is set to match rbenv_force_update
variable.
- hosts: web
gather_facts: true # https://github.com/zzet/ansible-rbenv-role/issues/37
vars:
rbenv_install: user
rbenv_version: v0.4.0
rbenv_default_ruby: 2.0.0-p353
rbenv_rubies:
- version: "{{ rbenv_default_ruby }}"
- version: 2.2.4
env:
RUBY_CONFIGURE_OPTS: "--enable-shared"
- version: 2.3.4
env:
RUBY_CONFIGURE_OPTS: "--enable-shared --with-jemalloc"
rbenv_extra_depends:
- libjemalloc1
- libjemalloc-dev
roles:
- role: zzet.rbenv
rbenv_users:
- user
none
When running on Debian with system-wide install, rbenv won't work from
sudo -s
shells. If you need rbenv commands within sudo shells, use sudo -i
.
This will launch login shell that will read the rbenv configuration snippet
from /etc/profile.d/rbenv.sh
(alternatively, you can manually source that
file from sudo -s
shell).
Ruby prior to 2.3 link to openssl 1.0, which is not present on modern Debian.
Starting with ruby 2.3, you can use gem version of openssl, which could be
linked against openssl 1.1. If you want to install older rubies on debian,
you'll have to override libssl_dev_pkg
to be libssl1.0-dev
(or install
openssl1.0 separately).
MIT