Commit graph

319 commits

Author SHA1 Message Date
Hunter Haugen
53257df16f Add helper to install puppet/pe/puppet-agent 2015-06-11 16:14:06 -07:00
Justin Stoller
5185d3d360 (maint) allow setting PUPPET_VERSION in acceptance 2015-06-08 22:22:26 -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
d3901f205a (fix) - Change default for mysql::server::backup to ignore_triggers => false
- Update spec acceptance test to check for which version is currently installed prior to testing
2015-05-12 09:45:10 -07:00
Travis Fields
9dad94a8c6 (fix) - Fix issue where fact is unknown at start
- Resolve issue where if known and failed versioncmp would result in idempotency issue on second run
2015-05-11 09:36:35 -07:00
Travis Fields
8b1fa24479 (fix) - Fix an issue were we assume triggers work
- There are older versions of mysql that do not support the privilege TRIGGER and need to change default to not include
  http://dev.mysql.com/doc/refman/5.0/en/grant.html
  'MySQL does not support the standard SQL UNDER privilege, and does not support the TRIGGER privilege until MySQL 5.1.6'

- Updated tests to have both 5.1.6 and 5.0.11 tests for mysql_version fact
2015-05-08 08:51:38 -07: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
Steven C. Saliman
49f273a42c Made the 'TRIGGER'privilege of mysqldump backups depend on whether or not we are actually backing up triggers 2015-04-30 12:37:38 -06:00
Steven C. Saliman
ec14b87a81 Added options for including/excluding triggers and routines, and fixed a permission problem that was preventing triggers from being backed up 2015-04-30 08:01:06 -06:00
Morgan Haskel
298242e043 MODULES-1928 - allow log-error to be undef
Wrap the file resource so that this doesn't explode if log-error is
undef. This is required for syslogging.
2015-04-13 17:05:22 -07:00
Colleen Murphy
a59c68b165 Update tests for rspec-puppet 2 and future parser
This patch changes the raise_error matchers to use `catalogue` instead
of `subject` since `subject` is not evaluated the way it used to be;
changes a parameter value from empty string to nil to be compatible
with the future parser, and unpins rspec-puppet.
2015-03-23 22:09:15 -07:00
Jesse Cotton
a26b80d750 Remove default install root password if set 2015-03-17 15:21:07 +00:00
tphoney
78a787107f minor typos fixed 2015-03-04 10:56:32 +00: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
Morgan Haskel
7a3fe1ca00 Merge pull request #617 from juniorsysadmin/package-manage-parameter
(MODULES-1143) Add package_manage parameters
2015-02-27 12:06:25 -08:00
Hunter Haugen
ce43899af3 (MODULES-1804) Allow override of log-error
The mysqld log-error setting may be passed by override_options, but
server/service.pp was not using the overridden value. This fixes that.
2015-02-27 09:54:00 -08:00
David Gurtner
b3c33f0a13 fix bug in GH-578
the recently added feature to support galera by allowing independent
creation of the root@localhost user in the DB and the /root/.my.cnf
file contains a bug.

specifically the .my.cnf file resource still requires the root@localhost
resource, even when it is not available.

this fixes the issue by making the dependency conditional.
2015-02-16 17:01:18 +01:00
juniorsysadmin
f5a693b826 (MODULES-1143) Add package_manage parameter
This patch adds a package_manage parameter for both mysql::server and
mysql::client
2015-02-12 13:33:36 +11:00
Morgan Haskel
b9fbba3b0d Merge pull request #578 from franzs/new_root_options
Add new parameters create_root_user and create_root_my_cnf.
2015-02-09 14:13:07 -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
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
Colleen Murphy
551d22fb84 Fix acceptance tests from #648
Missed Lucid the first time.
2015-01-27 15:05:37 -08:00
Colleen Murphy
80236d1f3a Fix acceptance tests from #641 2015-01-27 13:42:24 -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
TP Honey
1a87bae020 Merge pull request #637 from dveeden/account_localhost
Do the right thing when fqdn==localhost
2015-01-22 10:36:01 -08:00
Daniël van Eeden
c04fed1066 When fqdn==localhost account security breaks
This is because the root@localhost account is already
defined.

