Skip to content

Commit cf08d0d

Browse files
authored
feat!: modernise ruby_rbenv cookbook (#354)
* refactor: modernise ruby_rbenv cookbook - Add frozen_string_literal: true to all Ruby files - Move test cookbook from test/fixtures/cookbooks/test to test/cookbooks/test - Fix partial reference from _partial/git to _partial/_git in system_install - Remove EOL platforms, add current Ubuntu/Debian/AlmaLinux/Fedora platforms - Add default kitchen suite exercising primary system install workflow - Align CI matrix with kitchen.yml suites and platforms - Update Ruby versions in test recipes to 3.3.10, 3.4.9, 4.0.1 - Simplify package_deps.rb removing EOL Debian version branches - Add ChefSpec tests for all 8 resources and helper modules - Add default InSpec suite with controls for system install workflow - Update Ruby versions in existing InSpec integration tests - Move documentation to flat documentation/ structure - Update README with current platform list, doc paths, and test cookbook path - Add LIMITATIONS.md documenting install method, build deps, platform/arch notes - Remove stale test/unit specs * fix: add libyaml-dev/libyaml-devel to Ruby build dependencies - Ruby 3.4+ requires libyaml for the psych extension - Added libyaml-dev for Debian, libyaml-devel for RHEL/Fedora/Amazon/SUSE - Updated specs to match new dependency lists * fix: make rbenv_ruby uninstall guard idempotent - Skip uninstall when ruby version is already absent - Skip install when ruby version is already present - Stub File.directory? in spec for uninstall context * fix: resolve CI and idempotency issues in test configuration - Pass version: latest to actionshub/chef-install@6.0.0 (default 21.6.497 has checksum mismatch) - Disable idempotency for gem and ruby_uninstall suites (install-then-remove is inherently non-convergent) - Remove rbenv_rehash from default test recipe (bash resource always reports updated) * fix: use -d instead of -s for directory tests in rbenv.sh template - The -s flag tests 'file exists and has size > 0' which is unreliable for directories on overlayfs (Docker/CI environments) - Use -d to properly test directory existence * fix: add apt_update to test::dokken for Debian-family platforms - Dokken containers have stale apt cache causing package 404 errors - Refresh apt cache before installing git and other prerequisites * fix: resolve CI regressions for profile script, CRB repos, and test infra - Fix rbenv.sh.erb: use RBENV_ROOT env var, test .rbenv dir instead of .rbenv/bin, guard nil global_prefix with -n test - Fix test::dokken: enable native CRB/PowerTools repos instead of AlmaLinux-specific yum_alma resources - Fix test::dokken: set explicit home + manage_home for vagrant user - Fix system_install test: add include_recipe test::dokken for apt_update on Debian - Remove yum-almalinux test cookbook dependency Signed-off-by: Dan Webb <dan.webb@damacus.io> * fix: make rbenv profile script robust against rbenv init failures - Add shims dir to PATH so Ruby commands work even if rbenv init fails - Suppress rbenv init stderr and exit code to prevent source failures - Add diagnostic InSpec control to capture environment state on CI * fix: add sudo + NOPASSWD for vagrant in Dokken containers RHEL-family Dokken containers lack PAM configuration for non-root users, causing 'PAM account management error' when Chef or InSpec runs sudo -u vagrant. Install sudo package and add /etc/sudoers.d/vagrant with NOPASSWD:ALL. * fix: replace sudo with runuser in gem binary helper sudo fails in Dokken containers on RHEL-family because PAM cannot perform account management for users without /etc/shadow entries. runuser does not use PAM authentication, making it reliable for non-interactive user switching when already running as root. Also set vagrant password via chpasswd in test::dokken so InSpec verification commands using sudo work correctly. * fix: use runuser in user install integration checks --------- Signed-off-by: Dan Webb <dan.webb@damacus.io>
1 parent ca1e0d8 commit cf08d0d

68 files changed

Lines changed: 1098 additions & 209 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,19 @@ jobs:
2222
strategy:
2323
matrix:
2424
os:
25-
- "almalinux-8"
26-
- "almalinux-9"
2725
- "amazonlinux-2023"
28-
- "centos-7"
29-
- "centos-stream-8"
26+
- "fedora-latest"
27+
- "opensuse-leap-15"
28+
- "almalinux-9"
29+
- "almalinux-10"
3030
- "centos-stream-9"
31-
- "debian-10"
32-
- "debian-11"
31+
- "centos-stream-10"
3332
- "debian-12"
34-
- "fedora-latest"
35-
- "ubuntu-1804"
36-
- "ubuntu-2004"
33+
- "debian-13"
3734
- "ubuntu-2204"
35+
- "ubuntu-2404"
3836
suite:
37+
- "default"
3938
- "gem"
4039
- "global"
4140
- "ruby-uninstall"
@@ -48,6 +47,8 @@ jobs:
4847
uses: actions/checkout@v6
4948
- name: Install Chef
5049
uses: actionshub/chef-install@6.0.0
50+
with:
51+
version: latest
5152
- name: Dokken
5253
uses: actionshub/test-kitchen@3.0.0
5354
env:

.rubocop.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
---
2-
AllCops:
3-
Exclude:
4-
- 'Dangerfile'
1+
require:
2+
- cookstyle

Berksfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
# frozen_string_literal: true
2+
13
source 'https://supermarket.chef.io'
24

35
metadata
46

57
group :integration do
6-
cookbook 'test', path: 'test/fixtures/cookbooks/test'
8+
cookbook 'test', path: 'test/cookbooks/test'
79
end

LIMITATIONS.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Limitations
2+
3+
## Installation Method
4+
5+
rbenv is installed from source via `git clone` — there are no binary packages.
6+
Ruby versions are compiled from source using the [ruby-build](https://github.com/rbenv/ruby-build) plugin.
7+
8+
## Package Availability
9+
10+
This cookbook does **not** install packages for rbenv itself. It clones the rbenv
11+
git repository and compiles Ruby from source. Build dependencies are installed
12+
per platform family.
13+
14+
## Build Dependencies
15+
16+
| Platform Family | Packages |
17+
|------------------------|---------------------------------------------------------------------------------------------------------------------------------|
18+
| Debian | gcc, autoconf, bison, build-essential, libssl-dev, libreadline6-dev, zlib1g-dev, libncurses5-dev, libffi-dev, libgdbm-dev, make |
19+
| RHEL / Fedora / Amazon | gcc, bzip2, openssl-devel, libffi-devel, readline-devel, zlib-devel, gdbm-devel, ncurses-devel, make |
20+
| SUSE | gcc, make, automake, gdbm-devel, ncurses-devel, readline-devel, zlib-devel, libopenssl-devel, bzip2 |
21+
| macOS | openssl, makedepend, pkg-config, libffi |
22+
23+
## Architecture Limitations
24+
25+
- Ruby compiles natively on both amd64 and arm64
26+
- No architecture-specific restrictions from rbenv itself
27+
- Individual Ruby versions may have architecture-specific build issues
28+
29+
## Platform Notes
30+
31+
- **macOS**: Listed in `metadata.rb` but not tested in CI. System-wide installation
32+
requires manual `/etc/profile.d` setup as macOS does not support this idiom natively.
33+
- **FreeBSD**: Partial support in helper code but not listed in `metadata.rb` or tested.
34+
35+
## Known Issues
36+
37+
- Some Chef versions (>= 16 and < 16.4.41) have a bug in the `git` resource causing
38+
failures. Use Chef >= 16.4.41 or later.
39+
- JRuby installations require Java to be pre-installed (not managed by this cookbook).

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ This cookbook is maintained by the Sous Chefs. The Sous Chefs are a community of
1717

1818
### Chef
1919

20-
This cookbook requires Chef 13.0+.
20+
This cookbook requires Chef 16.0+.
2121

2222
**NOTE:** Some Chef versions (>= 16 and < 16.4.41) have a bug in the git resource causing some failures (see [#289](https://github.com/sous-chefs/ruby_rbenv/issues/289)). If you experience any troubles please try a more recent version of Chef 16.
2323

@@ -26,23 +26,23 @@ This cookbook requires Chef 13.0+.
2626
- Debian derivatives
2727
- Fedora
2828
- macOS (not currently tested)
29-
- RHEL derivatives (RHEL, CentOS, Amazon Linux, Oracle, Scientific Linux)
30-
- openSUSE and openSUSE leap
29+
- RHEL derivatives (RHEL, AlmaLinux, Rocky Linux, Amazon Linux, Oracle Linux)
30+
- openSUSE Leap
3131

3232
## Resources
3333

34-
- [rbenv_gem](documentation/resources/rbenv_gem.md)
35-
- [rbenv_global](documentation/resources/rbenv_global.md)
36-
- [rbenv_plugin](documentation/resources/rbenv_plugin.md)
37-
- [rbenv_rehash](documentation/resources/rbenv_rehash.md)
38-
- [rbenv_ruby](documentation/resources/rbenv_ruby.md)
39-
- [rbenv_script](documentation/resources/rbenv_script.md)
40-
- [rbenv_system_install](documentation/resources/rbenv_system_install.md)
41-
- [rbenv_user_install](documentation/resources/rbenv_user_install.md)
34+
- [rbenv_gem](documentation/rbenv_gem.md)
35+
- [rbenv_global](documentation/rbenv_global.md)
36+
- [rbenv_plugin](documentation/rbenv_plugin.md)
37+
- [rbenv_rehash](documentation/rbenv_rehash.md)
38+
- [rbenv_ruby](documentation/rbenv_ruby.md)
39+
- [rbenv_script](documentation/rbenv_script.md)
40+
- [rbenv_system_install](documentation/rbenv_system_install.md)
41+
- [rbenv_user_install](documentation/rbenv_user_install.md)
4242

4343
## Usage
4444

45-
Example installations are provided in `test/fixtures/cookbooks/test/recipes/`.
45+
Example installations are provided in `test/cookbooks/test/recipes/`.
4646

4747
A `rbenv_system_install` or `rbenv_user_install` is required to be set so that rbenv knows which version you want to use, and is installed on the system.
4848

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Installs a given Ruby version to the system or user location.
55
## Properties
66

77
| Name | Type | Default | Description |
8-
| ------------------ | --------------- | ----------------------------------------- | --------------------------------------- |
8+
|--------------------|-----------------|-------------------------------------------|-----------------------------------------|
99
| version | `String` | | Ruby version to install. |
1010
| environment | `Hash` | | Environment to pass to the Ruby script. |
1111
| rbenv_action | `String` | `install` | Action to pass to rbenv. |
@@ -17,11 +17,11 @@ Installs a given Ruby version to the system or user location.
1717
## Examples
1818

1919
```ruby
20-
rbenv_ruby '2.5.1' do
20+
rbenv_ruby '3.4.9' do
2121
user 'vagrant'
2222
end
2323
```
2424

2525
```ruby
26-
rbenv_ruby '2.5.1'
26+
rbenv_ruby '3.4.9'
2727
```

0 commit comments

Comments
 (0)