I’m using a small framework for foreman hooks, written in ruby & requires additional gems.
If I run scripts manually - everything works fine.
When foreman runs scripts I see this raise:
Hook: 20_server_inventory.rb task failed with the following error: Hook failure running `/usr/share/foreman/config/hooks/host/managed/destroy/20_server_inventory.rb destroy sjc04t1itoap01.local`: /opt/rh/rh-ruby22/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- tiny_tds (LoadError) from /opt/rh/rh-ruby22/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require' from /usr/share/foreman/config/hooks/libs/inventory.rb:4:in `initialize' from /usr/share/foreman/config/hooks/host/managed/destroy/20_server_inventory.rb:7:in `new' from /usr/share/foreman/config/hooks/host/managed/destroy/20_server_inventory.rb:7:in `<main>'
If there a way to fix this?
I found gem & ruby under /opt/rh/rh-ruby22/root/bin - but I can’t install any gems
[root@foreman vagrant]# /opt/rh/rh-ruby22/root/usr/bin/gem install tiny_tds
/opt/rh/rh-ruby22/root/usr/bin/ruby: error while loading shared libraries: libruby.so.2.2: cannot open shared object file: No such file or directory
One small question. I use Gemfile is there a way to make it work with bundle?
It installs by default to /tmp directory Thanks
[root@foreman destroy]# scl enable rh-ruby22 ‘bundler install --gemfile=/usr/share/foreman/config/hooks/Gemfile’
Don’t run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this application for all non-root users on this machine.
Using bundler 1.16.2
Using net-ping 2.0.4
Using oauth 0.5.4
Using tiny_tds 2.1.2
Bundle complete! 3 Gemfile dependencies, 4 gems now installed.
Bundled gems are installed into /tmp
[root@foreman destroy]# scl enable rh-ruby22 ‘gem install tiny_tds’
Fetching: tiny_tds-2.1.2.gem (100%)
Building native extensions. This could take a while…
ERROR: Error installing tiny_tds:
ERROR: Failed to build gem native extension.
mkmf.rb can’t find header files for ruby at /opt/rh/rh-ruby22/root/usr/share/include/ruby.h
extconf failed, exit code 1
Gem files will remain installed in /opt/rh/rh-ruby22/root/usr/local/share/gems/gems/tiny_tds-2.1.2 for inspection.
Results logged to /opt/rh/rh-ruby22/root/usr/local/lib64/gems/ruby/tiny_tds-2.1.2/gem_make.out