Remove localdomain accounts if fqdn is localhost
2015-01-18 15:02:17 +01: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
23c192df9f Merge pull request #634 from cyberious/ResourceTest
MODULES-1520 add test to assert it does not break
2015-01-02 11:52:06 -05:00
Travis Fields
d9d02718b8 MODULES-1520 add test to assert it does not break 2014-12-31 16:48:54 -08: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
3c872abcd2 Remove mysqltuner, fetch with staging instead
mysqltuner is licensed under GPL so we don't want to package it with the
module.
2014-12-16 10:52:39 -08:00
Morgan Haskel
93615453b5 Use puppet() instead of shell() to install module dependencies 2014-12-12 12:55:31 -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
Morgan Haskel
11fb01c736 Fix test issues
Remove the dependency on stdlib 4.x puppetlabs/puppetlabs-mysql#574
introduced, add some input validation, and improve test checks.
2014-11-14 13:16:01 -08:00
Igor Galić
ab84a671f9 Merge pull request #574 from Mylezeem/allow_multiple_import_at_a_time
(MODULES-1338) Allow mysql::db to import several files
2014-11-14 17:15:13 +01: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
Yanis Guenane
5e6a1c418a (MODULES-1338) Allow mysql::db to import several files
A user might need to import several files on database creation.
Currently the module only allows the import of a single file.
This commit allows one to, from now on, import severals.

Before :

  mysql::db { 'test' :
    sql => '/tmp/my_import1.sql',
  }

Now :

  mysql::db { 'test' :
    sql => [
      '/tmp/my_import1.sql',
      '/tmp/my_import2.sql',
    ]
  }
2014-11-13 14:17:50 -05:00
Maxence Dunnewind
cdd7132ff9 Improve checks for MySQL user's name.
As per http://dev.mysql.com/doc/refman/5.5/en/identifiers.html , MySQL
allows for more than '\w-'. This commit improves the check to ensure
that:
 - if username only contains [0-9a-zA-Z$_], it might be quoted. It is
   not a requirement though
 - if username contains anything else, it MUST be quoted

I kept 2 checks, but the 2nd one can probably be removed (I can't find a
username which match the 2nd one but not the first.)
2014-11-06 08:51:07 +01:00
Morgan Haskel
91e57102d6 Merge pull request #580 from cmurphy/fix_bzcat
Install bzip2 on RHEL 7 and Fedora hosts
2014-10-07 18:52:11 -04:00
Colleen Murphy
c291be44eb Install bzip2 on RHEL 7 and Fedora hosts
The backup script needs the bzcat command, which does not come
installed on RHEL 7 and Fedora hosts by default. This patch installs
the bzip2 package before attempting to run tests that use bzcat.
2014-10-07 15:43:57 -07: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
Franz Schwartau
02564bfe08 Add new parameters create_root_user and create_root_my_cnf.
This allows the galera module and others to write ${::root_home}/.my.cnf
independently from create the mysql user. This is useful for cluster
setups where you want to create ${::root_home}/.my.cnf on every node
but create the user only once.
2014-10-06 10:53:30 +02:00
Frederik Wagner
f88719b52f (MODULES-552) Add capability to specify column_privileges 2014-10-06 08:11:01 +02:00
Morgan Haskel
ba4830cbbe Trailing commas were breaking things on 1.8.7 2014-09-19 09:42:35 -07: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
Igor Galić
f8dca35b8e Merge pull request #559 from nhinds/file_per_database_username_and_password
(MODULES-1287) Pass the backup credentials to 'SHOW DATABASES'
2014-09-08 14:54:17 +02:00
Morgan Haskel
058053b5bc Update spec_helper for more consistency 2014-08-28 17:49:18 -04:00
Nicholas Hinds
462dbf7a1c (MODULES-1287) Pass the backup credentials to 'SHOW DATABASES'
Pass the backup username and password to mysql when running SHOW DATABASES in
mysqlbackup.sh if `file_per_database` is true and `backupdatabases` is empty.
2014-08-24 15:44:47 +12:00
Ashley Penney
9cb685da47 Split out the template tests and rework both sets of tests. 2014-08-14 14:55:20 -04:00
Ashley Penney
c4e4a56a47 Fix this to be more concise and consistent.
This was a surprisingly large amount of work.
2014-08-08 16:47:45 -04:00
Ashley Penney
5b10f3e773 Clean these up to be more readable. 2014-08-08 16:47:44 -04:00
Ashley Penney
00a191f9ed Convert specs to RSpec 2.99.1 syntax with Transpec
This conversion is done by Transpec 2.3.6 with the following command:
    transpec -f -c "bundle exec rake spec"

* 69 conversions
    from: it { should ... }
      to: it { is_expected.to ... }

* 48 conversions
    from: obj.should
      to: expect(obj).to

* 34 conversions
    from: == expected
      to: eq(expected)

