Commit graph

49 commits

Author SHA1 Message Date
Frederik Wagner
bbbc6cd446 (MODULES-1330) Change order of revokation 2014-09-16 14:06:26 +02:00
Ashley Penney
bb205ad2f0 Remove all the deprecated code. 2014-08-08 14:13:22 -04:00
Ray Lehtiniemi
548952a6f9 Prevent ERROR 1008 in mysql_database provider
Check for database existence when dropping to prevent

  ERROR 1008 (HY000): Can't drop database 'test'; database doesn't exist

Signed-off-by: Ray Lehtiniemi <rayl@mail.com>
2014-07-23 21:41:16 -06:00
jsosic
356672342e Fix problem with GRANT not recognizing backslash
If database grant has backslash in database name (for example: example\_dev), then puppet will try to apply same resource every run because MySQL reports that table name with double backslash (for example: example\\_dev). By global replace of double backslash with single one, this issue is fixed.
2014-07-13 04:01:53 +02:00
Jaakko
3cfbb581cc Change grant provider to ignore grants for non existing users.
In the grant provider users are fetched by querying mysql.user table. Grants
for those users are fetched using show grants for... syntax. This can lead to
errors, when some of the users in mysql.user table do not have currently
active grants.

This happens at least when MySQL is started with --skip-name-resolve option,
when there are users with the hostname part specified as a FQDN. Such users are
created by mysql_install_db. This leads to problems if mysql::account_security
is included for the node and skip-name-resolve is specified in override_options
hash for mysql::server.

