Skip to content

Commit be3f81a

Browse files
authored
Merge pull request #158 from bootc/fix/148-jruby-gem-path
fix: install hiera-eyaml into puppetserver's JRuby gem-home (#148)
2 parents 913d2dc + 4218c53 commit be3f81a

1 file changed

Lines changed: 35 additions & 3 deletions

File tree

openvoxserver/prep_release_container.sh

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,18 @@ else
4747
exit 1
4848
fi
4949

50-
gem install --no-document hiera-eyaml:${RUBYGEM_HIERA_EYAML}
50+
# Install gems into the system CRuby gem path. These back the tools that run
51+
# under the distro Ruby inside the container: the `puppet`/`facter` CLIs (used
52+
# by the entrypoint, e.g. `puppet config print`), the `puppetserver ca` CLI
53+
# (its cli/apps/ca app runs under the distro Ruby via /opt/puppetlabs/puppet/bin/ruby
54+
# and needs openvoxserver-ca plus its hocon dependency), and the `r10k`
55+
# convenience symlink created below. racc and syslog are stdlib gems dropped
56+
# from default Ruby 3.4+, installed here for the distro Ruby. rugged is a native
57+
# extension that cannot load on JRuby.
58+
#
59+
# NOTE: this path is NOT on puppetserver's JRuby gem-path. hiera-eyaml is needed
60+
# only by the server JVM (for eyaml Hiera lookups), so it is installed solely
61+
# into the JRuby gem-home further down, along with openvox. See #148.
5162
gem install --no-document hocon:1.4.0
5263
gem install --no-document openvox:${RUBYGEM_OPENVOX}
5364
gem install --no-document openvoxserver-ca:${RUBYGEM_OPENVOXSERVER_CA}
@@ -97,13 +108,34 @@ chmod 0770 /opt/puppetlabs/server/data/puppetserver
97108
find /etc/puppetlabs/puppet/ssl -type d -exec chmod 0770 {} \;
98109

99110
mkdir -p /opt/puppetlabs/puppet/bin
100-
for executable in puppet facter ruby gem irb erb r10k eyaml
111+
for executable in puppet facter ruby gem irb erb r10k
101112
do
102113
ln -s "$(command -v "$executable")" "/opt/puppetlabs/puppet/bin/$executable"
103114
done
104115

105-
# install puppet gem as library into jruby loadpath
116+
# Install the gems the puppetserver JVM loads at runtime into the JRuby
117+
# gem-home. The `gem install` calls above only populate the distro CRuby gem
118+
# path (e.g. /var/lib/gems/3.x), which is NOT on puppetserver's JRuby gem-path,
119+
# so any gem the server loads is invisible there. openvox provides puppet as a
120+
# server library, and hiera-eyaml is required for eyaml-encrypted Hiera lookups
121+
# during catalog compilation. The other gems above are CLI tools that run under
122+
# the distro Ruby (not the JVM), so they are not needed here. See #148.
106123
puppetserver gem install --no-document openvox:${RUBYGEM_OPENVOX}
124+
puppetserver gem install --no-document hiera-eyaml:${RUBYGEM_HIERA_EYAML}
125+
126+
# Expose the `eyaml` CLI. hiera-eyaml lives only in the JRuby gem-home, and its
127+
# binstub there resolves the gem against the default (distro) gem-path, where it
128+
# is no longer installed, so it can't simply be symlinked. Wrap it to run under
129+
# the distro Ruby with GEM_PATH pointed at the JRuby gem-home; hiera-eyaml is a
130+
# pure-Ruby gem, so it loads fine there and we avoid JVM start-up. The CLI is
131+
# essentially never used inside the container, it is provided only for the
132+
# occasional manual eyaml encrypt/decrypt.
133+
cat > /opt/puppetlabs/puppet/bin/eyaml <<'SCRIPT'
134+
#!/bin/bash
135+
export GEM_PATH="/opt/puppetlabs/server/data/puppetserver/jruby-gems${GEM_PATH:+:$GEM_PATH}"
136+
exec ruby /opt/puppetlabs/server/data/puppetserver/jruby-gems/bin/eyaml "$@"
137+
SCRIPT
138+
chmod 0755 /opt/puppetlabs/puppet/bin/eyaml
107139

108140
# use system/root paths instead of non-root paths to make permission management
109141
# and volume mounting simpler. for this we link the appropiate paths and explicitly

0 commit comments

Comments
 (0)