Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add mysql argument to use mysql database back

  • Loading branch information...
commit 64d38890c696c3d09e9dded648b58872926b04f0 1 parent 24444ce
@hunner hunner authored
View
8 lib/puppet/provider/database_grant/mysql.rb
@@ -87,7 +87,7 @@ def create_row
end
def destroy
- mysql "--defaults-file=#{Facter.value(:root_home)}/.my.cnf", "-e", "REVOKE ALL ON '%s'.* FROM '%s@%s'" % [ @resource[:privileges], @resource[:database], @resource[:name], @resource[:host] ]
+ mysql "--defaults-file=#{Facter.value(:root_home)}/.my.cnf", "mysql", "-e", "REVOKE ALL ON '%s'.* FROM '%s@%s'" % [ @resource[:privileges], @resource[:database], @resource[:name], @resource[:host] ]
end
def row_exists?
@@ -96,7 +96,7 @@ def row_exists?
if name[:type] == :db
fields << :db
end
- not mysql("--defaults-file=#{Facter.value(:root_home)}/.my.cnf", 'mysql', '-NBe', 'SELECT "1" FROM %s WHERE %s' % [ name[:type], fields.map do |f| "%s=\"%s\"" % [f, name[f]] end.join(' AND ')]).empty?
+ not mysql("--defaults-file=#{Facter.value(:root_home)}/.my.cnf", "mysql", '-NBe', 'SELECT "1" FROM %s WHERE %s' % [ name[:type], fields.map do |f| "%s=\"%s\"" % [f, name[f]] end.join(' AND ')]).empty?
end
def all_privs_set?
@@ -118,9 +118,9 @@ def privileges
case name[:type]
when :user
- privs = mysql "--defaults-file=#{Facter.value(:root_home)}/.my.cnf", "-Be", 'select * from mysql.user where user="%s" and host="%s"' % [ name[:user], name[:host] ]
+ privs = mysql "--defaults-file=#{Facter.value(:root_home)}/.my.cnf", "mysql", "-Be", 'select * from mysql.user where user="%s" and host="%s"' % [ name[:user], name[:host] ]
when :db
- privs = mysql "--defaults-file=#{Facter.value(:root_home)}/.my.cnf", "-Be", 'select * from mysql.db where user="%s" and host="%s" and db="%s"' % [ name[:user], name[:host], name[:db] ]
+ privs = mysql "--defaults-file=#{Facter.value(:root_home)}/.my.cnf", "mysql", "-Be", 'select * from mysql.db where user="%s" and host="%s" and db="%s"' % [ name[:user], name[:host], name[:db] ]
end
if privs.match(/^$/)
View
12 lib/puppet/provider/database_user/mysql.rb
@@ -8,30 +8,30 @@
optional_commands :mysqladmin => 'mysqladmin'
def self.instances
- users = mysql("--defaults-file=#{Facter.value(:root_home)}/.my.cnf", '-BNe' "select concat(User, '@',Host) as User from mysql.user").split("\n")
+ users = mysql("--defaults-file=#{Facter.value(:root_home)}/.my.cnf", "mysql", '-BNe' "select concat(User, '@',Host) as User from mysql.user").split("\n")
users.select{ |user| user =~ /.+@/ }.collect do |name|
new(:name => name)
end
end
def create
- mysql("--defaults-file=#{Facter.value(:root_home)}/.my.cnf", "-e", "create user '%s' identified by PASSWORD '%s'" % [ @resource[:name].sub("@", "'@'"), @resource.value(:password_hash) ])
+ mysql("--defaults-file=#{Facter.value(:root_home)}/.my.cnf", "mysql", "-e", "create user '%s' identified by PASSWORD '%s'" % [ @resource[:name].sub("@", "'@'"), @resource.value(:password_hash) ])
end
def destroy
- mysql("--defaults-file=#{Facter.value(:root_home)}/.my.cnf", "-e", "drop user '%s'" % @resource.value(:name).sub("@", "'@'") )
+ mysql("--defaults-file=#{Facter.value(:root_home)}/.my.cnf", "mysql", "-e", "drop user '%s'" % @resource.value(:name).sub("@", "'@'") )
end
def password_hash
- mysql("--defaults-file=#{Facter.value(:root_home)}/.my.cnf", "-NBe", "select password from mysql.user where CONCAT(user, '@', host) = '%s'" % @resource.value(:name)).chomp
+ mysql("--defaults-file=#{Facter.value(:root_home)}/.my.cnf", "mysql", "-NBe", "select password from mysql.user where CONCAT(user, '@', host) = '%s'" % @resource.value(:name)).chomp
end
def password_hash=(string)
- mysql("--defaults-file=#{Facter.value(:root_home)}/.my.cnf", "-e", "SET PASSWORD FOR '%s' = '%s'" % [ @resource[:name].sub("@", "'@'"), string ] )
+ mysql("--defaults-file=#{Facter.value(:root_home)}/.my.cnf", "mysql", "-e", "SET PASSWORD FOR '%s' = '%s'" % [ @resource[:name].sub("@", "'@'"), string ] )
end
def exists?
- not mysql("--defaults-file=#{Facter.value(:root_home)}/.my.cnf", "-NBe", "select '1' from mysql.user where CONCAT(user, '@', host) = '%s'" % @resource.value(:name)).empty?
+ not mysql("--defaults-file=#{Facter.value(:root_home)}/.my.cnf", "mysql", "-NBe", "select '1' from mysql.user where CONCAT(user, '@', host) = '%s'" % @resource.value(:name)).empty?
end
def flush
View
6 spec/unit/puppet/provider/database_grant/mysql_spec.rb
@@ -40,7 +40,7 @@
end
it 'should query set priviliges' do
- provider_class.expects(:mysql).with("--defaults-file=#{root_home}/.my.cnf", '-Be', 'select * from mysql.user where user="user" and host="host"').returns <<-EOT
+ provider_class.expects(:mysql).with("--defaults-file=#{root_home}/.my.cnf", 'mysql', '-Be', 'select * from mysql.user where user="user" and host="host"').returns <<-EOT
Host User Password Select_priv Insert_priv Update_priv
host user Y N Y
EOT
@@ -48,7 +48,7 @@
end
it 'should recognize when all priviliges are set' do
- provider_class.expects(:mysql).with("--defaults-file=#{root_home}/.my.cnf", '-Be', 'select * from mysql.user where user="user" and host="host"').returns <<-EOT
+ provider_class.expects(:mysql).with("--defaults-file=#{root_home}/.my.cnf", 'mysql', '-Be', 'select * from mysql.user where user="user" and host="host"').returns <<-EOT
Host User Password Select_priv Insert_priv Update_priv
host user Y Y Y
EOT
@@ -56,7 +56,7 @@
end
it 'should recognize when all privileges are not set' do
- provider_class.expects(:mysql).with("--defaults-file=#{root_home}/.my.cnf", '-Be', 'select * from mysql.user where user="user" and host="host"').returns <<-EOT
+ provider_class.expects(:mysql).with("--defaults-file=#{root_home}/.my.cnf", 'mysql', '-Be', 'select * from mysql.user where user="user" and host="host"').returns <<-EOT
Host User Password Select_priv Insert_priv Update_priv
host user Y N Y
EOT
Please sign in to comment.
Something went wrong with that request. Please try again.