(maint) - Add a fact for capturing the mysql version installed
- Add spec test for mysql_version fact - Add `mysql_version` fact to README
This commit is contained in:
parent
dd129d5e52
commit
3ce8ad3799
3 changed files with 33 additions and 1 deletions
|
@ -784,6 +784,10 @@ The library file name.
|
||||||
|
|
||||||
###Facts
|
###Facts
|
||||||
|
|
||||||
|
#### `mysql_version`
|
||||||
|
|
||||||
|
Determines the MySql version by parsing the output from `mysql --version`
|
||||||
|
|
||||||
#### `mysql_server_id`
|
#### `mysql_server_id`
|
||||||
|
|
||||||
Generates a unique id, based on the node's MAC address, which can be used as
|
Generates a unique id, based on the node's MAC address, which can be used as
|
||||||
|
|
8
lib/facter/mysql_version.rb
Normal file
8
lib/facter/mysql_version.rb
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
Facter.add("mysql_version") do
|
||||||
|
setcode do
|
||||||
|
mysql_ver = Facter::Util::Resolution.exec('mysql --version')
|
||||||
|
if mysql_ver
|
||||||
|
mysql_ver.match(/\d+\.\d+\.\d+/)[0]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
20
spec/unit/facter/mysql_version_spec.rb
Normal file
20
spec/unit/facter/mysql_version_spec.rb
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
require "spec_helper"
|
||||||
|
|
||||||
|
describe Facter::Util::Fact do
|
||||||
|
before {
|
||||||
|
Facter.clear
|
||||||
|
}
|
||||||
|
|
||||||
|
describe "mysql_version" do
|
||||||
|
context 'with value' do
|
||||||
|
before :each do
|
||||||
|
Facter::Util::Resolution.stubs(:exec).with('mysql --version').returns('mysql Ver 14.12 Distrib 5.0.95, for redhat-linux-gnu (x86_64) using readline 5.1')
|
||||||
|
end
|
||||||
|
it {
|
||||||
|
expect(Facter.fact(:mysql_version).value).to eq('5.0.95')
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
Loading…
Reference in a new issue