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.

Fixes: voxpupuli#783
  • Loading branch information
jistr committed Mar 25, 2019
1 parent 5477e69 commit 12989f5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/facter/rabbitmq_plugins_dirs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +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_match = %r{^\{ok\,\"(\/.+\/\w+)}.match(rabbitmq_pluginsdirs_env)
rabbitmq_plugins_dirs = rabbitmq_plugins_dirs_match ? rabbitmq_plugins_dirs_match[1] : ''
rabbitmq_plugins_dirs.split(':')
end
end
Expand Down

0 comments on commit 12989f5

Please sign in to comment.