Skip to content

Commit 877f320

Browse files
committed
Remove facter rabbitmq_nodename error message
Currently when facter checks for rabbitmq_nodename and rabbitmq is not available due to a number of reasons. We get the following facter error displayed: Error: Facter: error while resolving custom fact "rabbitmq_nodename": undefined method `[]' for nil:NilClass Since facter errors are non fatal anyway let's be a little friendlier. Before this change: $ puppet apply foo.pp Error: Facter: error while resolving custom fact "rabbitmq_nodename": undefined method `[]' for nil:NilClass Notice: Compiled catalog for messaging-0.redhat.local in environment production in 0.02 seconds Notice: foo Notice: /Stage[main]/Main/Notify[foo]/message: defined 'message' as 'foo' After this change: $ puppet apply foo.pp Notice: Compiled catalog for messaging-0.redhat.local in environment production in 0.02 seconds Notice: foo Notice: /Stage[main]/Main/Notify[foo]/message: defined 'message' as 'foo' After this change with debug mode: $ puppet --debug apply foo.pp 2>&1 |grep -e "Error:.*rabbitmq_nodename" Debug: Facter: Error: rabbitmq_nodename facter failed. Output was warning: the VM is running with native name encoding of latin1 which may cause Elixir to malfunction as it expects utf8. Please ensure your locale is set to UTF-8 (which can be verified by running "locale" in your shell)
1 parent 5818788 commit 877f320

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/facter/rabbitmq_nodename.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
setcode do
33
if Facter::Util::Resolution.which('rabbitmqctl')
44
rabbitmq_nodename = Facter::Core::Execution.execute('rabbitmqctl status 2>&1')
5-
%r{^Status of node '?([\w\.\-]+@[\w\.\-]+)'?}.match(rabbitmq_nodename)[1]
5+
begin
6+
%r{^Status of node '?([\w\.\-]+@[\w\.\-]+)'?}.match(rabbitmq_nodename)[1]
7+
rescue
8+
Facter.debug("Error: rabbitmq_nodename facter failed. Output was #{rabbitmq_nodename}")
9+
end
610
end
711
end
812
end

0 commit comments

Comments
 (0)