Includes acceptance test for the change.
2014-06-17 13:07:56 +02:00
Ashley Penney
30ce3e0e12 Repair this by ensuring calls to mysql include the database name.
A prior commit accidently broke this, meaning that mysql_database
was querying the mysql defaults instead of each individual database
when trying to determine the current collate settings.
2014-02-18 14:38:21 -05:00
Steve Saliman
21aca48e02 fixed a problem with the mysql_database provider 2014-01-22 12:44:59 -07:00
Dejan Golja
ce7b661f10 Bugfix for mysql_grant provider when we try to grant remove privileges
on PROCEDURE. Resolve for bug https://tickets.puppetlabs.com/browse/MODULES-130
(https://github.com/puppetlabs/puppetlabs-mysql/issues/378)
2014-01-20 23:56:26 +11:00
Srinath M
1cc07977c5 Added [if not exists] to [create database] clause.
this should avoid errors like:
ERROR 1007 (HY000): Can't create database 'MyDB'; database exists

This error can cause a multi-master replication to stop due to conflicting
commands between nodes. For  example, if the command create DB is run in
 different nodes and then they will send it in the replication logs to each
other and then they will try to run them second time and fail.
2013-12-15 21:47:10 -05:00
Reinhard Vicinus
9de42ac43e mysql_grant bugfix: REVOKE ALL PRIVILEGES doesn't revoke GRANT OPTION 2013-12-11 13:16:14 +01:00
Reinhard Vicinus
f5a78f1c5f mysql_grant bugfix: on table *.* SHOW GRANT can return 'WITH MAX_QUERIES_PER_HOUR' which breaks the captures on the match 2013-12-11 13:15:21 +01:00
Tamas Szasz
fbfc5d831f defaults_file methods removed from every provider (old & new) and moved
the method to the global mysql.rb which is now included in every provider
file.

Class from the global mysql.rb file is a parent of every provider.
2013-11-16 19:09:09 +01:00
Tamas Szasz
4ac8879734 Fixed missing parent for global mysql class
Added "require" to the global mysql.rb file like in the other provider files.

defaults-file changed to defaults-extra-file in all the database_* (old) providers, the same as in the mysql_* providers.

Changed defaults-file to defaults-extra-file in all test files
2013-11-12 21:32:41 +01:00
w32-blaster
e315ee96d0 Changed defaults-file to defaults-extra-file
Should load the .my.cnf file with "--defaults-extra-file" instead of "--defaults-file". This is necessary if we have global my.cnf file but we want to use both of them.
2013-11-11 18:48:00 +01:00
Ashley Penney
c6647c46b3 Fix ordering causing mysql_grant to reapply.
Because arrays are ordered lists, Puppet compares the list of retrieved
privileges against the defined privilege list.  This causes it to
reapply privilege if the ordering differs.  We now forcibly order in
the type and the provider to make sure we never falsely reapply
privileges.
2013-10-20 12:40:18 -04:00
Ashley Penney
09f42c8bb3 Further improvements to our matching - stop trying to guess what
might be the username or hostname and just match the entire thing
no matter what it may be.
2013-10-10 13:48:24 -07:00
Ashley Penney
93aab36804 Previously we were matching to ensure that usernames matched
user@host but MySQL allows you to use @host with a blank user.

No longer .select but allow all and remove these successfully.
2013-10-08 10:12:46 -07:00
Ashley Penney
cc51d7ad7d Improve mysql_grant to work with IPv6.
This work attempts to improve the situation for matching IPv6
IP addresses, as the previous regex couldn't handle them properly.
2013-10-07 11:57:02 -07:00
Ashley Penney
f8af684fe0 Merge pull request #276 from apenney/mysql_grant_fixes
Improvements to mysql_grant.
2013-10-02 09:54:09 -07:00
Nate Riffe
aef9fd0912 Add collation with the create statement 2013-09-29 09:39:06 -05:00
Ashley Penney
003d5b3c6a Improvements to mysql_grant.
Ensure that table and user are required properties, as well as remove
the optional table handling in the provider and enforce it.
2013-09-24 15:37:11 -04:00
Ashley Penney
a972e4d3a0 Merge pull request #258 from apenney/refactor
Completely redesign the MySQL module.
2013-09-23 14:05:08 -07:00
Pan
58b7dc2c87 Add quote to username and host in mysql_grant constructor
The quote is need for username and host in mysql grant. revoke and grant function is already doing it with cmd_user(). not sure why the constructor didn't do it. This patch fixed #261 and #262.
2013-09-18 17:04:36 -07:00
Ashley Penney
4d6962e868 Various adjustments to classes to align with refactored work.
Handful of changes here, such as removing flush (so that mysql_user
can be used for root password changes) and other tweaks here.

Add time option to mysql::backup.
2013-09-13 13:14:48 -04:00
Ashley Penney
2abccab4d9 Refactor and rename database_grant to mysql_grant.
This provider has undergone the largest set of changes and currently
just accepts a full SQL grant string as the name and then applies it,
making things easier for DBAs and removes the awkward attempts at
modelling grants into Puppet.
2013-09-03 17:24:21 -04:00
Ashley Penney
16770faa29 Rename and refactor database_user to mysql_user.
This work adds max_connections_per_hour, max_queries_per_hour, and
max_updates_per_hour support to the provider and extends self.instances to add
in the new parameters when checking existing users.  It also adds
self.prefetch in order to speed up Puppet runs.

Provider is also switched to using mk_resource_methods to generate
all the resource readers, and exists? and other methods now use the
property_hash where appropriate.

Tests rewritten to handle changes and extend code coverage.
2013-08-28 18:11:21 -04:00
Ashley Penney
7d4f9fc685 Rename and refactor database to mysql_database.
Add collate as a new managable parameter, and extend self.instances to
add in all parameters when checking existing databases.  It also adds
self.prefetch in order to speed up Puppet runs.

Provider is also switched to using mk_resource_methods to generate
all the resource readers, and exists? and other methods now use the
property_hash where appropriate.

Tests rewritten to handle changes and extend code coverage.
2013-08-28 18:11:21 -04:00
Ashley Penney
4d3f73b550 Fixes suggested by RubyMine. (style for the most part.) 2013-07-11 19:42:41 -04:00
Marius Bakke
dc2ec8101e allow setting max_user_connections during user creation 2013-07-10 10:07:56 +02:00
Marius Bakke
2548ab63e8 support max_user_connections in database_user 2013-07-08 17:31:07 +02:00
Ashley Penney
8bf03681f3 Various changes to the provider to ensure commands are successful,
as well as improvements to the tests.
2013-07-03 16:08:48 -04:00
Stuart Grimshaw
608e4e8f43 Fixed SQL for databse_grant and database_user when ANSI_QUOTES Mysql option is set. 2013-06-24 14:50:39 -07:00
Hunter Haugen
ca2b16c691 Patch providers for absent my.cnf
If the /root/.my.cnf file does not exist but is specified by the
`--defaults-file` argument, the mysql calls will fail. The
`mysql::config` class creates this file, but if the custom resources are
used without including our classes then it will still break.

This allows users to use our custom resources without having to use our
classes.
2013-01-10 15:31:21 -08:00
Olivier Bilodeau
8510a41bb3 fixed character-set detection regex
Previous regex matched COLLATE value instead of CHARACTER SET. For
example:

> CREATE DATABASE `test` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_bin */

Returned utf8_bin instead of utf8 causing an unfortunate database refresh in my
configuration. Fixed the regex by adding the optional presence of the COLLATE
keyword.
2012-12-11 12:56:57 -05:00
Hunter Haugen
64d38890c6 Add mysql argument to use mysql database back 2012-10-09 14:02:05 -07:00
Nate Riffe
bdb416053a Use root's credentials when executing mysql.
This is necessary when running puppet as root using sudo because mysql
will still look in the user's home directory in that case unless told
otherwise.
2012-10-09 13:59:58 -07:00
Reid Vandewiele
8dac527b2a Add priv validation to database_grant provider
The mysql database_grant provider currently has what is arguably a heinous
design flaw. At present:

 1. The 'privileges' parameter for the database_grant type, mysql provider,
    does not expect the same syntax as the mysql Grant command ('SELECT',
    'UPDATE', 'DELETE', etc). Rather, it expects the user to supply column
    names used to store raw grants in the mysql.db or mysql.user tables
    internally ('Select_priv', 'Update_priv', 'Delete_priv', etc).

 2. If a user supplies `privileges => [ 'SELECT', 'INSERT' ]` instead of
    `privileges => [ 'Select_priv', 'Insert_priv' ]`, the provider fails
    silently and will continuously attempt to update the privileges with
    each successive puppet run. In the specific example provided, all privs
    for the user/db will be set to false since e.g. 'INSERT' does not match
    any valid privilege.

Unfortunately it doesn't look simple to modify the provider such that the
intuitive SELECT, DELETE, etc. keywords can be used without changing
existing behavior. Leaving that alone for now, it *is* pretty simple to add
a validation function that will at least fail cleanly if non-functional
privilege values are supplied that don't mean anything to the provider. If
the user is trying to use valid MySQL Grant syntax, the new validation
procedure will recognize this and suggest a correction. Hopefully giving
users this kind of warning will clue them in to what kind of input the
provider expects.
2012-08-04 10:28:06 -07:00
Branan Purvine-Riley
66c17cd14c Merge pull request #82 from agerlic/escape_database_name
escape database name
2012-07-16 11:19:32 -07:00
Alexandre Gerlic
de0f749ea5 add missing db param to database_grant 2012-06-21 17:27:39 +02:00
Alexandre Gerlic
2817f362d5 escape database name 2012-06-20 23:58:34 +02:00
Rodrigo Menezes
f0f9e76db7 Default types hacks not needed.
Default types hacks not needed.
2012-05-22 16:50:46 -07:00
Branan Purvine-Riley
6a81a2f687 (#14316) make privileges case-insensitive 2012-05-04 10:04:46 -07:00
Branan Purvine-Riley
4485dbb95f Remove the global *_PRIVS variables 2012-05-01 17:00:46 -07:00
Dan Bode
015490c787 Fix bug when querying for all database users
This commit fixes an issue in self.instances of
database_user where none of the users were actually
being detected.

There was a accidental '\' in front of the '.' which 
means that it will only consider users that have
one or more '.' in front of the '@'.

This commit removes the '\' so that all users are
returned that have one or more characters in from
of an '@'.
2012-03-14 23:05:20 -07:00
Nan Liu
b1f90fd1d2 Major refactor of mysql module.
This is a major change to the module and would be released as a new
version.

* Add self.instances to database and database_user for puppet resource.
* Update database provider to use flush method.
* Update module to conform to puppet-lint recommendations.
* Cleanup some unecessary logic in mysql::db define type.
* Move mysql_restart to config class.
* Use class to class dependency instead of resource dependency.
* Change appropriate rspec-puppet tests.
* Add fixtures directory to simplify testing.
* Update raketask and spec_helper to reflect fixture changes.
* Update mysql_password function to support validation.
* Move client installation to a separate class.
* Update documentation and readme.
2012-03-13 15:19:53 -07:00
Matthias Pigulla
d15c9d1621 (#11363) Add two missing privileges to grant: event_priv, trigger_priv
These were missing from the list of allowed privileges:

* event_priv
* trigger_priv

No rspec changes, as we don't even have basic coverage on these providers and
its a minor change so should be low risk.
2011-12-30 16:33:21 +00:00
Matthias Pigulla
b0ff433860 Fix (#10882) by making all commands optional. 2011-11-16 16:49:31 +01:00
Dan Bode
4774c63435 Database should set charset on create.
Previously, the charset of the database was not
being set on create, causing puppet to have to
potentially run twice to update it.
2011-06-16 21:57:06 -07:00
Dan Bode
d28f0e0327 adding first commit for mysql. 2011-05-24 23:22:43 -07:00