* 4 conversions
    from: it { should_not ... }
      to: it { is_expected.not_to ... }

* 3 conversions
    from: obj.should_not
      to: expect(obj).not_to

* 2 conversions
    from: lambda { }.should
      to: expect { }.to

* 2 conversions
    from: pending
      to: skip

For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-08-08 16:47:44 -04:00
Ashley Penney
bb205ad2f0 Remove all the deprecated code. 2014-08-08 14:13:22 -04:00
Ashley Penney
cf2ffc6821 Handle graceful failure on RHEL4 and improve the messaging. 2014-08-08 11:55:31 -04:00
Ashley Penney
138820b3b8 Don't check the variable here, we can trust mysql to work. 2014-08-07 17:53:26 -04:00
Hunter Haugen
1812fbca25 Rewrite some of the unit tests to work on more platforms.
This commit introduces puppet_facts, a gem that allows easier testing
against PE platforms.  We're using this gem to automatically parse the
metadata.json and test against appropriate versions of PE on platforms
we support.

We start by only running against centos-6-x86_64 and ubuntu 14.04 on a
regular basis but this is implemented as an ENV so it can be overwritten
by CI systems to test against all PE platforms.
2014-08-07 16:27:17 -04:00
Ashley Penney
994ac1a058 Rebuild the acceptance tests. 2014-08-07 15:52:19 -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
I'm on Vacation until 18th of July
70cafdc283 Merge pull request #509 from xbezdick/master
Parametrize !includedir
2014-07-23 12:38:18 +02:00
Gael Chamoulaud
7b3cdd234a Adds Support for CentOS and Scientific Linux 7
CentOS Project has adopted a new rule for versioning numbers. The major number
matches the RHEL major number, but the minor number is generated from the
release date. For example, CentOS 7.0.1406.

Uses $::operatingsystemmajrelease instead of $::operatingsystemrelease for
avoiding issue like "Comparison of String with 7 failed" for CentOS 7.

Signed-off-by: Gael Chamoulaud <gchamoul@redhat.com>
2014-07-21 20:13:26 +02:00
Hunter Haugen
52d44be30f Merge pull request #536 from apenney/mysql_install
Handle changing the datadir properly.
2014-07-08 14:55:11 -07:00
Ashley Penney
5959715ff6 Rework the mysql initdb functionality.
This reworks a previously unmerged PR to clean up the code a little and
adds a test for it.
2014-07-08 12:53:20 -04: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
Jaakko
16002dfe09 Fix acceptance test for mysql::bindings.
Fix acceptance test for bindings to use correct parameter names, when
instantiating mysql::bindings class. Fix client and server dev package names
for couple of distros.
2014-06-11 18:01:16 +02:00
Ashley Penney
d884e2fc1e Merge pull request #522 from cmurphy/fix_mysql_grant_MODULES-1040
Require title of mysql_grant resource to match form user/table
2014-06-05 13:07:40 -04:00
Igor Galić
b39ebdcf74 Merge pull request #505 from larsks/bz/1093367
lowercase hostname values in qualified usernames
2014-06-05 12:17:04 +02:00
Colleen Murphy
07b661dcea Require title of mysql_grant resource to match form user/table
This addresses https://tickets.puppetlabs.com/browse/MODULES-1040.
The user parameter is required to have the form username@host. A grant
is identified in the instances method by a name of the form
username@host/table. The resource will fail to be identified as already
existing if the name given to the resource does not match this form.
2014-06-04 10:44:36 -07:00
Lars Kellogg-Stedman
0afb8f09e8 lowercase hostname values in qualified usernames
MySQL/MariaDB automatically downcase hostnames:

  MariaDB [mysql]> create user 'testuser'@'HOSTNAME';
  MariaDB [mysql]> select user,host from user where host = 'hostname';
  +----------+----------+
  | user     | host     |
  +----------+----------+
  | testuser | hostname |
  +----------+----------+

This causes problems when a mysql_user or datbase_user has an hostname
with non-lowercase characters:

  database_user { "root@HOSTNAME":
    ensure => absent,
  }

