sensu / sensu-omnibus

Build full-stack platform-specific Sensu packages
12 stars 16 forks source link

Unable to set custom configuration variable for service script #216

Closed t2tre closed 6 years ago

t2tre commented 7 years ago

On a RHEL/CentOS system, I am trying to set a custom paths for the configuration folder, plugin folders, extension folders, etc. I am unable to do this by adding the relevant environment variable (for example CONFIG_DIR) to /etc/default/sensu or /etc/sysconfig/sensu-[server|client|api], because the settings are overridden in the sensu-service script.

The use case is where I have a sensu server that I want to monitor via a different Sensu instance, so the Sensu client instance on the sensu server needs a separate configuration folder from that used by Sensu Server and Sensu Api.

I would like to submit a pull request for updating the sensu-service script so that it checks each of the Sensu service script configuration variables (see https://sensuapp.org/docs/latest/reference/configuration.html) before it sets a default value.

portertech commented 7 years ago

What version of Sensu (the package) are you using?

Are you using sysvinit or systemd?

What version of RHEL/CentOS are you using?

t2tre commented 7 years ago

I'm using Sensu v0.29, sysvinit on CentOS 6

bodgit commented 7 years ago

I've just run into the same problem, Sensu 0.29.0 and CentOS 7 so it's Systemd here.

I'm trying to configure Sensu with two configuration directories; one to be managed with Puppet (the default /etc/sensu/... hierarchy) and another directory that Puppet does not manage that is populated by a separate process.

According to the documentation it states that CONFIG_DIR defaults to /etc/sensu/conf.d and likely maps through to the -d/--config_dir option on sensu-{client,server,...}. So I surmised that I could set CONFIG_DIR=/etc/sensu/conf.d,/some/other/path but this doesn't seem to work.

According to https://github.com/sensu/sensu-omnibus/blob/master/files/sensu-gem/bin/sensu-service#L52-L66 CONFIG_DIR is computed to be /etc/sensu (which doesn't match the documentation) and then CONFD_DIR is computed from that to be /etc/sensu/conf.d and then after a few more variables are computed /etc/default/sensu is sourced allowing these to be overridden however CONFIG_DIR is never used after that point so overriding it has no effect anywhere.

If I set CONFD_DIR in /etc/default/sensu then this has the desired effect but this doesn't match the documentation and as I want to in theory try and get the Puppet module updated to support setting additional directories it's not going to fly if I'm Puppet-izing undocumented behaviour.

amdprophet commented 7 years ago

@bodgit you are correct. CONFD_DIR replaced CONFIG_DIR in 0.27 and our documentation needs to be updated to reflect the change.

@t2tre the sysvinit scripts (https://github.com/sensu/sensu-omnibus/blob/master/config/templates/sensu-gem/sysvinit/sensu-service.erb#L32-L34) and binstub (https://github.com/sensu/sensu-omnibus/blob/master/files/sensu-gem/bin/sensu-service#L64-L66) both source /etc/default/sensu after setting their defaults. Try using CONFD_DIR instead of CONFIG_DIR in your defaults file.

portertech commented 6 years ago

Closing due to inactivity. Please feel free to create a new issue if this matter is not resolved.