diff --git a/README.md b/README.md index fb8f525..5a9ac9c 100644 --- a/README.md +++ b/README.md @@ -768,6 +768,14 @@ The name of the MySQL plugin to manage. The library file name. +###Facts + +####`mysql_server_id` + +Generates a unique id, based on the node's MAC address, which can be used as +`server_id`. This fact will *always* return `0` on all nodes which only have +loopback interfaces. Given those nodes' connnectivity that's probably okay. + ##Limitations This module has been tested on: diff --git a/lib/facter/server_id.rb b/lib/facter/mysql_server_id.rb similarity index 100% rename from lib/facter/server_id.rb rename to lib/facter/mysql_server_id.rb diff --git a/spec/unit/facter/mysql_server_id_spec.rb b/spec/unit/facter/mysql_server_id_spec.rb new file mode 100644 index 0000000..304890e --- /dev/null +++ b/spec/unit/facter/mysql_server_id_spec.rb @@ -0,0 +1,27 @@ +require "spec_helper" + +describe Facter::Util::Fact do + before { + Facter.clear + } + + describe "mysql_server_id" do + context "igalic's laptop" do + before :each do + Facter.fact(:macadddress).stubs(:value).returns('3c:97:0e:69:fb:e1') + end + it do + Facter.fact(:mysql_server_id).value.to_s.should == '72898961' + end + end + + context "node with lo only" do + before :each do + Facter.fact(:macadddress).stubs(:value).returns('00:00:00:00:00:00') + end + it do + Facter.fact(:mysql_server_id).value.should == '0' + end + end + end +end