Commit graph

126 commits

Author SHA1 Message Date
Quentin Moss
8d4b83159e
Add limit to mysql server ID generated value 2016-08-09 17:05:22 -07:00
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
Hunter Haugen
f4fe313e65 Remove mysql_table_exists() function
This function is intended to check for the existence of a table before
declaring some resource, but this is neither portable (because functions
orun on the master, not the agent) nor one-run idempotent (because the
function would run before mysql is even installed, and would take two
runs to do anything).

The correct way of doing this would be to update the providers and
dependency ordering to handle the conditional states.

Luckily this was never released so it is backwards compatible.
2016-03-28 10:48:58 -07: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
Martin Hagstrom
61058b7610 Don't hash passwords that are already hashed 2015-11-19 07:54:10 +01:00
Artur Gadelshin
27323f74e6 (MODULES-2767) fix mysql_table_exists: add check for args.size, fix rspec test 2015-11-09 16:04:38 +03:00
Artur Gadelshin
cafbc80fcf (MODULES-2767) early return after fail 2015-11-09 12:02:40 +03:00
Artur Gadelshin
e518abd97e (MODULES-2767) allow to check if table exists before grant 2015-11-07 19:23:20 +03:00
Joseph Karns
96c9d6d9a7 Fixes unique server_id within my.cnf, The issue was that the entire mac address was not being read in to generate the id. 2015-10-12 12:36:39 -04: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
Morgan Haskel
97b8200a5f Improved user validation and munging
We want to make sure we are validating the entire user parameter (and
validating it consistently between mysql_user and mysql_grant).
Additionally, for munging we do not want to do anything that could
truncate the username.
2015-09-24 11:35:14 -07:00
Igor Galić
f44830ca7b autorequire mysql::server in types
instead of making mysql::db have a hard dependency on mysql::server, we
now have a (soft) dependency on it through the types (mysql_user, and
mysql_database) that mysql::db uses. (n.b.: mysql_grant depends on
mysql_user so it doesn't need an explicit dependency on mysql::server)
2015-07-30 16:11:17 +02:00
Igor Galić
ffa2b1ecea Merge pull request #730 from binford2k/fix/dont_explode_if_mac_fails
Don't explode if macaddress isn't set
2015-06-25 15:48:28 -07:00
Ben Ford
eaff7e40b5 Don't explode if macaddress isn't set
Sometimes the macaddress fact fails, for example sometimes in a Docker
container. We shouldn't clutter up reports with spurious warnings in
that case.
2015-06-25 10:23:58 -07:00
Igor Galić
837c21b963 length check for usernames should take mysql version into consideration
Starting MariaDB 10.0.0, usernames are now 80 long.
Our mysql_user and mysql_grant types now take that into consideration.

This check is *opportunistic*. It will only take place if the
mysql_version fact is available. If that is not the case, it will be
skipped, leaving the database itself to deal with it, and returning its
error verbatim to our users, if it does fail.

Our fixed and extended tests assume this isn't the first run, and the
fact is already in place.
2015-05-29 14:13:39 +02:00
Travis Fields
3ce8ad3799 (maint) - Add a fact for capturing the mysql version installed
- Add spec test for mysql_version fact
- Add `mysql_version` fact to README
2015-05-08 08:51:38 -07:00
Artur Gadelshin
35c75b79bb MODULES-1981: Revoke and grant difference of old and new privileges 2015-05-04 16:07:10 +03:00
Igor Galić
d7077b43d2 document mysql_server_id fact and add spec tests
add spec tests, expand documentation to mention lo behaviour
also, rename fact, for, consistency.
2015-03-04 08:56:45 +01:00
Nick Le Mouton
dbf54cefe8 Added server_id fact
use mac address for "guaranteed" uniqueness ;)
2015-03-04 08:56:18 +01:00
Morgan Haskel
96f4d164a4 MODULES-1759: Remove dependency on stdlib >=4.1.0
Backported dirname => mysql_dirname since updating dependency to stdlib
4.1.0 is backwards incompatible with some versions of PE.
2015-02-09 12:34:44 -08:00
Hunter Haugen
b3a38a8dfe Merge pull request #645 from dveeden/auth-plugins
Support authentication plugins
2015-02-06 12:40:49 -08:00
Hunter Haugen
506292ae58 Make grant autorequire user
grants that happen before a user is created cause an ERROR 1396
2015-02-05 16:21:24 -08:00
Hunter Haugen
3fa70506c4 Merge pull request #646 from dveeden/emptypwd
Return an empty string for an empty input.
2015-02-05 10:39:28 -08:00
Daniël van Eeden
279c13b5e3 Return an empty string for an empty input.
https://tickets.puppetlabs.com/browse/MODULES-1676

This is identical to what PASSWORD('') in MySQL does:

5.6.22-debug-log> CREATE USER 'testpwd'@'localhost' IDENTIFIED BY 'foo';
Query OK, 0 rows affected (0.03 sec)

5.6.22-debug-log> SELECT User,Host,Password FROM mysql.user WHERE
User='testpwd';
+---------+-----------+-------------------------------------------+
| User    | Host      | Password                                  |
+---------+-----------+-------------------------------------------+
| testpwd | localhost | *F3A2A51A9B0F2BE2468926B4132313728C250DBF |
+---------+-----------+-------------------------------------------+
1 row in set (0.01 sec)

5.6.22-debug-log> SET PASSWORD FOR 'testpwd'@'localhost' = PASSWORD('');
Query OK, 0 rows affected (0.00 sec)

5.6.22-debug-log> SELECT User,Host,Password FROM mysql.user WHERE
User='testpwd';
+---------+-----------+----------+
| User    | Host      | Password |
+---------+-----------+----------+
| testpwd | localhost |          |
+---------+-----------+----------+
1 row in set (0.00 sec)
2015-01-28 21:08:29 +01: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
Morgan Haskel
f92a24ef3d MODULES-1520 - update username validation
Don't fail on validation where the user isn't quoted with special
characters. The providers quote these strings by default.
2014-12-31 11:50:48 -08:00
Morgan Haskel
a611686530 Fix issues introduced in puppetlabs/puppetlabs-mysql#612
The regex updates caused failures in some places where it previously
(correctly) worked.
2014-12-12 17:36:46 -08:00
Sébastien Lavoie
60838a5837 Reworked all identifier quoting detections
Otherwise, trying to manage `debian-sys-maint` will fail miserably, quoted or not.

Fixes #609
2014-11-27 12:47:09 -05:00
Michael Chapman
fe0365e80d Support size 15 and 16 quoted usernames
As usernames containing special characters must be quoted, they
may have two extra characters that are not counted against the
size limit of 16 characters. This patch adds a regex to handle
this case.
2014-11-20 17:23:11 +11:00
Mason Malone
4f0d4311d9 Fix regression in username validation
Commit cdd7132ff9 added logic to catch invalid database usernames,
but the regex it uses fails to match usernames with special characters that are properly quoted,
causing errors with usernames that used to work in versions < 3.0.0. This fixes the regex so that
if the username is quoted, anything is allowed between the quotes.

From the docs (http://dev.mysql.com/doc/refman/5.5/en/identifiers.html):
"Permitted characters in quoted identifiers include the full Unicode Basic Multilingual Plane (BMP),
except U+0000"
2014-11-13 18:18:02 -05:00