Skip to content

Commit

Permalink
Merge branch 'dbname_in_hostname'
Browse files Browse the repository at this point in the history
  • Loading branch information
justinellison committed Feb 2, 2012
2 parents 2981222 + 30b023c commit fa75781
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/puppet/provider/database_user/mysql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def create

def destroy
dbh = Puppet::Type.type(:database_user).provider(:mysql).connect
dbh.select_db('mysql').query("drop user '%s'" % @resource[:name].sub("@", "'@'"))
user = @resource[:name].sub(/^([^@]*)@([^\/]*)(\/(.*))?$/,'\1\'@\'\2')
dbh.select_db('mysql').query("drop user '%s'" % user)
dbh.reload
@property_hash[:ensure] = :absent
end
Expand All @@ -37,7 +38,8 @@ def password_hash

def password_hash=(string)
dbh = Puppet::Type.type(:database_user).provider(:mysql).connect
dbh.select_db('mysql').query("SET PASSWORD FOR '%s' = '%s'" % [ @resource[:name].sub("@", "'@'"), string ])
user = @resource[:name].sub(/^([^@]*)@([^\/]*)(\/(.*))?$/,'\1\'@\'\2')
dbh.select_db('mysql').query("SET PASSWORD FOR '%s' = '%s'" % [ user, string ])
dbh.reload
@property_hash[:password_hash] = string
end
Expand Down

0 comments on commit fa75781

Please sign in to comment.