+++ /dev/null
-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
--- /dev/null
+Facter.add("mysql_exists") do
+ setcode do
+ File.exist? '/usr/bin/mysql'
+ end
+end
--- /dev/null
+Facter.add("mysql_version") do
+ confine :mysql_exists => true
+ setcode do
+ Facter::Util::Resolution.exec('mysql --version').chomp.split(' ')[4].split(',').first
+ end
+end
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'
# 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."
# 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."