]> gitweb.fluxo.info Git - puppet-mysql.git/commitdiff
More lib updates
authorSilvio Rhatto <rhatto@riseup.net>
Sat, 26 Jan 2013 15:04:42 +0000 (13:04 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Sat, 26 Jan 2013 15:04:42 +0000 (13:04 -0200)
lib/facter/mysql.rb [deleted file]
lib/facter/mysql_exists.rb [new file with mode: 0644]
lib/facter/mysql_version.rb [new file with mode: 0644]
lib/puppet/provider/mysql_user/mysql.rb
lib/puppet/type/mysql_database.rb
lib/puppet/type/mysql_user.rb

diff --git a/lib/facter/mysql.rb b/lib/facter/mysql.rb
deleted file mode 100644 (file)
index e262ec1..0000000
+++ /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 (file)
index 0000000..d08dabe
--- /dev/null
@@ -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 (file)
index 0000000..ba3dc36
--- /dev/null
@@ -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
index e04d7e6ec7234b8447760f79f518cf42dca761a0..3051681d7606a2b9ff50d98084a61cc2800eb5de 100644 (file)
@@ -1,8 +1,8 @@
 require 'puppet/provider/package'
 
 Puppet::Type.type(:mysql_user).provide(:mysql,
-    # T'is funny business, this code is quite generic
-    :parent => Puppet::Provider::Package) do
+  # T'is funny business, this code is quite generic
+  :parent => Puppet::Provider::Package) do
 
   desc "Use mysql as database."
   commands :mysql => '/usr/bin/mysql'
index b01bb836111176953d3b1f90036cfafef3c31d90..0ba929f9bbbc33601a447c103f1d778a9f2f1d73 100644 (file)
@@ -1,7 +1,10 @@
 # This has to be a separate type to enable collecting
 Puppet::Type.newtype(:mysql_database) do
   @doc = "Manage a database."
+
   ensurable
+  autorequire(:service) { 'mysql' }
+
   newparam(:name) do
     desc "The name of the database."
 
index 55d97b6b8ab38f03124b4998b57441b4fcd50ed0..0b7e9af4e52cbd072998ac86028c55d33105c9a8 100644 (file)
@@ -1,7 +1,10 @@
 # This has to be a separate type to enable collecting
 Puppet::Type.newtype(:mysql_user) do
   @doc = "Manage a database user."
+
   ensurable
+  autorequire(:service) { 'mysqld' }
+
   newparam(:name) do
     desc "The name of the user. This uses the 'username@hostname' form."