mocdaniel / dashing-icinga2

Dashing dashboard for Icinga 2 using the REST API
MIT License
204 stars 47 forks source link

CentOs 7 - Cannot Start Service /usr/bin/env: ruby: No such file or directory #78

Closed pauby closed 5 years ago

pauby commented 5 years ago

Installing Dashing on CentOS 7 (I'm using CentOS 7.6.1810) is a bit of a chore thanks to CentOS no longer having an update ruby vesion in the general repositories. So I had to install Ruby this way - I installed rh-ruby25-ruby-devel but the process is the same.

I followed all of the instructions and made sure the bundle installed all of the gems. I amended the paths for the dashing-icinga2.service from /usr/local/bin/dashing to /opt/rh/rh-ruby25/root/usr/bin/dashing. Running /opt/rh/rh-ruby25/root/usr/bin/dashing -p 8005 gives me an error every 5 seconds or so (but I think this may be a red herring as it appears to keep running):

================================================================================
scheduler caught exception:
401 Unauthorized
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rest-client-2.0.2/lib/restclient/abstract_response.rb:223:in `exception_with_response'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rest-client-2.0.2/lib/restclient/abstract_response.rb:103:in `return!'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rest-client-2.0.2/lib/restclient/request.rb:809:in `process_result'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rest-client-2.0.2/lib/restclient/request.rb:725:in `block in transmit'
/opt/rh/rh-ruby25/root/usr/share/ruby/net/http.rb:910:in `start'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rest-client-2.0.2/lib/restclient/request.rb:715:in `transmit'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rest-client-2.0.2/lib/restclient/request.rb:145:in `execute'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rest-client-2.0.2/lib/restclient/request.rb:52:in `execute'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rest-client-2.0.2/lib/restclient/resource.rb:51:in `get'
/usr/share/dashing-icinga2/lib/icinga2.rb:236:in `getApiData'
/usr/share/dashing-icinga2/lib/icinga2.rb:258:in `getIcingaApplicationData'
/usr/share/dashing-icinga2/lib/icinga2.rb:662:in `run'
/usr/share/dashing-icinga2/jobs/icinga2.rb:27:in `block in <top (required)>'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rufus-scheduler-2.0.24/lib/rufus/sc/jobs.rb:230:in `trigger_block'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rufus-scheduler-2.0.24/lib/rufus/sc/jobs.rb:204:in `block in trigger'
/opt/rh/rh-ruby25/root/usr/share/gems/gems/rufus-scheduler-2.0.24/lib/rufus/sc/scheduler.rb:430:in `block in trigger_job'
================================================================================

After copying the dashing-icinga2.service to the correct systemd folder and running sudo systemctl start dashing-icinga2 it immediately returns an error message and if I look at journalctl -xe I see:

-- Unit dashing-icinga2.service has begun starting up.
Jul 05 21:15:03 ip-172-30-0-241.ec2.internal dashing[6588]: /usr/bin/env: ruby: No such file or directory
Jul 05 21:15:03 ip-172-30-0-241.ec2.internal systemd[1]: dashing-icinga2.service: main process exited, code
Jul 05 21:15:03 ip-172-30-0-241.ec2.internal systemd[1]: Failed to start Dashing-Icinga2 host/service/netwo
-- Subject: Unit dashing-icinga2.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit dashing-icinga2.service has failed.

If I run /usr/bin/env ruby it just sits there until I press Ctrl + C. If I run which ruby I get /opt/rh/rh-ruby25/root/usr/bin/ruby.

Unfortunately the instructions don't take into account how things have changed with CentOS. Which is fine. If you're not using it you'll not know until somebody reports it. However I'm a bit lost now on where to do.

Any help appreciated.

dnsmichi commented 5 years ago

CentOS no longer having an update ruby vesion in the general repositories.

Not sure why you would need to update the Ruby version. The Vagrant boxes use CentOS 7 as base, and Dashing runs inside like a charm. Without any SCL packages.

scheduler caught exception:
401 Unauthorized

The error is that the provided API credentials are wrong, you can modify such in the configuration file for dashing-icinga2.

/usr/bin/env: ruby: No such file or directory

Maybe Systemd needs more specific environment variables being set, when you change from native ruby to SCL.

pauby commented 5 years ago

Not sure why you would need to update the Ruby version. The Vagrant boxes use CentOS 7 as base, and Dashing runs inside like a charm. Without any SCL packages.

The verion of Ruby that was installed out of the box is 2.0.0. When I went to run the bundle step:

cd /usr/share/dashing-icinga2
bundle

I got an error that bundle required a minimum of Ruby 2.3.0. That's why I went to update, found out 2.0.0 was way out of date and searched for how to update it and came across SCL.

The error is that the provided API credentials are wrong, you can modify such in the configuration file for dashing-icinga2.

Hmmm. The credentials I made sure matched. I'll take a look.

Maybe Systemd needs more specific environment variables being set, when you change from native ruby to SCL.

That's where my knowledge will therefore stop, sadly 😢 SCL, from my limited understanding, is supposed to be a replacement for the native Ruby so all the environment variables and config should be updated by it.

dnsmichi commented 5 years ago

The Vagrant boxes have EPEL enabled by default and then install bundler via packages. This is abstracted in this Puppet profile: https://github.com/Icinga/icinga-vagrant/blob/master/.puppet/modules/profiles/manifests/dashing/icinga2.pp

When you're going the gem install bundler route, I could imagine that bundler doesn't like the old Ruby version. Still, with the packaged variant, without updating bundler when asking from its run, it should work. Otherwise the Vagrant runs would fail.