# Fact: rabbitmq_erlang_cookie
#
# Purpose: To determine the current erlang cookie value.
#
# Resolution: Returns the cookie.
Facter.add(:rabbitmq_erlang_cookie) do
  confine :osfamily => %w[Debian RedHat Suse]

  case Facter.value(:osfamily)
  when 'Debian', 'RedHat', 'Suse'
    cookie = File.read('/var/lib/rabbitmq/.erlang.cookie')
  end
  cookie
end

# Fact: rabbitmq_erlang_cookie
#
# Purpose: To determine the current erlang cookie value.
#
# Resolution: Returns the cookie.
Facter.add(:rabbitmq_erlang_cookie) do
  confine :osfamily => %w[Debian RedHat Suse]

  setcode do
    if File.exists?('/var/lib/rabbitmq/.erlang.cookie')
      File.read('/var/lib/rabbitmq/.erlang.cookie')
    else
      nil
    end
  end
end

Fix the wrapping around this fact.
Fix the wrapping around this fact.

Embarrassing this fact was completely broken, but because the spec tests
fake out the results of the fact it wasn't being picked up.
