Ruby Gems installation for Linux.
| GitHub | Issues | Pull Requests | Version | Downloads |
|---|---|---|---|---|
This example is taken from molecule/default/converge.yml and is tested on each push, pull request and release.
---
- name: Converge
hosts: all
post_tasks:
- name: Verify Ruby is installed.
changed_when: false
ansible.builtin.command: ruby --version
pre_tasks:
- name: Install python3 and sudo
ansible.builtin.raw: |
if command -v dnf 2>/dev/null; then
dnf install -y python3 sudo
elif command -v apt-get 2>/dev/null; then
apt-get update -qq && apt-get install -y python3 sudo
elif command -v apk 2>/dev/null; then
apk update && apk add python3 sudo
fi
become: false
changed_when: true
- name: Find EXTERNALLY-MANAGED files
ansible.builtin.find:
paths: /usr/lib
patterns: "EXTERNALLY-MANAGED"
recurse: true
register: externally_managed_files
- name: Remove EXTERNALLY-MANAGED files
ansible.builtin.file:
path: "{{ item.path }}"
state: absent
loop: "{{ externally_managed_files.files }}"
- name: Update apt cache.
ansible.builtin.apt:
update_cache: "true"
cache_valid_time: "600"
when: ansible_facts['os_family'] == 'Debian'
- name: Add rubygems bin dir to system-wide $PATH.
ansible.builtin.copy:
content: PATH=$PATH:{{ ruby_gems_bin_path }}
dest: /etc/profile.d/ruby.sh
mode: "0644"
- name: Don't install Bundler on CentOS 7 because of old Ruby version.
ansible.builtin.set_fact:
ruby_install_bundler: false
when:
- ansible_facts['os_family'] == 'RedHat'
- ansible_facts['distribution_major_version'] == '7'
roles:
- role: buluma.bootstrap
- role: buluma.ruby_gems
vars:
ruby_gems_bin_path: /root/.gem/ruby/bin
ruby_install_gems:
- json
ruby_install_gems_user: rootAlso see a full explanation and example on how to use these roles.
The default values for the variables are set in defaults/main.yml:
---
ruby_download_url: "http://cache.ruby-lang.org/pub/ruby/3.0/ruby-3.0.0.tar.gz"
ruby_install_bundler: true
ruby_install_from_source: true
ruby_install_gems: []
ruby_install_gems_user: "{{ ansible_user }}"
ruby_rubygems_package_name: rubygems
ruby_source_configure_command: ./configure --enable-shared
ruby_version: "3.0.0"
workspace: /root- pip packages listed in requirements.txt.
The following roles are used to prepare a system. You can prepare your system in another way.
| Requirement | GitHub |
|---|---|
| buluma.bootstrap |
This role is part of many compatible roles. Have a look at the documentation of these roles for further information.
Here is an overview of related roles:
This role has been tested on these container images:
| container | tags |
|---|---|
| EL | 10, 9 |
| Debian | all |
| Fedora | 44, 43 |
| Ubuntu | all |
The minimum version of Ansible required is 2.12, tests have been done on:
- The previous version.
- The current version.
- The development version.
If you find issues, please register them on GitHub.
