Update 3rdparty rabbitmq module
[mirror/dsa-puppet.git] / 3rdparty / modules / rabbitmq / lib / facter / erl_ssl_path.rb
diff --git a/3rdparty/modules/rabbitmq/lib/facter/erl_ssl_path.rb b/3rdparty/modules/rabbitmq/lib/facter/erl_ssl_path.rb
new file mode 100644 (file)
index 0000000..c8f41f6
--- /dev/null
@@ -0,0 +1,13 @@
+# Fact to get the ssl path for the erlang distribution in the current
+# system as described in the RabbitMQ docs [1].
+#
+# [1] https://www.rabbitmq.com/clustering-ssl.html
+Facter.add(:erl_ssl_path) do
+  setcode do
+    if Facter::Util::Resolution.which('erl')
+      data = Facter::Core::Execution.execute("erl -eval 'io:format(\"~p\", [code:lib_dir(ssl, ebin)]),halt().' -noshell")
+      # erl returns the string with quotes, strip them off
+      data.gsub!(%r{\A"|"\Z}, '')
+    end
+  end
+end