Commit graph

81 commits

Author SHA1 Message Date
Helen Campbell
2a888f714d Fix for mysql version retrieval 2016-07-21 15:55:49 +01:00
Jon Topper
ec5450ec75 Use facts for mysqld version discovery
Per https://tickets.puppetlabs.com/browse/MODULES-3441, the mysql
module has behaviour which varies by server version. The version is
discovered by running mysqld -V. On hosts without a MySQL server
package install, this fails, which means that contrary to the README,
it's not actually possible to use this module to manage a remote db.

This PR moves the version string discovery into a new fact,
mysqld_version which is used by the provider. This makes it possible
to configure the db version with a custom fact when a remote db
(eg AWS RDS) is being managed.
2016-06-15 10:43:50 +02:00
Jarosław Jagodziński
7d2ab4e921 Find MySQL 5.5 installation on CentOS #832
MySQL from CentOS SCL repository is installed in different location. You should also check for binaries in this location.
Without this change puppet returns error like: Could not find a suitable provider for mysql_datadir
2016-05-23 12:17:09 +02:00
Arkadiusz Dzięgiel
41e4753bd2 Support mysql_install_db script on Gentoo
On Gentoo, mysql_install_db script is installed into /usr/share/mysql/scripts
and therefore is not found by mysql_datadir type.
This commit adds scripts path to ENV['PATH'] so it can be found.
2016-05-19 12:20:51 +02:00
JT (Jonny)
3e3cd55e04 Merge pull request #830 from fvanboven/module-2111-replication
(MODULES-2111) Add the system database to user related actions.
2016-05-10 11:30:28 +01:00
JT (Jonny)
13a8d807d5 Merge pull request #828 from s-t-e-v-e-n-k/mysql-type-xenial
Remove mysql regex when checking type
2016-05-09 18:39:07 +01:00
Al Wiesner
06fe1f9abb Check that /var/lib/mysql actually contains files.
MySQL-server-advanced installs install the 'mysql' directory in /var/lib/mysql by default,
therefore the check fails and does not run mysql_install_db.
Check is adjusted to check if any files exist in the directory.
2016-05-09 18:35:48 +01:00
Frank Wall
e52a669410 make sure we find mysql commands on FreeBSD 2016-05-06 01:45:46 +02:00
Frank van Boven
b8d301527e (MODULES-2111) Add the system database to user related tables.
Change the behaviour of applying user and grant related changes to use
the system database of MySQL.

