summaryrefslogtreecommitdiff
path: root/lib/facter
diff options
context:
space:
mode:
Diffstat (limited to 'lib/facter')
-rw-r--r--lib/facter/mysql.rb8
-rw-r--r--lib/facter/mysql_exists.rb5
-rw-r--r--lib/facter/mysql_version.rb6
3 files changed, 11 insertions, 8 deletions
diff --git a/lib/facter/mysql.rb b/lib/facter/mysql.rb
deleted file mode 100644
index e262ec1..0000000
--- a/lib/facter/mysql.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-Facter.add("mysql_exists") do
- ENV["PATH"]="/bin:/sbin:/usr/bin:/usr/sbin"
-
- setcode do
- mysqlexists = system "which mysql > /dev/null 2>&1"
- ($?.exitstatus == 0)
- end
-end
diff --git a/lib/facter/mysql_exists.rb b/lib/facter/mysql_exists.rb
new file mode 100644
index 0000000..d08dabe
--- /dev/null
+++ b/lib/facter/mysql_exists.rb
@@ -0,0 +1,5 @@
+Facter.add("mysql_exists") do
+ setcode do
+ File.exist? '/usr/bin/mysql'
+ end
+end
diff --git a/lib/facter/mysql_version.rb b/lib/facter/mysql_version.rb
new file mode 100644
index 0000000..ba3dc36
--- /dev/null
+++ b/lib/facter/mysql_version.rb
@@ -0,0 +1,6 @@
+Facter.add("mysql_version") do
+ confine :mysql_exists => true
+ setcode do
+ Facter::Util::Resolution.exec('mysql --version').chomp.split(' ')[4].split(',').first
+ end
+end