Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the command parameter if it's defined alongside the source parameter #255

Merged
merged 1 commit into from
Oct 3, 2014

Conversation

bodgit
Copy link
Contributor

@bodgit bodgit commented Sep 30, 2014

Previously if command and source parameters were both specified, the value of command was in fact ignored. This is not desired when the command might need additional preamble or arguments to function.

Specifically my use case is to install a Ruby-based handler, but due to running CentOS/RHEL 6.x with Ruby 1.8.7 and not wanting to pollute the embedded Ruby installed and used by Sensu I have it working using a Ruby installed as part of the RHEL Software Collections. So my actual command should be:

env -u GEM_PATH scl enable ruby193 /etc/sensu/handlers/myshinyhandler.rb

(Annoyingly, I found I need to clear $GEM_PATH otherwise my separate SCL Ruby uses the gems from the embedded Ruby and it still doesn't work)

However when I define my handler like so:

::sensu::handler { 'myshinyhandler':
  type    => pipe,
  command => 'env -u GEM_PATH scl enable ruby193 /etc/sensu/handlers/myshinyhandler.rb',
  source  => 'puppet:///modules/mymodule/myshinyhandler.rb',
}

The resulting myshinyhandler.json config file just has /etc/sensu/handlers/myshinyhandler.rb for the command.

This PR just uses the value of command if it's defined alongside source, otherwise behave as before and set it to the concatenation of the install path and the base filename of the handler.

Previously if command and source parameters were both specified, command was
in fact ignored. This is not helpful when the command might need additional
preamble or arguments to function.

Change the logic to use the value of the command parameter if it is defined,
(and therefore allow the operator to shoot themselves in the foot), otherwise
behave as before by setting the command to the concatenation of the install
path and the handler filename.
jamtur01 added a commit that referenced this pull request Oct 3, 2014
Use the command parameter if it's defined alongside the source parameter
@jamtur01 jamtur01 merged commit d5fe391 into sensu:master Oct 3, 2014
@jamtur01
Copy link
Contributor

jamtur01 commented Oct 3, 2014

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants