-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5b21e12
commit 3b2de63
Showing
12 changed files
with
275 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
--- | ||
roles: | ||
- name: rvm/ruby | ||
src: https://github.com/rvm/rvm1-ansible | ||
version: v2.2.0 | ||
- name: geerlingguy.composer | ||
src: https://github.com/geerlingguy/ansible-role-composer | ||
version: master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Ansible Role: rvm | ||
|
||
An Ansible Role that installs [rvm](https://rsync.samba.org/) and manage ruby version on Debian and Ubuntu servers. | ||
|
||
## Role Variables | ||
|
||
Available variables can be found in [defaults/main.yml](defaults/main.yml) | ||
|
||
## Example Playbook | ||
|
||
```yaml | ||
- hosts: all | ||
|
||
vars: | ||
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 | ||
|
||
roles: | ||
- alphanodes.setup.rvm | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
--- | ||
|
||
# Install 1 or more versions of ruby | ||
# The last ruby listed will be set as the default ruby | ||
rvm1_rubies: | ||
- 'ruby-3.2.2' | ||
|
||
# Install bundler | ||
rvm1_bundler_install: false | ||
|
||
# Delete a specific version of ruby (ie. ruby-2.1.0) | ||
rvm1_delete_ruby: | ||
|
||
# Install path for rvm (defaults to user based install) | ||
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: '--user-install' | ||
|
||
# Add additional ruby install flags | ||
rvm1_ruby_install_flags: | ||
|
||
# Set the owner for the rvm directory | ||
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 | ||
# Note: 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 | ||
# rvm1_gpg_keys: '409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB' | ||
rvm1_gpg_keys: '' | ||
|
||
# The GPG key server | ||
rvm1_gpg_key_server: 'hkp://keys.openpgp.org' | ||
|
||
# The GPG alternative key servers | ||
rvm1_gpg_key_servers: | ||
- '{{ rvm1_gpg_key_server }}' | ||
- hkp://pgp.mit.edu | ||
- hkp://keyserver.pgp.com | ||
- hkp://keyserver.ubuntu.com | ||
|
||
# autolib mode, see https://rvm.io/rvm/autolibs | ||
rvm1_autolib_mode: 2 | ||
|
||
# Name of UID 0 user | ||
root_user: 'root' | ||
|
||
# Name of GID 0 group -- BSD systems typically use wheel instead of root | ||
root_group: '{{ root_user }}' | ||
|
||
# Symlink binaries to system path | ||
rvm1_symlink: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
galaxy_info: | ||
description: RVM role to install and manage your ruby versions | ||
author: alexandermeindl | ||
company: AlphaNodes GmbH | ||
license: Apache License 2.0 | ||
min_ansible_version: '2.14' | ||
|
||
platforms: | ||
- name: Ubuntu | ||
versions: | ||
- focal | ||
- jammy | ||
- name: Debian | ||
versions: | ||
- bullseye | ||
- bookworm | ||
|
||
dependencies: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
|
||
- name: Install RVM | ||
ansible.builtin.import_tasks: 'rvm.yml' | ||
become: true | ||
become_user: '{{ rvm1_user }}' | ||
|
||
- name: Install Ruby and Gems | ||
ansible.builtin.import_tasks: 'rubies.yml' | ||
become: true | ||
become_user: '{{ rvm1_user }}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
--- | ||
|
||
- name: Detect rubies | ||
ansible.builtin.command: '{{ rvm1_rvm }} list strings' | ||
register: rvm_list_strings | ||
changed_when: False | ||
|
||
- name: Install rubies | ||
ansible.builtin.command: '{{ rvm1_rvm }} install {{ item }} {{ rvm1_ruby_install_flags }}' | ||
loop: '{{ rvm1_rubies | difference(rvm_list_strings.stdout_lines) }}' | ||
|
||
- name: Detect default ruby version | ||
ansible.builtin.command: '{{ rvm1_rvm }} alias list default' | ||
changed_when: False | ||
register: detect_default_ruby_version | ||
|
||
- name: Select default ruby | ||
ansible.builtin.command: '{{ rvm1_rvm }} alias create default {{ rvm1_default_ruby_version }}' | ||
when: detect_default_ruby_version.stdout|default() | length == 0 or | ||
rvm1_default_ruby_version not in detect_default_ruby_version.stdout | ||
|
||
- name: Detect installed ruby patch number | ||
ansible.builtin.shell: > | ||
set -o pipefail && | ||
{{ rvm1_rvm }} list strings | | ||
grep {{ item }} | | ||
tail -n 1 | ||
with_items: '{{ rvm1_rubies }}' | ||
changed_when: False | ||
register: ruby_patch | ||
check_mode: no # Run in normal mode when in --check mode (http://docs.ansible.com/ansible/playbooks_checkmode.html) | ||
Check warning on line 31 in roles/rvm/tasks/rubies.yml GitHub Actions / build
|
||
|
||
- name: Install bundler if not installed | ||
ansible.builtin.shell: > | ||
set -o pipefail && | ||
ls {{ rvm1_install_path }}/wrappers/{{ item.stdout }} | | ||
if ! grep "^bundler " ; then {{ rvm1_install_path }}/wrappers/{{ item.stdout }}/gem install bundler ; fi | ||
args: | ||
creates: '{{ rvm1_install_path }}/wrappers/{{ item.stdout }}/bundler' | ||
with_items: '{{ ruby_patch.results }}' | ||
when: rvm1_bundler_install | ||
register: bundler_install | ||
changed_when: '"Successfully installed bundler" in bundler_install.stdout' | ||
|
||
- name: Symlink ruby related binaries on the system path | ||
ansible.builtin.file: | ||
state: 'link' | ||
src: '{{ rvm1_install_path }}/wrappers/default/{{ item }}' | ||
dest: '{{ rvm1_symlink_to }}/{{ item }}' | ||
owner: '{{ root_user }}' | ||
group: '{{ root_group }}' | ||
when: not '--user-install' in rvm1_install_flags and rvm1_symlink | ||
with_items: '{{ rvm1_symlink_binaries }}' | ||
|
||
- name: Symlink bundler binaries on the system path | ||
ansible.builtin.file: | ||
state: 'link' | ||
src: '{{ rvm1_install_path }}/wrappers/default/{{ item }}' | ||
dest: '{{ rvm1_symlink_to }}/{{ item }}' | ||
owner: '{{ root_user }}' | ||
group: '{{ root_group }}' | ||
when: not '--user-install' in rvm1_install_flags and rvm1_bundler_install and rvm1_symlink | ||
with_items: '{{ rvm1_symlink_bundler_binaries }}' | ||
|
||
- name: Delete ruby if relevant | ||
ansible.builtin.command: '{{ rvm1_rvm }} remove {{ rvm1_delete_ruby }}' | ||
register: rvm_delete_command | ||
changed_when: "'#removing' in rvm_delete_command.stdout" | ||
when: rvm1_delete_ruby is defined and rvm1_delete_ruby |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
--- | ||
|
||
- name: Detect rvm binary | ||
ansible.builtin.stat: | ||
path: '{{ rvm1_rvm }}' | ||
register: rvm_binary | ||
|
||
- name: Detect rvm installer | ||
ansible.builtin.stat: | ||
path: '{{ rvm1_temp_download_path }}/rvm-installer.sh' | ||
register: rvm_installer | ||
|
||
- name: Detect current rvm version | ||
ansible.builtin.command: '{{ rvm1_rvm }} version' | ||
changed_when: False | ||
register: rvm_current_version | ||
when: rvm_binary.stat.exists | ||
|
||
- name: Install rvm installer | ||
ansible.builtin.get_url: | ||
url: '{{ rvm1_rvm_latest_installer }}' | ||
dest: '{{ rvm1_temp_download_path }}/rvm-installer.sh' | ||
mode: 0755 | ||
when: not rvm_installer.stat.exists | ||
|
||
- name: Import GPG keys from keyservers | ||
ansible.builtin.command: 'gpg --batch --keyserver {{ item }} --recv-keys {{ rvm1_gpg_keys }}' | ||
changed_when: False | ||
check_mode: False | ||
with_items: '{{ rvm1_gpg_key_servers }}' | ||
register: gpg_import | ||
when: not ansible_check_mode and rvm1_gpg_keys | length and (gpg_import is not defined or gpg_import.rc != 0) | ||
ignore_errors: True | ||
|
||
- name: Was GPG import from keyservers succesfull? | ||
ansible.builtin.set_fact: | ||
gpg_imported_from: '{{ item.item }}' | ||
when: "'rc' in item and item.rc == 0" | ||
with_items: "{{ gpg_import.results }}" | ||
|
||
- name: Import GPG keys from rvm.io, if keyservers failed | ||
ansible.builtin.shell: > | ||
set -o pipefail && | ||
curl -sSL https://rvm.io/{{ item }} | gpg --batch --import - | ||
with_items: | ||
- mpapis.asc | ||
- pkuczynski.asc | ||
when: not ansible_check_mode and rvm1_gpg_keys | length and gpg_imported_from is not defined | ||
|
||
- name: Install rvm | ||
ansible.builtin.shell: > | ||
/usr/bin/env bash {{ rvm1_temp_download_path }}/rvm-installer.sh {{ rvm1_rvm_version }} | ||
--path {{ rvm1_install_path }} {{ rvm1_install_flags }} | ||
when: not rvm_binary.stat.exists | ||
|
||
- name: Update rvm | ||
ansible.builtin.shell: '{{ rvm1_rvm }} get {{ rvm1_rvm_version }} && {{ rvm1_rvm }} reload' | ||
changed_when: False | ||
when: rvm_binary.stat.exists and rvm1_rvm_check_for_updates | ||
|
||
- name: Configure rvm | ||
ansible.builtin.command: '{{ rvm1_rvm }} autolibs {{ rvm1_autolib_mode }}' | ||
when: not rvm_binary.stat.exists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
|
||
rvm1_temp_download_path: '/tmp' | ||
|
||
rvm1_default_ruby_version: '{{ rvm1_rubies | last if rvm1_rubies and rvm1_rubies is iterable else rvm1_rubies }}' | ||
|
||
rvm1_rvm: '{{ rvm1_install_path }}/bin/rvm' | ||
|
||
rvm1_symlink_binaries: | ||
- 'erb' | ||
- 'executable-hooks-uninstaller' | ||
- 'gem' | ||
- 'irb' | ||
- 'rake' | ||
- 'rdoc' | ||
- 'ri' | ||
- 'ruby' | ||
|
||
rvm1_symlink_bundler_binaries: | ||
- 'bundle' | ||
- 'bundler' | ||
|
||
rvm1_symlink_to: '/usr/local/bin' |