From 494241a212d7db9cf576adf9b06c01458e65ecb5 Mon Sep 17 00:00:00 2001 From: drebs Date: Fri, 5 Jun 2015 15:53:26 -0300 Subject: add conf file to provider commands --- lib/puppet/provider/mysql_grant/mysql.rb | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'lib/puppet/provider/mysql_grant') diff --git a/lib/puppet/provider/mysql_grant/mysql.rb b/lib/puppet/provider/mysql_grant/mysql.rb index f666788..74aa2a9 100644 --- a/lib/puppet/provider/mysql_grant/mysql.rb +++ b/lib/puppet/provider/mysql_grant/mysql.rb @@ -55,7 +55,7 @@ Puppet::Type.type(:mysql_grant).provide(:mysql) do commands :mysqladmin => '/usr/bin/mysqladmin' def mysql_flush - mysqladmin "flush-privileges" + mysqladmin "--defaults-extra-file=/root/.my.cnf", "flush-privileges" end # this parses the @@ -101,15 +101,15 @@ Puppet::Type.type(:mysql_grant).provide(:mysql) do name = split_name(@resource[:name]) case name[:type] when :user - mysql "mysql", "-e", "INSERT INTO user (host, user) VALUES ('%s', '%s')" % [ + mysql "--defaults-extra-file=/root/.my.cnf", "mysql", "-e", "INSERT INTO user (host, user) VALUES ('%s', '%s')" % [ name[:host], name[:user], ] when :db - mysql "mysql", "-e", "INSERT INTO db (host, user, db) VALUES ('%s', '%s', '%s')" % [ + mysql "--defaults-extra-file=/root/.my.cnf", "mysql", "-e", "INSERT INTO db (host, user, db) VALUES ('%s', '%s', '%s')" % [ name[:host], name[:user], name[:db], ] when :column - mysql "mysql", "-e", "INSERT INTO columns_priv (host, user, db, table, column_name) VALUES ('%s', '%s', '%s', '%s', '%s')" % [ + mysql "--defaults-extra-file=/root/.my.cnf", "mysql", "-e", "INSERT INTO columns_priv (host, user, db, table, column_name) VALUES ('%s', '%s', '%s', '%s', '%s')" % [ name[:host], name[:user], name[:db], name[:table], name[:column], ] end @@ -118,7 +118,7 @@ Puppet::Type.type(:mysql_grant).provide(:mysql) do end def destroy - mysql "mysql", "-e", "REVOKE ALL ON '%s'.* FROM '%s@%s'" % [ @resource[:privileges], @resource[:database], @resource[:name], @resource[:host] ] + mysql "--defaults-extra-file=/root/.my.cnf", "mysql", "-e", "REVOKE ALL ON '%s'.* FROM '%s@%s'" % [ @resource[:privileges], @resource[:database], @resource[:name], @resource[:host] ] end def row_exists? @@ -130,7 +130,7 @@ Puppet::Type.type(:mysql_grant).provide(:mysql) do if name[:type] == :column fields << :column end - not mysql( "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-extra-file=/root/.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? @@ -156,15 +156,15 @@ Puppet::Type.type(:mysql_grant).provide(:mysql) do case name[:type] when :user - privs = mysql "mysql", "-Be", 'select * from user where user="%s" and host="%s"' % [ name[:user], name[:host] ] + privs = mysql "--defaults-extra-file=/root/.my.cnf", "mysql", "-Be", 'select * from user where user="%s" and host="%s"' % [ name[:user], name[:host] ] when :db - privs = mysql "mysql", "-Be", 'select * from db where user="%s" and host="%s" and db="%s"' % [ name[:user], name[:host], name[:db] ] + privs = mysql "--defaults-extra-file=/root/.my.cnf", "mysql", "-Be", 'select * from db where user="%s" and host="%s" and db="%s"' % [ name[:user], name[:host], name[:db] ] when :tables_priv - privs = mysql "mysql", "-NBe", 'select Table_priv from tables_priv where User="%s" and Host="%s" and Db="%s" and Table_name="%s"' % [ name[:user], name[:host], name[:db], name[:table_name] ] + privs = mysql "--defaults-extra-file=/root/.my.cnf", "mysql", "-NBe", 'select Table_priv from tables_priv where User="%s" and Host="%s" and Db="%s" and Table_name="%s"' % [ name[:user], name[:host], name[:db], name[:table_name] ] privs = privs.chomp.downcase return privs when :columns - privs = mysql "mysql", "-Be", 'select * from columns_priv where User="%s" and Host="%s" and Db="%s" and Table_name="%s" and Column_name="%s"' % [ name[:user], name[:host], name[:db], name[:table], name[:column] ] + privs = mysql "--defaults-extra-file=/root/.my.cnf", "mysql", "-Be", 'select * from columns_priv where User="%s" and Host="%s" and Db="%s" and Table_name="%s" and Column_name="%s"' % [ name[:user], name[:host], name[:db], name[:table], name[:column] ] end if privs.match(/^$/) @@ -213,7 +213,7 @@ Puppet::Type.type(:mysql_grant).provide(:mysql) do if !revoke.empty? #puts "Revoking table privs: ", revoke - mysql "mysql", "-e", "REVOKE %s ON %s.%s FROM '%s'@'%s'" % [ revoke.join(", "), name[:db], name[:table_name], name[:user], name[:host] ] + mysql "--defaults-extra-file=/root/.my.cnf", "mysql", "-e", "REVOKE %s ON %s.%s FROM '%s'@'%s'" % [ revoke.join(", "), name[:db], name[:table_name], name[:user], name[:host] ] end set = privs - currently_set @@ -245,7 +245,7 @@ Puppet::Type.type(:mysql_grant).provide(:mysql) do #puts "stmt:", stmt if !set.empty? - mysql "mysql", "-Be", stmt + mysql "--defaults-extra-file=/root/.my.cnf", "mysql", "-Be", stmt mysql_flush end end -- cgit v1.2.3