diff --git a/lib/puppet/provider/mysql_user/mysql.rb b/lib/puppet/provider/mysql_user/mysql.rb index 0c2d442..f05a606 100644 --- a/lib/puppet/provider/mysql_user/mysql.rb +++ b/lib/puppet/provider/mysql_user/mysql.rb @@ -1,4 +1,5 @@ -Puppet::Type.type(:mysql_user).provide(:mysql) do +require File.expand_path(File.join(File.dirname(__FILE__), '..', 'mysql')) +Puppet::Type.type(:mysql_user).provide(:mysql, :parent => Puppet::Provider::Mysql) do desc 'manage users for a mysql database.' commands :mysql => 'mysql' @@ -22,7 +23,7 @@ Puppet::Type.type(:mysql_user).provide(:mysql) do "SELECT CONCAT(User, '@',Host) AS User FROM mysql.user"].compact).split("\n") # To reduce the number of calls to MySQL we collect all the properties in # one big swoop. - users.select{ |user| user =~ /.+@/ }.collect do |name| + users.collect do |name| query = "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, PASSWORD FROM mysql.user WHERE CONCAT(user, '@', host) = '#{name}'" @max_user_connections, @max_connections_per_hour, @max_queries_per_hour, @max_updates_per_hour, @password = mysql([defaults_file, "-NBe", query].compact).split(/\s/) diff --git a/spec/unit/puppet/provider/mysql_user/mysql_spec.rb b/spec/unit/puppet/provider/mysql_user/mysql_spec.rb index f9ba34a..eebe5cb 100644 --- a/spec/unit/puppet/provider/mysql_user/mysql_spec.rb +++ b/spec/unit/puppet/provider/mysql_user/mysql_spec.rb @@ -16,7 +16,7 @@ usvn_user@localhost SQL_OUTPUT end - let(:parsed_users) { %w(root@127.0.0.1 root@::1 debian-sys-maint@localhost root@localhost usvn_user@localhost) } + let(:parsed_users) { %w(root@127.0.0.1 root@::1 @localhost debian-sys-maint@localhost root@localhost usvn_user@localhost @vagrant-ubuntu-raring-64) } let(:resource) { Puppet::Type.type(:mysql_user).new( { :ensure => :present,