summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/facter/mysql.rb8
-rw-r--r--lib/facter/mysql_exists.rb5
-rw-r--r--lib/facter/mysql_version.rb6
-rw-r--r--lib/puppet/provider/mysql_user/mysql.rb4
-rw-r--r--lib/puppet/type/mysql_database.rb3
-rw-r--r--lib/puppet/type/mysql_user.rb3
6 files changed, 19 insertions, 10 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
diff --git a/lib/puppet/provider/mysql_user/mysql.rb b/lib/puppet/provider/mysql_user/mysql.rb
index e04d7e6..3051681 100644
--- a/lib/puppet/provider/mysql_user/mysql.rb
+++ b/lib/puppet/provider/mysql_user/mysql.rb
@@ -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'
diff --git a/lib/puppet/type/mysql_database.rb b/lib/puppet/type/mysql_database.rb
index b01bb83..0ba929f 100644
--- a/lib/puppet/type/mysql_database.rb
+++ b/lib/puppet/type/mysql_database.rb
@@ -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."
diff --git a/lib/puppet/type/mysql_user.rb b/lib/puppet/type/mysql_user.rb
index 55d97b6..0b7e9af 100644
--- a/lib/puppet/type/mysql_user.rb
+++ b/lib/puppet/type/mysql_user.rb
@@ -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."