This is a workaround to fix a bug in MySQL
(https://bugs.mysql.com/bug.php?id=65923) that causes users and grants
to be replicated, even if the "mysql" database should not be replicated.
2016-05-02 14:52:44 +02:00
Steve Kowalik
c63e318df8 Remove mysql regex when checking type
Since the default MySQL return type is 'mysql', only check for MariaDB
and Percona specially.
2016-04-29 14:40:30 -05:00
Hunter Haugen
2603411dac Merge pull request #824 from ih84ds/patch-1
Default mysqld_type should be "mysql"
2016-04-25 16:29:21 -07:00
Monty Solomon
d472d5bcf1 Use defaults_extra_file first; add debug messages
Remove added notices and revert to debug

Add support for Percona

Use log-error for mysqld initialize

Improve description of error log argument

Should be --log-error
2016-04-21 01:00:40 -04:00
ih84ds
5695cef4a6 Default mysqld_type should be "mysql"
Default mysqld_type return value should be "mysql" if another type is not detected. Returning nil breaks mysql 5.7.11 on Ubuntu (at least) due to the conditional used in mysql_user provider.
2016-04-14 17:55:22 -05:00
Jakub Husak
1a67c3868b Loosen MariaDB recognition to fix it on Debian 8 2016-03-18 16:26:48 +01:00
Jim Riggs
31c17b0484 (#3028) Fix mysql_grant with MySQL ANSI_QUOTES mode
Change mysql_grant provider to ignore/delete double-quotes -- as it does with single quotes and backticks -- in the returned list of existing grants. With ANSI_QUOTES enabled in MySQL's sql_mode, grant identifiers (e.g. database name) are quoted with double-quotes rather than backticks, for example "foo".* vs. `foo`.*. This breaks mysql_grant's evaluation of existing grants and causes it to apply grants with every run.
2016-02-03 08:21:07 -06:00
Igor Galić
23672ca326 Merge pull request #779 from jmcclell/patch-1
Fixes edge-case with dropping pre-existing users with grants
2016-01-15 16:00:31 +01:00
Jason McClellan (dsc)
1bad8ae56a Fixes edge-case with dropping pre-existing users with grants
If a user exists in the database upon first Puppet run (for example, in the case of loading a database snapshot) and the run sets that user's :ensure attribute to 'absent', the mysql_grant provider will throw an error when the dependency chain causes it to try to destroy the grants associated with that user because the DROP statement from the mysql_user provider already removed the grants. To fix, we must check if the user exists before revoking the grants.
2016-01-15 08:14:12 -05:00
Robert Heinzmann
7efc93c3c5 Fixed new mysql_datadir provider on CentOS for MySQl 5.7.6 compatibility 2015-12-17 18:31:17 +01:00
Robert Heinzmann
bdf4d0f52d Fixed MySQL 5.7.6++ compatibility
- Added MySQL version and flavour detection support
  - Added mysql_datadir provider/type (replaces Exec[mysql_install_db])
  - Added version specific parameters my.cnf ([mysqld-5.X] sections)
  - Version specific user mangement SQL (ALTER USER for 5.7.6++ ...)

Rebased-By: David Schmitt <david.schmitt@puppetlabs.com>
2015-12-10 18:39:40 +00:00
Roman Mueller
afddc3ff7b Fix fetching the mysql_user password for MySQL >=5.7.6
The password column has been renamed to authentication_string in MySQL >=5.7.6.
By using: SELECT /*!50706 AUTHENTICATION_STRING AS */ PASSWORD the query will
continue to work in older versions as well as newer ones.
2015-09-30 18:55:26 +02:00
Artur Gadelshin
35c75b79bb MODULES-1981: Revoke and grant difference of old and new privileges 2015-05-04 16:07:10 +03:00
Hunter Haugen
b3a38a8dfe Merge pull request #645 from dveeden/auth-plugins
Support authentication plugins
2015-02-06 12:40:49 -08:00
Daniël van Eeden
74132ec038 Add type & provider for managing plugins 2015-01-26 15:03:45 +01:00
Daniël van Eeden
367fcf06af Support authentication plugins
This uses CREATE USER xxx IDENTIFIED WITH yyy

For tests:
 unix_socket is not loaded by default, so this might require:
 install plugin unix_socket soname 'auth_socket.so';

 The mysql_native_password plugin is available by default and
 allows you to also set a password.

Try to make it compatible with MySQL < 5.5.7 it uses version
specific code with "/*!50508 stmt */"
2015-01-24 17:28:17 +01:00
Colleen Murphy
ccf37e7c8d Revert "Support for authentication plugins" 2015-01-22 11:27:41 -08:00
Daniël van Eeden
305b0d2a87 Support authentication plugins
This uses CREATE USER xxx IDENTIFIED WITH yyy

For tests:
 unix_socket is not loaded by default, so this might require:
 install plugin unix_socket soname 'auth_socket.so';

 The mysql_native_password plugin is available by default and
 allows you to also set a password.
2015-01-17 18:41:37 +01:00
Scott Kroll
9dbdd89c7a Fix escaped backslashes in grants
* Mysql uses the underscore character to represent a single character
  wildcard.
* A grant on table `the_database`.* would match `theAdatabase`.*, so
  underscores must be escaped to avoid this match.
* The output from mysql escapes special characters (\n, \t, \0, and \\),
  but the input does not need to be escaped.
* In order for the provider to compare the tables, the output of
  mysql -NBe <query> must have \\ substituted with \.
2014-11-05 14:53:14 -05:00
Maxence Dunnewind
46065c4095 The old regex requires something after the 'host' part. Fix this.
Old regex is : /^GRANT\s(.+)\sON\s(.+)\sTO\s(.*)@(.*?)(\s.*)$/ . The
last part (\s.*)$ means "a space followed by anything". The issue is
that when user has no GRANT privileges, the "SHOW GRANTS FOR #{user_string}" returns
"GRANT SELECT ON `database`.* TO 'user'@'%'" which does not match (\s.*)$ .
This small patch fixes this making last bloc optional (thanks to '?').
2014-10-27 16:41:33 +01:00
Igor Galić
400d3b29cf Merge pull request #570 from fnerdwq/mysql_grant_column_privs
(MODULES-552) Add capability to specify column_privileges
2014-10-07 15:46:08 +02:00
Frederik Wagner
f88719b52f (MODULES-552) Add capability to specify column_privileges 2014-10-06 08:11:01 +02:00
Igor Galić
443ff061ea Merge pull request #569 from fnerdwq/mysql_grant_revokation
(MODULES-1330) Change order of revokation.
2014-09-16 15:02:13 +02:00
Frederik Wagner
bbbc6cd446 (MODULES-1330) Change order of revokation 2014-09-16 14:06:26 +02:00
Matthew Monaco
d986a87558 mysql_database: prevent syntax error with collate=>'binary'
On MySQL v5.5.38, creating a database such as:

	CREATE DATABASE `mydb` CHARACTER SET binary COLLATE binary;

seems to hit a parser bug. A workaround is simply to quote COLLATE
`binary`. As the quoting is harmless, and for aesthetics, quote both
the CHARACTER SET and COLLATE arguments.
2014-09-15 23:22:59 -06: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