module-puppetlabs-mysql/lib/facter/mysql_server_id.rb
Ben Ford eaff7e40b5 Don't explode if macaddress isn't set
Sometimes the macaddress fact fails, for example sometimes in a Docker
container. We shouldn't clutter up reports with spurious warnings in
that case.
2015-06-25 10:23:58 -07:00

9 lines
198 B
Ruby

def get_mysql_id
Facter.value(:macaddress).split(':').inject(0) { |total,value| (total << 4) + value.hex }
end
Facter.add("mysql_server_id") do
setcode do
get_mysql_id rescue nil
end
end