Skip to content

Commit

Permalink
Don't crash on rabbitmq_plugins_dirs fact if rabbitmqctl is not present
Browse files Browse the repository at this point in the history
Before trying to access the contents of a regexp match, see if the
match was successful. On machines without rabbitmqctl this match will
return `nil`, so we can't index it with `[1]`. When that's the case,
the whole rabbitmq_plugins_dirs fact value will now be `nil`, instead
of throwing an exception.

Fixes: #783
  • Loading branch information
jistr committed Mar 27, 2019
1 parent 5477e69 commit ce7d4ce
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/facter/rabbitmq_plugins_dirs.rb
Expand Up @@ -2,8 +2,8 @@
setcode do
if Facter::Util::Resolution.which('rabbitmqctl')
rabbitmq_pluginsdirs_env = Facter::Core::Execution.execute("rabbitmqctl eval 'application:get_env(rabbit, plugins_dir).'")
rabbitmq_plugins_dirs = %r{^\{ok\,\"(\/.+\/\w+)}.match(rabbitmq_pluginsdirs_env)[1]
rabbitmq_plugins_dirs.split(':')
rabbitmq_plugins_dirs_match = %r{^\{ok\,\"(\/.+\/\w+)}.match(rabbitmq_pluginsdirs_env)
rabbitmq_plugins_dirs_match[1].split(':') if rabbitmq_plugins_dirs_match
end
end
end

0 comments on commit ce7d4ce

Please sign in to comment.