diff options
author | drebs <drebs@riseup.net> | 2015-06-05 15:53:26 -0300 |
---|---|---|
committer | drebs <drebs@riseup.net> | 2015-06-05 15:53:26 -0300 |
commit | 494241a212d7db9cf576adf9b06c01458e65ecb5 (patch) | |
tree | d7fb652f7332ca277a439518cd293aa38ba06e50 /lib/puppet | |
parent | 59fe3f1d51aa0ac1c5fd7029ecce7da7e1c6aafd (diff) | |
download | puppet-mysql-494241a212d7db9cf576adf9b06c01458e65ecb5.tar.gz puppet-mysql-494241a212d7db9cf576adf9b06c01458e65ecb5.tar.bz2 |
add conf file to provider commandsadapt-to-jessie
Diffstat (limited to 'lib/puppet')
-rw-r--r-- | lib/puppet/provider/mysql_database/mysql.rb | 10 | ||||
-rw-r--r-- | lib/puppet/provider/mysql_grant/mysql.rb | 24 | ||||
-rw-r--r-- | lib/puppet/provider/mysql_user/mysql.rb | 14 |
3 files changed, 24 insertions, 24 deletions
diff --git a/lib/puppet/provider/mysql_database/mysql.rb b/lib/puppet/provider/mysql_database/mysql.rb index 18b0a5a..fe21b79 100644 --- a/lib/puppet/provider/mysql_database/mysql.rb +++ b/lib/puppet/provider/mysql_database/mysql.rb @@ -11,7 +11,7 @@ Puppet::Type.type(:mysql_database).provide(:mysql, def self.instances dbs = [] - cmd = "#{command(:mysql)} mysql -NBe 'show databases'" + cmd = "#{command(:mysql)} --defaults-extra-file=/root/.my.cnf mysql -NBe 'show databases'" execpipe(cmd) do |process| process.each do |line| dbs << new( { :ensure => :present, :name => line.chomp } ) @@ -26,7 +26,7 @@ Puppet::Type.type(:mysql_database).provide(:mysql, :ensure => :absent } - cmd = "#{command(:mysql)} mysql -NBe 'show databases'" + cmd = "#{command(:mysql)} --defaults-extra-file=/root/.my.cnf mysql -NBe 'show databases'" execpipe(cmd) do |process| process.each do |line| if line.chomp.eql?(@resource[:name]) @@ -38,14 +38,14 @@ Puppet::Type.type(:mysql_database).provide(:mysql, end def create - mysqladmin "create", @resource[:name] + mysqladmin "--defaults-extra-file=/root/.my.cnf", "create", @resource[:name] end def destroy - mysqladmin "-f", "drop", @resource[:name] + mysqladmin "--defaults-extra-file=/root/.my.cnf", "-f", "drop", @resource[:name] end def exists? - if mysql("mysql", "-NBe", "show databases").match(/^#{@resource[:name]}$/) + if mysql("--defaults-extra-file=/root/.my.cnf ", "mysql", "-NBe", "show databases").match(/^#{@resource[:name]}$/) true else false 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 diff --git a/lib/puppet/provider/mysql_user/mysql.rb b/lib/puppet/provider/mysql_user/mysql.rb index 3051681..52c9f0a 100644 --- a/lib/puppet/provider/mysql_user/mysql.rb +++ b/lib/puppet/provider/mysql_user/mysql.rb @@ -12,7 +12,7 @@ Puppet::Type.type(:mysql_user).provide(:mysql, def self.instances users = [] - cmd = "#{command(:mysql)} mysql -NBe 'select concat(user, \"@\", host), password from user'" + cmd = "#{command(:mysql)} --defaults-extra-file=/root/.my.cnf mysql -NBe 'select concat(user, \"@\", host), password from user'" execpipe(cmd) do |process| process.each do |line| users << new( query_line_to_hash(line) ) @@ -31,13 +31,13 @@ Puppet::Type.type(:mysql_user).provide(:mysql, end def mysql_flush - mysqladmin "flush-privileges" + mysqladmin "--defaults-extra-file=/root/.my.cnf", "flush-privileges" end def query result = {} - cmd = "#{command(:mysql)} mysql -NBe 'select concat(user, \"@\", host), password from user where concat(user, \"@\", host) = \"%s\"'" % @resource[:name] + cmd = "#{command(:mysql)} --defaults-extra-file=/root/.my.cnf mysql -NBe 'select concat(user, \"@\", host), password from user where concat(user, \"@\", host) = \"%s\"'" % @resource[:name] execpipe(cmd) do |process| process.each do |line| unless result.empty? @@ -51,17 +51,17 @@ Puppet::Type.type(:mysql_user).provide(:mysql, end def create - mysql "mysql", "-e", "create user '%s' identified by PASSWORD '%s'" % [ @resource[:name].sub("@", "'@'"), @resource.should(:password_hash) ] + mysql "--defaults-extra-file=/root/.my.cnf", "mysql", "-e", "create user '%s' identified by PASSWORD '%s'" % [ @resource[:name].sub("@", "'@'"), @resource.should(:password_hash) ] mysql_flush end def destroy - mysql "mysql", "-e", "drop user '%s'" % @resource[:name].sub("@", "'@'") + mysql "--defaults-extra-file=/root/.my.cnf", "mysql", "-e", "drop user '%s'" % @resource[:name].sub("@", "'@'") mysql_flush end def exists? - not mysql("mysql", "-NBe", "select '1' from user where CONCAT(user, '@', host) = '%s'" % @resource[:name]).empty? + not mysql("--defaults-extra-file=/root/.my.cnf", "mysql", "-NBe", "select '1' from user where CONCAT(user, '@', host) = '%s'" % @resource[:name]).empty? end def password_hash @@ -69,7 +69,7 @@ Puppet::Type.type(:mysql_user).provide(:mysql, end def password_hash=(string) - mysql "mysql", "-e", "SET PASSWORD FOR '%s' = '%s'" % [ @resource[:name].sub("@", "'@'"), string ] + mysql "--defaults-extra-file=/root/.my.cnf", "mysql", "-e", "SET PASSWORD FOR '%s' = '%s'" % [ @resource[:name].sub("@", "'@'"), string ] mysql_flush end end |