The SELECT statements used to determine if the user exists will fail
because the comparisons use "HOSTNAME" but the database has "hostname".
This patch forces the hostname part of "user@hostname" to lower case in
the custom type definitions.
2014-06-04 09:30:45 -04:00
Lukas Bezdicka
26204437ef Prametrize !includedir
Hardcoded path provided by puppet is now replaced by providing only the final directory as on
most systems includedir is provided by package and it's matter of user to provide it if he
wants to override it. This also allows disabling including at all.
2014-06-04 14:07:49 +02:00
William Van Hevelingen
669466c315 RSpec renamed be_true to be_truthy in 3.0
This commits updates the spec tests to use the renamed function.
2014-06-03 23:31:19 -07:00
Igor Galić
6769677e74 Merge pull request #510 from Aethylred/dev_libs
Install MySQL client and daemon dev libraries.
2014-06-03 06:34:43 +02:00
Ashley Penney
8f73cfcce0 Fix test so it doesn't fail on deprecation warnings. 2014-05-29 14:49:00 -04:00
Aaron Hicks
b2090194f5 Install MySQL client and daemon dev libraries. 2014-05-19 09:41:25 +12:00
Morgan Haskel
3871ca4206 Fixes to get tests running on RHEL5.
Existing EPEL addition in spec_helper_acceptance wasn't actually working, so pulled in stahnma-epel and applied that in the bindings test, since that's the only place it's actually required.
2014-05-12 12:32:20 -04:00
Morgan Haskel
d8a5043cc7 Fix the path for the hiera file. 2014-05-09 17:15:09 -04:00
Ashley Penney
b719956252 Replace the symlink with the actual file to resolve a PMT issue. 2014-05-09 16:53:12 -04:00
Ashley Penney
1999625fe2 Missed a couple of tests to gate off for unsupported platforms. 2014-05-09 16:53:11 -04:00
Ashley Penney
2bf1759f76 Fix hiera.yaml creation on PE. 2014-05-09 16:53:11 -04:00
Morgan Haskel
c57c762810 Package rename in Ubuntu 14.04. 2014-05-09 16:39:10 -04:00
Morgan Haskel
625cdf0e9f Allow the tests to run on RHEL7. 2014-05-09 15:54:08 -04:00
Morgan Haskel
bb4640d64a Change package/service for MariaDB. 2014-05-09 15:35:16 -04:00
Morgan Haskel
ad5381d67a Fix to install ruby-mysql from gem. 2014-05-09 15:11:57 -04:00
Morgan Haskel
7c16c52ef4 Try to add some checks so the test doesn't do an rm -rf / 2014-05-09 13:58:46 -04:00
Morgan Haskel
a6bacbd144 Fix backup test, install bzip2. 2014-05-09 13:05:00 -04:00
Ashley Penney
81a1a19f24 Improve this so it works on Ubuntu 14.04. 2014-05-02 19:52:05 +02:00
Ashley Penney
7f4c067350 Remove all rspec-system traces. 2014-04-24 22:05:43 +02:00
Igor Galić
aa82f83ace Merge pull request #500 from nerdlich/patch-1
User needs PROCESS privilege when doing file-per-database backup
2014-04-22 14:22:54 +02:00
nerdlich
b40865d740 Backup user needs PROCESS privilege when doing file-per-database backups
The following error occured:
mysqldump: Couldn't execute 'SELECT /*!40001 SQL_NO_CACHE */ * FROM `INNODB_BUFFER_PAGE`': Access denied; you need (at least one of) the PROCESS privilege(s) for this operation (1227)
2014-04-22 13:08:58 +02:00
Igor Galić
50612ab6ff fix spec tests, by adding osrelease facts 2014-04-22 12:38:29 +02:00
Ashley Penney
71d1f24bd9 Merge pull request #457 from igalic/independent-backup
mysqlbackup.sh should be able to find mysql
2014-04-10 13:46:19 -04:00
Pan
2834498e4d Allow use different name for db resource other than db name
When defining the mysql::db as exported resources, there are chances that the
same resource names are defined across the site, which will cause puppet agent
fail. By adding an optional dbname parameter, default to the $name, it allows the
resouce name to be defined differently, e.g. ${dbname}_${domain}.
Also updated test and docs for dbname parameter and add acceptance test for
dbname parameter feature
2014-03-15 13:38:13 -07:00
Ashley Penney
ec1cc59d03 Merge pull request #479 from igalic/better-backup-test
backup script test: Actually loop through a list
2014-03-06 14:48:04 -05:00
Robin Gloster
5c8d97f81b add test for ssl-disable 2014-03-04 14:58:37 +01:00
Igor Galić
53af16e601 backup script test: Actually loop through a list
we do this by creating more than one database to backup.
2014-03-02 13:30:30 +01:00
Ben Kero
ce6effe736 change box parameter to ensure vbox436 on centos65 type in acceptance test 2014-02-26 14:10:34 -08:00
Ben Kero
86d2051a5e change vbox version and ensure correct path 2014-02-26 14:09:02 -08:00