diff -Nru puppet-module-puppetlabs-mysql-3.10.0/CHANGELOG.md puppet-module-puppetlabs-mysql-5.3.0/CHANGELOG.md --- puppet-module-puppetlabs-mysql-3.10.0/CHANGELOG.md 2016-11-07 20:14:06.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/CHANGELOG.md 2018-02-20 14:54:26.000000000 +0000 @@ -1,3 +1,112 @@ +# Change log + +All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](http://semver.org). + +## Supported Release [5.3.0] +### Summary +This release uses the PDK convert functionality which in return makes the module PDK compliant. It also includes a roll up of maintenance changes, a new task and support for `GRANTS FUNCTION`. + +### Added +- Add support for `GRANTS FUNCTION` ([MODULES-2075](https://tickets.puppet.com/browse/MODULES-2075)). +- Add Export database task. +- PDK Convert mysql ([MODULES-6454](https://tickets.puppet.com/browse/MODULES-6454)). + +### Changed +- Allow authentication plugin to be changed. +- Update mysql_user provider. +- Plugins don't exist before 5.5; password field name changed +- Fix helpful rubocops and disable hurtful cops. +- Addressing puppet-lint and rubocop errors +- Remove update bundler and add ignore .DS_Store +- Skip rubocop warning in task. +- Fix a typo in a classname in the changelog. + +## Supported Release [5.2.1] +### Summary +This release fixes CVE-2018-6508 which is a potential arbitrary code execution via tasks. + +### Fixed +- Fix export and mysql tasks for arbitrary remote code + +## Supported Release [5.2.0] + +### Added +- Compatibility for puppet-staging 3.0.0 + +### Fixed +- Centralize all mysql command calls for providers +- Add paths to `mysql_datadir` provider for RedHat Software Collections + +## Supported Release [5.1.0] +### Summary +This release adds Tasks to the Mysql module. + +#### Added +- Adds the execute sql task. + +## Supported Release [5.0.0] +### Summary +This is a major release that adds support for string translation. Currently the only supported language besides +English is Japanese. + +#### Added +- Several gem dependencies required for translation. +- Wrapping of strings that require translation. Strings in ruby code are now wrapped with `_()` and strings in puppet code with `translate()`. +- Debian 9 support + +#### Changed +- The default php_package_name for Debian and Ubuntu to `php-mysql` + +## Supported Release 4.0.1 +### Summary +This is a small bugfix release that makes `mysql_install_db` optional and fixes some regular expression issues. + +#### Bugfixes +- ([MODULES-5528](https://tickets.puppet.com/browse/MODULES-5528)) Fixes the `mysql_install_db` command so that it is optional +- ([MODULES-5602](https://tickets.puppet.com/browse/MODULES-5602)) Removes superfluous backslashes in some regular expressions that were causing instability + +## Supported Release 4.0.0 +### Summary +This release sees the enablement of rubocop, also an update to the lib directory with rubocop fixes and several other changes and fixes. Also a bump to the Puppet version compatibility and several Puppet language updates. + +#### Added +- Updated README.md with example how to install MySQL Community Server 5.6 on Centos 7.3 +- Enabled Rubocop and addition of Rubocop fixes for /lib directory. + +#### Removed +- Dropped legacy tests for db.pp. + +#### Changed +- Replaced validate function calls with datatypes in db.pp. +- Bumped recommended puppet version to between 4.7.0 and 6.0.0. +- Conditionalize name validation in mysql_grant type. ([MODULES-4604](https://tickets.puppet.com/browse/MODULES-4604)) + +#### Fixed +- Removal of invalid parameter provider on Mysql_user[user@localhost] in mysql::db ([MODULES-4115](https://tickets.puppet.com/browse/MODULES-4115)) +- Fixed server_service_name for Debian/stretch. +- Spec fixes for Puppet 5. +- Test update for fix:create procedure, then grant ([MODULES-5390](https://tickets.puppet.com/browse/MODULES-5390)) +- Fixing empty user/password issue for xtrabackup. Now defaults as undef instead of ''. +- Remove unsupported Ubuntu versions ([MODULES-5501](https://tickets.puppet.com/browse/MODULES-5501)) + +## Supported Release 3.11.0 +### Summary +This release includes README and metadata translations to Japanese, as well as some enhancements and bugfixes. + +#### Added +- New flag for successful backups +- Solaris support improvements +- New parameter `optional_args` for extra innobackupex options +- Specify environment variables (e.g. https_proxy) for MySQLTuner download. +- Check to only install bzip2 if `$backupcompress` is `true` +- Debian 9 compatibility +- Japanese README + +#### Fixed +- Syntax errors +- Bug where error logs were being created before the datadir was initialized (MODULES-4743) + ## Supported Release 3.10.0 ### Summary This release includes new features for setting TLS options on a mysql user, a new parameter to allow specifying tool to import sql files, as well as various bugfixes. @@ -7,7 +116,7 @@ - Adds support for setting `tls_options` in `mysql_user` #### Bugfixes -- (MODULES-3557) Adds Ubuntu 16.04 package names for language bindings +- (MODULES-3557) Adds Ubuntu 16.04 package names for language bindings - (MODULES-3907) Adds MySQL/Percona 5.7 initialize on fresh deploy ## Supported Release 3.9.0 @@ -31,7 +140,7 @@ - Fixes a bug where error log is not writable by owner ## Supported Release 3.8.0 -###Summary +### Summary This release adds Percona 5.7 support and compatibility with Ubuntu 16.04, in addition to various bugfixes. #### Features @@ -64,7 +173,7 @@ - Adds path to be able to find MySQL 5.5 installation on CentOS ## Supported Release 3.7.0 -###Summary +### Summary A large release with several new features. Also includes a considerable amount of bugfixes, many around compatibility and improvements to current functionality. @@ -111,7 +220,7 @@ - Generate .my.cnf for all sections. ## Supported Release 3.6.2 -###Summary +### Summary Small release for support of newer PE versions. This increments the version of PE in the metadata.json file. @@ -139,24 +248,24 @@ - Fix service dependency when package_manage is false - Fix selinux permissions on my.cnf -##2015-07-23 - Supported Release 3.5.0 -###Summary +## 2015-07-23 - Supported Release 3.5.0 +### Summary A small release to add explicit support to newer Puppet versions and accumulated patches. -####Features/Improvements +#### Features/Improvements - Start running tests against puppet 4 - Support longer usernames on newer MariaDB versions - Add parameters for Solaris 11 and 12 -####Bugfixes +#### Bugfixes - Fix references to the mysql-server package - mysql_server_id doesn't throw and error on machines without macaddress -##2015-05-19 - Supported Release 3.4.0 -###Summary +## 2015-05-19 - Supported Release 3.4.0 +### Summary This release includes the addition of extra facts, OpenBSD compatibility, and a number of other features, improvements and bug fixes. -####Features/Improvements +#### Features/Improvements - Added server_id fact which includes mac address for better uniqueness - Added OpenBSD compatibility, only for 'OpenBSD -current' (due to the recent switch to mariadb) - Added a $mysql_group parameter, and use that instead of the $root_group parameter to define the group membership of the mysql error log file. @@ -170,7 +279,7 @@ - Cleaned up the privilege assignment in the mysqldump backup script - Add a fact for capturing the mysql version installed -####Bugfixes +#### Bugfixes - mysql backup: fix regression in mysql_user call - Set service_ensure to undef, in the case of an unmanaged service - README Typos fixed @@ -180,33 +289,33 @@ - Fix an issue were we assume triggers work - Change default for mysql::server::backup to ignore_triggers = false -####Deprecations +#### Deprecations mysql::server::old_root_password property -##2015-03-03 - Supported Release 3.3.0 -###Summary +## 2015-03-03 - Supported Release 3.3.0 +### Summary This release includes major README updates, the addition of backup providers, and a fix for managing the log-bin directory. -####Features +#### Features - Add package_manage parameters to `mysql::server` and `mysql::client` (MODULES-1143) - README improvements - Add `mysqldump`, `mysqlbackup`, and `xtrabackup` backup providers. -####Bugfixes +#### Bugfixes - log-error overrides were not being properly used (MODULES-1804) - check for full path for log-bin to stop puppet from managing file '.' -##2015-02-09 - Supported Release 3.2.0 -###Summary +## 2015-02-09 - Supported Release 3.2.0 +### Summary This release includes several new features and bugfixes, including support for various plugins, making the output from mysql_password more consistent when input is empty and improved username validation. -####Features +#### Features - Add type and provider to manage plugins - Add support for authentication plugins - Add support for mysql_install_db on freebsd - Add `create_root_user` and `create_root_my_cnf` parameters to `mysql::server` -####Bugfixes +#### Bugfixes - Remove dependency on stdlib >= 4.1.0 (MODULES-1759) - Make grant autorequire user - Remove invalid parameter 'provider' from mysql_user instance (MODULES-1731) @@ -219,16 +328,16 @@ - Test fixes - Lint fixes -##2014-12-16 - Supported Release 3.1.0 -###Summary +## 2014-12-16 - Supported Release 3.1.0 +### Summary This release includes several new features, including SLES12 support, and a number of bug fixes. -####Notes +#### Notes `mysql::server::mysqltuner` has been refactored to fetch the mysqltuner script from github by default. If you are running on a non-network-connected system, you will need to download that file and have it available to your node at a path specified by the `source` parameter to the `mysqltuner` class. -####Features +#### Features - Add support for install_options for all package resources (MODULES-1484) - Add log-bin directory creation - Allow mysql::db to import multiple files (MODULES-1338) @@ -236,20 +345,20 @@ - Improved identifier quoting detections - Reworked `mysql::server::mysqltuner` so that we are no longer packaging the script as it is licensed under the GPL. -####Bugfixes +#### Bugfixes - Fix regression in username validation - Proper containment for mysql::client in mysql::db - Support quoted usernames of length 15 and 16 chars -##2014-11-11 - Supported Release 3.0.0 -###Summary +## 2014-11-11 - Supported Release 3.0.0 +### Summary Added several new features including MariaDB support and future parser -####Backwards-incompatible Changes +#### Backwards-incompatible Changes * Remove the deprecated `database`, `database_user`, and `database_grant` resources. The correct resources to use are `mysql`, `mysql_user`, and `mysql_grant` respectively. -####Features +#### Features * Add MariaDB Support * The mysqltuner perl script has been updated to 1.3.0 based on work at http://github.com/major/MySQLTuner-perl * Add future parse support, fixed issues with undef to empty string @@ -260,24 +369,24 @@ * `mysql::server` now takes an `override_options` hash that will affect the installation * Ability to install both dev and client dev -####BugFix +#### BugFix * `mysql::server::backup` now passes `ensure` param to the nested `mysql_grant` * `mysql::server::service` now properly requires the presence of the `log_error` file * `mysql::config` now occurs before `mysql::server::install_db` correctly -##2014-07-15 - Supported Release 2.3.1 -###Summary +## 2014-07-15 - Supported Release 2.3.1 +### Summary This release merely updates metadata.json so the module can be uninstalled and upgraded via the puppet module command. -##2014-05-14 - Supported Release 2.3.0 +## 2014-05-14 - Supported Release 2.3.0 This release primarily adds support for RHEL7 and Ubuntu 14.04 but it also adds a couple of new parameters to allow for further customization, as well as ensuring backups can backup stored procedures properly. -####Features +#### Features Added `execpath` to allow a custom executable path for non-standard mysql installations. Added `dbname` to mysql::db and use ensure_resource to create the resource. Added support for RHEL7 and Fedora Rawhide. @@ -287,38 +396,38 @@ Disable ssl on FreeBSD. Add PROCESS privilege for backups. -####Bugfixes +#### Bugfixes -####Known Bugs +#### Known Bugs * No known bugs -##2014-03-04 - Supported Release 2.2.3 -###Summary +## 2014-03-04 - Supported Release 2.2.3 +### Summary This is a supported release. This release removes a testing symlink that can cause trouble on systems where /var is on a seperate filesystem from the modulepath. -####Features -####Bugfixes -####Known Bugs +#### Features +#### Bugfixes +#### Known Bugs * No known bugs -##2014-03-04 - Supported Release 2.2.2 -###Summary +## 2014-03-04 - Supported Release 2.2.2 +### Summary This is a supported release. Mostly comprised of enhanced testing, plus a bugfix for Suse. -####Bugfixes +#### Bugfixes - PHP bindings on Suse - Test fixes -####Known Bugs +#### Known Bugs * No known bugs -##2014-02-19 - Version 2.2.1 +## 2014-02-19 - Version 2.2.1 -###Summary +### Summary Minor release that repairs mysql_database{} so that it sees the correct collation settings (it was only checking the global mysql ones, not the @@ -327,18 +436,18 @@ Also fixes a bunch of tests on various platforms. -##2014-02-13 - Version 2.2.0 +## 2014-02-13 - Version 2.2.0 -###Summary +### Summary -####Features +#### Features - Add `backupdirmode`, `backupdirowner`, `backupdirgroup` to mysql::server::backup to allow customizing the mysqlbackupdir. - Support multiple options of the same name, allowing you to do 'replicate-do-db' => ['base1', 'base2', 'base3'] in order to get three lines of replicate-do-db = base1, replicate-do-db = base2 etc. -####Bugfixes +#### Bugfixes - Fix `restart` so it actually stops mysql restarting if set to false. - DRY out the defaults_file functionality in the providers. - mysql_grant fixed to work with root@localhost/@. @@ -351,16 +460,16 @@ - key_buffer renamed to key_buffer_size. - log_error renamed to log-error. - pid_file renamed to pid-file. -- Ensure mysql::server:root_password runs before mysql::server::backup +- Ensure mysql::server::root_password runs before mysql::server::backup - Fix options_override -> override_options in the README. - Extensively rewrite the README to be accurate and awesome. - Move to requiring stdlib 3.2.0, shipped in PE3.0 - Add many new tests. -##2013-11-13 - Version 2.1.0 +## 2013-11-13 - Version 2.1.0 -###Summary +### Summary The most important changes in 2.1.0 are improvements to the my.cnf creation, as well as providers. Setting options to = true strips them to be just the @@ -373,13 +482,13 @@ externalize all your grants, users, and, databases. Another great set of community submissions helped to make this release. -####Features +#### Features - Some options can not take a argument. Gets rid of the '= true' when an option is set to true. - Easier hiera integration: Add hash parameters to mysql::server to allow specifying grants, users, and databases. -####Bugfixes +#### Bugfixes - Fix an issue with lowercase privileges in mysql_grant{} causing them to be reapplied needlessly. - Changed defaults-file to defaults-extra-file in providers. - Ensure /root/.my.cnf is 0600 and root owned. @@ -389,22 +498,22 @@ - Various test fixes. -##2013-10-21 - Version 2.0.1 +## 2013-10-21 - Version 2.0.1 -###Summary +### Summary This is a bugfix release to handle an issue where unsorted mysql_grant{} privileges could cause Puppet to incorrectly reapply the permissions on each run. -####Bugfixes +#### Bugfixes - Mysql_grant now sorts privileges in the type and provider for comparison. - Comment and test tweak for PE3.1. -##2013-10-14 - Version 2.0.0 +## 2013-10-14 - Version 2.0.0 -###Summary +### Summary (Previously detailed in the changelog for 2.0.0-rc1) @@ -422,53 +531,53 @@ mysql::server. -##2013-10-09 - Version 2.0.0-rc5 +## 2013-10-09 - Version 2.0.0-rc5 -###Summary +### Summary Hopefully the final rc! Further fixes to mysql_grant (stripping out the cleverness so we match a much wider range of input.) -####Bugfixes +#### Bugfixes - Make mysql_grant accept '.*'@'.*' in terms of input for user@host. -##2013-10-09 - Version 2.0.0-rc4 +## 2013-10-09 - Version 2.0.0-rc4 -###Summary +### Summary Bugfixes to mysql_grant and mysql_user form the bulk of this rc, as well as ensuring that values in the override_options hash that contain a value of '' are created as just "key" in the conf rather than "key =" or "key = false". -####Bugfixes +#### Bugfixes - Improve mysql_grant to work with IPv6 addresses (both long and short). - Ensure @host users work as well as user@host users. - Updated my.cnf template to support items with no values. -##2013-10-07 - Version 2.0.0-rc3 +## 2013-10-07 - Version 2.0.0-rc3 -###Summary +### Summary Fix mysql::server::monitor's use of mysql_user{}. -####Bugfixes +#### Bugfixes - Fix myql::server::monitor's use of mysql_user{} to grant the proper permissions. Add specs as well. (Thanks to treydock!) -##2013-10-03 - Version 2.0.0-rc2 +## 2013-10-03 - Version 2.0.0-rc2 -###Summary +### Summary Bugfixes -####Bugfixes +#### Bugfixes - Fix a duplicate parameter in mysql::server -##2013-10-03 - Version 2.0.0-rc1 +## 2013-10-03 - Version 2.0.0-rc1 -###Summary +### Summary This module has been completely refactored and works significantly different. The changes are broad and touch almost every piece of the module. @@ -484,9 +593,9 @@ mysql::server. --- -##2013-09-23 - Version 1.0.0 +## 2013-09-23 - Version 1.0.0 -###Summary +### Summary This release introduces a number of new type/providers, to eventually replace the database_ ones. The module has been converted to call the @@ -496,38 +605,38 @@ This 1.0.0 release precedes a large refactoring that will be released almost immediately after as 2.0.0. -####Features +#### Features - Added mysql_grant, mysql_database, and mysql_user. - Add `mysql::bindings` class and refactor all other bindings to be contained underneath mysql::bindings:: namespace. - Added support to back up specified databases only with 'mysqlbackup' parameter. - Add option to mysql::backup to set the backup script to perform a mysqldump on each database to its own file -####Bugfixes +#### Bugfixes - Update my.cnf.pass.erb to allow custom socket support - Add environment variable for .my.cnf in mysql::db. - Add HOME environment variable for .my.cnf to mysqladmin command when (re)setting root password --- -##2013-07-15 - Version 0.9.0 -####Features +## 2013-07-15 - Version 0.9.0 +#### Features - Add `mysql::backup::backuprotate` parameter - Add `mysql::backup::delete_before_dump` parameter - Add `max_user_connections` attribute to `database_user` type -####Bugfixes +#### Bugfixes - Add client package dependency for `mysql::db` - Remove duplicate `expire_logs_days` and `max_binlog_size` settings - Make root's `.my.cnf` file path dynamic - Update pidfile path for Suse variants - Fixes for lint -##2013-07-05 - Version 0.8.1 -####Bugfixes +## 2013-07-05 - Version 0.8.1 +#### Bugfixes - Fix a typo in the Fedora 19 support. -##2013-07-01 - Version 0.8.0 -####Features +## 2013-07-01 - Version 0.8.0 +#### Features - mysql::perl class to install perl-DBD-mysql. - minor improvements to the providers to improve reliability - Install the MariaDB packages on Fedora 19 instead of MySQL. @@ -561,16 +670,16 @@ - `expire_logs_days` - `max_binlog_size` -####Bugfixes +#### Bugfixes - No longer restart MySQL when /root/.my.cnf changes. - Ensure mysql::config runs before any mysql::db defines. -##2013-06-26 - Version 0.7.1 -####Bugfixes +## 2013-06-26 - Version 0.7.1 +#### Bugfixes - Single-quote password for special characters - Update travis testing for puppet 3.2.x and missing Bundler gems -##2013-06-25 - Version 0.7.0 +## 2013-06-25 - Version 0.7.0 This is a maintenance release for community bugfixes and exposing configuration variables. @@ -620,10 +729,10 @@ * Fix travis support (but still messy) * Fix typos -##2013-01-11 - Version 0.6.1 +## 2013-01-11 - Version 0.6.1 * Fix providers when /root/.my.cnf is absent -##2013-01-09 - Version 0.6.0 +## 2013-01-09 - Version 0.6.0 * Add `mysql::server::config` define for specific config directives * Add `mysql::php` class for php support * Add `backupcompress` parameter to `mysql::backup` @@ -640,7 +749,7 @@ * Fix typos * Fix lint warnings -##2012-08-23 - Version 0.5.0 +## 2012-08-23 - Version 0.5.0 * Add puppetlabs/stdlib as requirement * Add validation for mysql privs in provider * Add `pidfile` parameter to mysql::config @@ -649,122 +758,128 @@ * Change `bind_address` parameter to be optional in my.cnf template * Fix quoting root passwords -##2012-07-24 - Version 0.4.0 +## 2012-07-24 - Version 0.4.0 * Fix various bugs regarding database names * FreeBSD support * Allow specifying the storage engine * Add a backup class * Add a security class to purge default accounts -##2012-05-03 - Version 0.3.0 +## 2012-05-03 - Version 0.3.0 * 14218 Query the database for available privileges * Add mysql::java class for java connector installation * Use correct error log location on different distros * Fix set_mysql_rootpw to properly depend on my.cnf -##2012-04-11 - Version 0.2.0 +## 2012-04-11 - Version 0.2.0 -##2012-03-19 - William Van Hevelingen +## 2012-03-19 - William Van Hevelingen * (#13203) Add ssl support (f7e0ea5) -##2012-03-18 - Nan Liu +## 2012-03-18 - Nan Liu * Travis ci before script needs success exit code. (0ea463b) -##2012-03-18 - Nan Liu +## 2012-03-18 - Nan Liu * Fix Puppet 2.6 compilation issues. (9ebbbc4) -##2012-03-16 - Nan Liu +## 2012-03-16 - Nan Liu * Add travis.ci for testing multiple puppet versions. (33c72ef) -##2012-03-15 - William Van Hevelingen +## 2012-03-15 - William Van Hevelingen * (#13163) Datadir should be configurable (f353fc6) -##2012-03-16 - Nan Liu +## 2012-03-16 - Nan Liu * Document create_resources dependency. (558a59c) -##2012-03-16 - Nan Liu +## 2012-03-16 - Nan Liu * Fix spec test issues related to error message. (eff79b5) -##2012-03-16 - Nan Liu +## 2012-03-16 - Nan Liu * Fix mysql service on Ubuntu. (72da2c5) -##2012-03-16 - Dan Bode +## 2012-03-16 - Dan Bode * Add more spec test coverage (55e399d) -##2012-03-16 - Nan Liu +## 2012-03-16 - Nan Liu * (#11963) Fix spec test due to path changes. (1700349) -##2012-03-07 - François Charlier +## 2012-03-07 - François Charlier * Add a test to check path for 'mysqld-restart' (b14c7d1) -##2012-03-07 - François Charlier +## 2012-03-07 - François Charlier * Fix path for 'mysqld-restart' (1a9ae6b) -##2012-03-15 - Dan Bode +## 2012-03-15 - Dan Bode * Add rspec-puppet tests for mysql::config (907331a) -##2012-03-15 - Dan Bode +## 2012-03-15 - Dan Bode * Moved class dependency between sever and config to server (da62ad6) -##2012-03-14 - Dan Bode +## 2012-03-14 - Dan Bode * Notify mysql restart from set_mysql_rootpw exec (0832a2c) -##2012-03-15 - Nan Liu +## 2012-03-15 - Nan Liu * Add documentation related to osfamily fact. (8265d28) -##2012-03-14 - Dan Bode +## 2012-03-14 - Dan Bode * Mention osfamily value in failure message (e472d3b) -##2012-03-14 - Dan Bode +## 2012-03-14 - Dan Bode * Fix bug when querying for all database users (015490c) -##2012-02-09 - Nan Liu +## 2012-02-09 - Nan Liu * Major refactor of mysql module. (b1f90fd) -##2012-01-11 - Justin Ellison +## 2012-01-11 - Justin Ellison * Ruby and Python's MySQL libraries are named differently on different distros. (1e926b4) -##2012-01-11 - Justin Ellison +## 2012-01-11 - Justin Ellison * Per @ghoneycutt, we should fail explicitly and explain why. (09af083) -##2012-01-11 - Justin Ellison +## 2012-01-11 - Justin Ellison * Removing duplicate declaration (7513d03) -##2012-01-10 - Justin Ellison +## 2012-01-10 - Justin Ellison * Use socket value from params class instead of hardcoding. (663e97c) -##2012-01-10 - Justin Ellison +## 2012-01-10 - Justin Ellison * Instead of hardcoding the config file target, pull it from mysql::params (031a47d) -##2012-01-10 - Justin Ellison +## 2012-01-10 - Justin Ellison * Moved $socket to within the case to toggle between distros. Added a $config_file variable to allow per-distro config file destinations. (360eacd) -##2012-01-10 - Justin Ellison +## 2012-01-10 - Justin Ellison * Pretty sure this is a bug, 99% of Linux distros out there won't ever hit the default. (3462e6b) -##2012-02-09 - William Van Hevelingen +## 2012-02-09 - William Van Hevelingen * Changed the README to use markdown (3b7dfeb) -##2012-02-04 - Daniel Black +## 2012-02-04 - Daniel Black * (#12412) mysqltuner.pl update (b809e6f) -##2011-11-17 - Matthias Pigulla +## 2011-11-17 - Matthias Pigulla * (#11363) Add two missing privileges to grant: event_priv, trigger_priv (d15c9d1) -##2011-12-20 - Jeff McCune +## 2011-12-20 - Jeff McCune * (minor) Fixup typos in Modulefile metadata (a0ed6a1) -##2011-12-19 - Carl Caum +## 2011-12-19 - Carl Caum * Only notify Exec to import sql if sql is given (0783c74) -##2011-12-19 - Carl Caum +## 2011-12-19 - Carl Caum * (#11508) Only load sql_scripts on DB creation (e3b9fd9) -##2011-12-13 - Justin Ellison +## 2011-12-13 - Justin Ellison * Require not needed due to implicit dependencies (3058feb) -##2011-12-13 - Justin Ellison +## 2011-12-13 - Justin Ellison * Bug #11375: puppetlabs-mysql fails on CentOS/RHEL (a557b8d) -##2011-06-03 - Dan Bode - 0.0.1 +## 2011-06-03 - Dan Bode - 0.0.1 * initial commit + +[5.3.0]:https://github.com/puppetlabs/puppetlabs-mysql/compare/5.2.1...5.3.0 +[5.2.1]:https://github.com/puppetlabs/puppetlabs-mysql/compare/5.2.0...5.2.1 +[5.2.0]:https://github.com/puppetlabs/puppetlabs-mysql/compare/5.1.0...5.2.0 +[5.1.0]:https://github.com/puppetlabs/puppetlabs-mysql/compare/5.0.0...5.1.0 +[5.0.0]:https://github.com/puppetlabs/puppetlabs-mysql/compare/4.0.1...5.0.0 diff -Nru puppet-module-puppetlabs-mysql-3.10.0/checksums.json puppet-module-puppetlabs-mysql-5.3.0/checksums.json --- puppet-module-puppetlabs-mysql-3.10.0/checksums.json 2016-11-07 20:18:10.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/checksums.json 2018-02-20 14:55:47.000000000 +0000 @@ -1,11 +1,12 @@ { - "CHANGELOG.md": "b68d316974b7228a92b8a8c3b65bb9a4", - "CONTRIBUTING.md": "b78f71c1104f00538d50ad2775f58e95", - "Gemfile": "fda543906c8c75b06ea37c4d31b95292", + "CHANGELOG.md": "dccd7f3c9e5b31da9dc79b80ec4904eb", + "CONTRIBUTING.md": "4d17f3c942e7c93d1577cc4438a231e4", + "Gemfile": "0db0c68e57d767c53a474bd2c4a7a158", "LICENSE": "3b83ef96387f14655fc854ddc3c6bd57", - "NOTICE": "d43aacde256c8e55a50e2425e25b3a8a", - "README.md": "b4969d0b8649dd0f9c105ff22b66a871", - "Rakefile": "6db744f1deed7ae0746abe59e3d50863", + "MAINTAINERS.md": "d1a8a0cb1736b23f3143b685e0d034b0", + "NOTICE": "61151e454f47a0df587642c792385533", + "README.md": "80e47ef2f4fff77e396d9387606158b3", + "Rakefile": "49fef5f9162ec2b4fa7cfa4e1bd84cb6", "TODO": "88ca4024a37992b46c34cb46e4ac39e6", "examples/backup.pp": "a61c6f34f153a323209faf25948737f5", "examples/bindings.pp": "35a8387f5c55fa2e479c513a67918674", @@ -21,95 +22,105 @@ "examples/server/account_security.pp": "375442b7886c01b42fbf75a1fcb31822", "examples/server/config.pp": "659b7c40e9b55634721b3c33a8c6da98", "examples/server.pp": "72e22552a95b9a5e4a349dbfc13639dc", - "lib/facter/mysql_server_id.rb": "10de205ca9dc83b68cf63b52d97346ec", - "lib/facter/mysql_version.rb": "e30648f3d394a1cbdd4e54eb5c28d28c", - "lib/facter/mysqld_version.rb": "720f447c97dd4ce099006cd5391ade57", - "lib/puppet/parser/functions/mysql_deepmerge.rb": "2b5040ee8cd75a81cf881851e922833a", - "lib/puppet/parser/functions/mysql_dirname.rb": "820ba09a6a0df639da560b41cb31242f", - "lib/puppet/parser/functions/mysql_password.rb": "365a0ba55f0d04d0f5d56abcd577ec7d", - "lib/puppet/parser/functions/mysql_strip_hash.rb": "3efe69f1eb189b2913e178b8472aaede", - "lib/puppet/provider/mysql.rb": "2696893220da9d341d5826c9e9d4ca19", - "lib/puppet/provider/mysql_database/mysql.rb": "5cf9b8044df4ec72a726b5f781c84f8f", - "lib/puppet/provider/mysql_datadir/mysql.rb": "7c256b40cf96bdafde9c762ab867de80", - "lib/puppet/provider/mysql_grant/mysql.rb": "3630023349a4c8f06932938a26aaa2e6", - "lib/puppet/provider/mysql_plugin/mysql.rb": "49128d2a9a547c4945735bfd75fd6d6c", - "lib/puppet/provider/mysql_user/mysql.rb": "dc09eef4e1d879ffe4ee8eb9a7b3026c", - "lib/puppet/type/mysql_database.rb": "438eafbfecc30605462a220d92cf9603", - "lib/puppet/type/mysql_datadir.rb": "f19e548062e81f424646c193b086aaf6", - "lib/puppet/type/mysql_grant.rb": "afcc65b0394a23e95b8bf932bc6110b4", - "lib/puppet/type/mysql_plugin.rb": "0a52cead6c9283c9aa14ea71bdfa80bd", - "lib/puppet/type/mysql_user.rb": "8cc3c0851c06d01b310a7f551945e696", - "manifests/backup/mysqlbackup.pp": "66441b167e682689df21a4b37af175e8", - "manifests/backup/mysqldump.pp": "d858a7dda445c45952f6a7f029d41189", - "manifests/backup/xtrabackup.pp": "ebf4f4765fbbedbdc49acad9dd539a6b", - "manifests/bindings/client_dev.pp": "80753f1bf48de71d2ca1a6cfda4830be", - "manifests/bindings/daemon_dev.pp": "94d2d74afc2b247593877cebd548ed76", + "lib/facter/mysql_server_id.rb": "8074e28063136191d064de5bbd23d823", + "lib/facter/mysql_version.rb": "9e8e89de386bbbd74bac1c24c388ed61", + "lib/facter/mysqld_version.rb": "486159ed46fcfee7041fdded68e7141e", + "lib/puppet/parser/functions/mysql_deepmerge.rb": "02f390569a73c4bbd4abe4e61b143d91", + "lib/puppet/parser/functions/mysql_dirname.rb": "f5ba5f02c17ff20c0fa75b5740b5e3cf", + "lib/puppet/parser/functions/mysql_password.rb": "f36707af71748ddedf0d7fb9f578447a", + "lib/puppet/parser/functions/mysql_strip_hash.rb": "59f90ce7c6a5f96c3565ba2ef12a6e7e", + "lib/puppet/provider/mysql.rb": "e8eb54b79d4e8bb8edd77ab85ded97bd", + "lib/puppet/provider/mysql_database/mysql.rb": "12e6bfef70486ed4d8a4e731bfde89fa", + "lib/puppet/provider/mysql_datadir/mysql.rb": "2623a784e068b1c79780f53f23fb61ba", + "lib/puppet/provider/mysql_grant/mysql.rb": "e0a96951629bc906d45c8bc73f0d16d5", + "lib/puppet/provider/mysql_plugin/mysql.rb": "d0043d2fec34ab9d9839ecb2f5e6f494", + "lib/puppet/provider/mysql_user/mysql.rb": "f357e77fc5955c5381bebca8f705a164", + "lib/puppet/type/mysql_database.rb": "7a6bdb276df1c7f09201aee14d7aae06", + "lib/puppet/type/mysql_datadir.rb": "c35a31d2c715205852051006b8a40b0a", + "lib/puppet/type/mysql_grant.rb": "137e3e5103f6918da6cee2953887f60e", + "lib/puppet/type/mysql_plugin.rb": "a5b5cd85cba16663fdc551b22618e78a", + "lib/puppet/type/mysql_user.rb": "9df24a8900eb49191d47aea54d2fed2b", + "locales/config.yaml": "2fa67bcbae3c1f47b447359558142bb4", + "locales/ja/puppetlabs-mysql.po": "2cf26b43a97d4444f0af6e542b140a84", + "locales/puppetlabs-mysql.pot": "0bc1d574fc470daa825d2052b901f1c2", + "manifests/backup/mysqlbackup.pp": "eb0196dc9ee5f8a2eab9f28ad86cccec", + "manifests/backup/mysqldump.pp": "839a57d287f80cad3d479948259cb260", + "manifests/backup/xtrabackup.pp": "d210e10869f6b39c8b005922d08450e1", + "manifests/bindings/client_dev.pp": "abd14519e597ea62b1828aaaf2f5a55f", + "manifests/bindings/daemon_dev.pp": "edb7597b1c1cbe32bf2ff430f951c120", "manifests/bindings/java.pp": "556b743dc162d2f3264708b0b7ba0328", "manifests/bindings/perl.pp": "4ecbd448ceac580a07df34b5d3e24837", "manifests/bindings/php.pp": "641139f1f27085b8e72ac73fb8bc39d8", "manifests/bindings/python.pp": "ef9e674237eddd7e98ab307131b11069", "manifests/bindings/ruby.pp": "32b0a32161f7a5b50562cb8e154207d9", - "manifests/bindings.pp": "8becf04105d44910f12986a58cd566f7", + "manifests/bindings.pp": "8f372370f060c4dec35a8c85fd0f7afd", "manifests/client/install.pp": "7b5810404cc9411ec38de404749f1266", - "manifests/client.pp": "c350bd6d108acb03a87b860b14d225ef", - "manifests/db.pp": "fada45e451ec7563dab714d12b9e330b", - "manifests/params.pp": "816c5cf78525ab2917da4ce1a888dfe6", + "manifests/client.pp": "4a11410bc57551cc1f527a99232c14f0", + "manifests/db.pp": "7314311b9db228fa334ccbe9c2aac123", + "manifests/params.pp": "70f8668147ffc91ce45c04be94ff91be", "manifests/server/account_security.pp": "36a293eec189ec1bdfe92b370d087085", - "manifests/server/backup.pp": "6ed4f8c9aac5d7f17bf5c10fceddde41", + "manifests/server/backup.pp": "37d4d13f648c4a2abc98897fd87aa992", "manifests/server/binarylog.pp": "d61af28d0f9c07cfa23c63a7cdd364bf", - "manifests/server/config.pp": "650f0ba40b9148e66f910465e63b1170", + "manifests/server/config.pp": "3f3f8a5759bf3fe5d9faee7cd6ba8cec", "manifests/server/install.pp": "3cbbf313b940b582e73c229f4a8c0720", - "manifests/server/installdb.pp": "ccc13d3cbeb78b0c144006a256e40079", + "manifests/server/installdb.pp": "d02c623948bebc685cdb5fddab55c979", "manifests/server/monitor.pp": "3810b5d756a3661e92d709115982cd59", - "manifests/server/mysqltuner.pp": "24d04e0b24cf3b31b6798bc76eed32b6", + "manifests/server/mysqltuner.pp": "f2069ade4000db344c7d2881e164cf1b", "manifests/server/providers.pp": "87a019dce5bbb6b18c9aa61b5f99134c", "manifests/server/root_password.pp": "5790e04defe2a64d145975abdfcfd3ac", - "manifests/server/service.pp": "e9d4256c2830a8b300822616c408ce95", - "manifests/server.pp": "3f3915a73ff075eca009f5656b225e6d", - "metadata.json": "2cc79c0e6902c12c1b33eca2e192ea29", - "spec/acceptance/mysql_backup_spec.rb": "ef6f0d033e87a8a9f8457f89ad8ea118", - "spec/acceptance/mysql_db_spec.rb": "c093f0d25c7000713b444706b6cfd1c7", - "spec/acceptance/mysql_helper.rb": "b95d8fd15325f1ece1cd652dc60c7608", - "spec/acceptance/mysql_server_spec.rb": "b3362859a6cdc38cfabf1c5a63a4fc57", + "manifests/server/service.pp": "d431a99dbc0ce440703377f197ff4636", + "manifests/server.pp": "b4a758b25abd810f86e7cdcd02cf3826", + "metadata.json": "45b197f3a02e6cd0966150dc92662af6", + "readmes/README_ja_JP.md": "a5153d4033623817e243335db5b4c37c", + "spec/acceptance/locales_spec.rb": "a6d43405b499b8166b732841a519edd9", + "spec/acceptance/mysql_backup_spec.rb": "4c6a7de317c5d8519338d3f5285eae5f", + "spec/acceptance/mysql_db_spec.rb": "cc23120fecd30fc1689ebbbd976c03c3", + "spec/acceptance/mysql_helper.rb": "57725b6252fd5b6e47dc45bfdf06d548", + "spec/acceptance/mysql_server_spec.rb": "2e9af92109854e7b8fde5e15169737c3", "spec/acceptance/nodesets/centos-7-x64.yml": "a713f3abd3657f0ae2878829badd23cd", "spec/acceptance/nodesets/debian-8-x64.yml": "d2d2977900989f30086ad251a14a1f39", "spec/acceptance/nodesets/default.yml": "b42da5a1ea0c964567ba7495574b8808", "spec/acceptance/nodesets/docker/centos-7.yml": "8a3892807bdd62306ae4774f41ba11ae", "spec/acceptance/nodesets/docker/debian-8.yml": "ac8e871d1068c96de5e85a89daaec6df", "spec/acceptance/nodesets/docker/ubuntu-14.04.yml": "dc42ee922a96908d85b8f0f08203ce58", - "spec/acceptance/types/mysql_database_spec.rb": "047db055103fa9782bc6714297eb2a09", - "spec/acceptance/types/mysql_grant_spec.rb": "216d93f0937dbdb5fc58a61bd2150d62", - "spec/acceptance/types/mysql_plugin_spec.rb": "107f32d267daa847996ff992ccec8c06", - "spec/acceptance/types/mysql_user_spec.rb": "5d04dc3b3ffd0778f83038833ef72bf2", - "spec/classes/graceful_failures_spec.rb": "91481f693c3f71dff22524189438bcc6", - "spec/classes/mycnf_template_spec.rb": "07fc36d51b592eba1f94d39208c2701f", - "spec/classes/mysql_bindings_spec.rb": "14c5abbe4ae20278d1a4a02254bf312b", - "spec/classes/mysql_client_spec.rb": "b1fa7a5a06585697f7100d1891d359ed", - "spec/classes/mysql_server_account_security_spec.rb": "97b6caf04a7a75a88e58728edcfc11cb", - "spec/classes/mysql_server_backup_spec.rb": "964357b46daa237c92cc61b88a20093b", - "spec/classes/mysql_server_monitor_spec.rb": "aef3aa73265b42b66b963a09e5f32f1f", - "spec/classes/mysql_server_mysqltuner_spec.rb": "55ff6dad45a8dfef97d52dff0b111a36", - "spec/classes/mysql_server_spec.rb": "99806ad51b124bf8ca9dad201962b743", - "spec/defines/mysql_db_spec.rb": "afb2d6cfa051dd4d8301d7aede1aa1c4", - "spec/spec.opts": "a600ded995d948e393fbe2320ba8e51c", - "spec/spec_helper.rb": "b2db3bc02b4ac2fd5142a6621c641b07", - "spec/spec_helper_acceptance.rb": "2d7d8e8a6d1225ba6bf57a4f05dfff0c", - "spec/spec_helper_local.rb": "05db024c91eb5d5141b67d97b01a58b4", - "spec/unit/facter/mysql_server_id_spec.rb": "4a01f2323a400c82d89f37847c3c9611", - "spec/unit/facter/mysql_version_spec.rb": "f593c725b83a7bbf1f0fdc13bf1531df", - "spec/unit/facter/mysqld_version_spec.rb": "f5495c63a64d21be175d329cc5a3a8cd", - "spec/unit/puppet/functions/mysql_deepmerge_spec.rb": "f6102e1f82fb9f4aa38cbf3955ee5973", - "spec/unit/puppet/functions/mysql_password_spec.rb": "8fe68dc4ec13fc6ade18defe54cac8d4", - "spec/unit/puppet/provider/mysql_database/mysql_spec.rb": "98a799433ac10b237ac3ad27441610d4", - "spec/unit/puppet/provider/mysql_plugin/mysql_spec.rb": "914bac73bb9841ec7d7041488a55d442", - "spec/unit/puppet/provider/mysql_user/mysql_spec.rb": "174e7e3a97529fdcc2e6ba24e65cf8d2", - "spec/unit/puppet/type/mysql_database_spec.rb": "9fa0d390c2e15c8a52fc2b981e2a63fc", - "spec/unit/puppet/type/mysql_grant_spec.rb": "1a003358dc88a74ef21fb33fc71debef", - "spec/unit/puppet/type/mysql_plugin_spec.rb": "7ebacf228dfd0c60811bdf8a28a329ff", - "spec/unit/puppet/type/mysql_user_spec.rb": "e902ad1b9578dce35e13750c7967ef1d", + "spec/acceptance/sql_task_spec.rb": "da17cc053c665660b84e4d1c35a7b84c", + "spec/acceptance/types/mysql_database_spec.rb": "d0159f8b1d11d76196b73e2750f2bfaf", + "spec/acceptance/types/mysql_grant_spec.rb": "731da76dd9f5e32ea99d4e941e724d7d", + "spec/acceptance/types/mysql_plugin_spec.rb": "d13bb3d3f52ff6dc1e1cf62f5714a330", + "spec/acceptance/types/mysql_user_spec.rb": "ec8f4a1e59f6b5d2bac4fda1b8aeb76c", + "spec/classes/graceful_failures_spec.rb": "b87bf88de1903d81765ea2823e30b13f", + "spec/classes/mycnf_template_spec.rb": "9f99dafd8d5f593ea50e68b2b9896bfc", + "spec/classes/mysql_bindings_spec.rb": "be28913fd5f8a394d1b6cac2fa6cf71c", + "spec/classes/mysql_client_spec.rb": "da69cadaa56676ab232317c0b2255ec5", + "spec/classes/mysql_server_account_security_spec.rb": "fa9089b55ba0839a601e1b487d6f6958", + "spec/classes/mysql_server_backup_spec.rb": "476160ee6579495309ec11c2a081fdd9", + "spec/classes/mysql_server_monitor_spec.rb": "f0b735429447068fc13a1d57b1d4aff0", + "spec/classes/mysql_server_mysqltuner_spec.rb": "b353330180fedb94dff9a242acf8f729", + "spec/classes/mysql_server_spec.rb": "0864ef71c380bd9ecc6e4047b29a1a1a", + "spec/default_facts.yml": "4de3cb611af6981a6d22bc77d7dd6f6f", + "spec/defines/mysql_db_spec.rb": "36cb0dc2498e584fc4a4ac536c70d9aa", + "spec/spec_helper.rb": "182136c8450f0af179fa0705ce971587", + "spec/spec_helper_acceptance.rb": "f7aaeb1857cc317d1e3d9ad8b5a3581a", + "spec/spec_helper_local.rb": "35d201e4b56adf60407d84c2a231b9ff", + "spec/unit/facter/mysql_server_id_spec.rb": "6cd165396028f68de96b8e66f1acadb6", + "spec/unit/facter/mysql_version_spec.rb": "0e555c398b189e20648ae6a037d106f6", + "spec/unit/facter/mysqld_version_spec.rb": "a7b04baa4f232ef22736e20600403ccb", + "spec/unit/puppet/functions/mysql_deepmerge_spec.rb": "dde2c9dd2efea331cada355ea7900ae8", + "spec/unit/puppet/functions/mysql_password_spec.rb": "9dea15d09ede3408822430ef005150b4", + "spec/unit/puppet/provider/mysql_database/mysql_spec.rb": "90d2c9fd6eb263776700d84183cb0cf8", + "spec/unit/puppet/provider/mysql_plugin/mysql_spec.rb": "033d476b84e766a455b7bfd403a67c2d", + "spec/unit/puppet/provider/mysql_user/mysql_spec.rb": "2dacc48e089d7d33d33e641d5abca556", + "spec/unit/puppet/type/mysql_database_spec.rb": "8e790bec45c59bc48544d7ac446b2f25", + "spec/unit/puppet/type/mysql_grant_spec.rb": "804c6c2a79f71f9b89a94e3cec5c10f0", + "spec/unit/puppet/type/mysql_plugin_spec.rb": "c4bfe6319219c10142667af520e09e2b", + "spec/unit/puppet/type/mysql_user_spec.rb": "361d4144d230adcf3597a6873145ad88", + "tasks/export.json": "7ecc5b7b20318fa6b23080fb3929ebf8", + "tasks/export.rb": "bed98c19b371cef7f4b1a54d273842de", + "tasks/sql.json": "f57ad96a8079e6729ff7557f9ac6fa62", + "tasks/sql.rb": "b6428a942317640b2b23d2776faac505", "templates/meb.cnf.erb": "b6422b19ee97b8a2883bfac44fdc0292", "templates/my.cnf.erb": "535d2ff37fea6b11ad928224965143d3", "templates/my.cnf.pass.erb": "11f80afb0993a436f074a43f70733999", - "templates/mysqlbackup.sh.erb": "0cc74138c7a5dd5d3864f94227717bd4", - "templates/xtrabackup.sh.erb": "219b487c4faad80a897cda6973b81741" + "templates/mysqlbackup.sh.erb": "7546eb67fc7f76d9d235e27da11b9e13", + "templates/xtrabackup.sh.erb": "ebcf249f36fd947e2daf5cff92367a14" } \ No newline at end of file diff -Nru puppet-module-puppetlabs-mysql-3.10.0/CONTRIBUTING.md puppet-module-puppetlabs-mysql-5.3.0/CONTRIBUTING.md --- puppet-module-puppetlabs-mysql-3.10.0/CONTRIBUTING.md 2016-09-06 22:04:13.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/CONTRIBUTING.md 2017-10-05 23:11:56.000000000 +0000 @@ -1,63 +1,75 @@ -Checklist (and a short version for the impatient) -================================================= +# Contributing to Puppet modules - * Commits: +So you want to contribute to a Puppet module: Great! Below are some instructions to get you started doing +that very thing while setting expectations around code quality as well as a few tips for making the +process as easy as possible. - - Make commits of logical units. +### Table of Contents - - Check for unnecessary whitespace with "git diff --check" before - committing. +1. [Getting Started](#getting-started) +1. [Commit Checklist](#commit-checklist) +1. [Submission](#submission) +1. [More about commits](#more-about-commits) +1. [Testing](#testing) + - [Running Tests](#running-tests) + - [Writing Tests](#writing-tests) +1. [Get Help](#get-help) - - Commit using Unix line endings (check the settings around "crlf" in - git-config(1)). +## Getting Started - - Do not check in commented out code or unneeded files. +- Fork the module repository on GitHub and clone to your workspace - - The first line of the commit message should be a short - description (50 characters is the soft limit, excluding ticket - number(s)), and should skip the full stop. +- Make your changes! - - Associate the issue in the message. The first line should include - the issue number in the form "(#XXXX) Rest of message". +## Commit Checklist - - The body should provide a meaningful commit message, which: +### The Basics - - uses the imperative, present tense: "change", not "changed" or - "changes". +- [x] my commit is a single logical unit of work - - includes motivation for the change, and contrasts its - implementation with the previous behavior. +- [x] I have checked for unnecessary whitespace with "git diff --check" - - Make sure that you have tests for the bug you are fixing, or - feature you are adding. +- [x] my commit does not include commented out code or unneeded files - - Make sure the test suites passes after your commit: - `bundle exec rspec spec/acceptance` More information on [testing](#Testing) below +### The Content - - When introducing a new feature, make sure it is properly - documented in the README.md +- [x] my commit includes tests for the bug I fixed or feature I added - * Submission: +- [x] my commit includes appropriate documentation changes if it is introducing a new feature or changing existing functionality + +- [x] my code passes existing test suites - * Pre-requisites: +### The Commit Message - - Make sure you have a [GitHub account](https://github.com/join) +- [x] the first line of my commit message includes: - - [Create a ticket](https://tickets.puppetlabs.com/secure/CreateIssue!default.jspa), or [watch the ticket](https://tickets.puppetlabs.com/browse/) you are patching for. + - [x] an issue number (if applicable), e.g. "(MODULES-xxxx) This is the first line" + + - [x] a short description (50 characters is the soft limit, excluding ticket number(s)) - * Preferred method: +- [x] the body of my commit message: - - Fork the repository on GitHub. + - [x] is meaningful - - Push your changes to a topic branch in your fork of the - repository. (the format ticket/1234-short_description_of_change is - usually preferred for this project). + - [x] uses the imperative, present tense: "change", not "changed" or "changes" - - Submit a pull request to the repository in the puppetlabs - organization. + - [x] includes motivation for the change, and contrasts its implementation with the previous behavior -The long version -================ +## Submission + +### Pre-requisites + +- Make sure you have a [GitHub account](https://github.com/join) + +- [Create a ticket](https://tickets.puppet.com/secure/CreateIssue!default.jspa), or [watch the ticket](https://tickets.puppet.com/browse/) you are patching for. + +### Push and PR + +- Push your changes to your fork + +- [Open a Pull Request](https://help.github.com/articles/creating-a-pull-request-from-a-fork/) against the repository in the puppetlabs organization + +## More about commits 1. Make separate commits for logically separate changes. @@ -104,37 +116,32 @@ GitHub has some pretty good [general documentation](http://help.github.com/) on using their site. They also have documentation on - [creating pull requests](http://help.github.com/send-pull-requests/). + [creating pull requests](https://help.github.com/articles/creating-a-pull-request-from-a-fork/). In general, after pushing your topic branch up to your repository on GitHub, you can switch to the branch in the GitHub UI and click "Pull Request" towards the top of the page in order to open a pull request. + 3. Update the related JIRA issue. - 3. Update the related GitHub issue. - - If there is a GitHub issue associated with the change you + If there is a JIRA issue associated with the change you submitted, then you should update the ticket to include the location of your branch, along with any other commentary you may wish to make. -Testing -======= +# Testing -Getting Started ---------------- +## Getting Started -Our puppet modules provide [`Gemfile`](./Gemfile)s which can tell a ruby -package manager such as [bundler](http://bundler.io/) what Ruby packages, +Our Puppet modules provide [`Gemfile`](./Gemfile)s, which can tell a Ruby package manager such as [bundler](http://bundler.io/) what Ruby packages, or Gems, are required to build, develop, and test this software. -Please make sure you have [bundler installed](http://bundler.io/#getting-started) -on your system, then use it to install all dependencies needed for this project, -by running +Please make sure you have [bundler installed](http://bundler.io/#getting-started) on your system, and then use it to +install all dependencies needed for this project in the project root by running ```shell -% bundle install +% bundle install --path .bundle/gems Fetching gem metadata from https://rubygems.org/........ Fetching gem metadata from https://rubygems.org/.. Using rake (10.1.0) @@ -148,7 +155,7 @@ Use `bundle show [gemname]` to see where a bundled gem is installed. ``` -NOTE some systems may require you to run this command with sudo. +NOTE: some systems may require you to run this command with sudo. If you already have those gems installed, make sure they are up-to-date: @@ -156,26 +163,27 @@ % bundle update ``` -With all dependencies in place and up-to-date we can now run the tests: +## Running Tests + +With all dependencies in place and up-to-date, run the tests: + +### Unit Tests ```shell % bundle exec rake spec ``` -This will execute all the [rspec tests](http://rspec-puppet.com/) tests -under [spec/defines](./spec/defines), [spec/classes](./spec/classes), -and so on. rspec tests may have the same kind of dependencies as the -module they are testing. While the module defines in its [Modulefile](./Modulefile), +This executes all the [rspec tests](http://rspec-puppet.com/) in the directories defined [here](https://github.com/puppetlabs/puppetlabs_spec_helper/blob/699d9fbca1d2489bff1736bb254bb7b7edb32c74/lib/puppetlabs_spec_helper/rake_tasks.rb#L17) and so on. +rspec tests may have the same kind of dependencies as the module they are testing. Although the module defines these dependencies in its [metadata.json](./metadata.json), rspec tests define them in [.fixtures.yml](./fixtures.yml). -Some puppet modules also come with [beaker](https://github.com/puppetlabs/beaker) -tests. These tests spin up a virtual machine under -[VirtualBox](https://www.virtualbox.org/)) with, controlling it with -[Vagrant](http://www.vagrantup.com/) to actually simulate scripted test -scenarios. In order to run these, you will need both of those tools -installed on your system. +### Acceptance Tests -You can run them by issuing the following command +Some Puppet modules also come with acceptance tests, which use [beaker][]. These tests spin up a virtual machine under +[VirtualBox](https://www.virtualbox.org/), controlled with [Vagrant](http://www.vagrantup.com/), to simulate scripted test +scenarios. In order to run these, you need both Virtualbox and Vagrant installed on your system. + +Run the tests by issuing the following command ```shell % bundle exec rake spec_clean @@ -183,36 +191,81 @@ ``` This will now download a pre-fabricated image configured in the [default node-set](./spec/acceptance/nodesets/default.yml), -install puppet, copy this module and install its dependencies per [spec/spec_helper_acceptance.rb](./spec/spec_helper_acceptance.rb) +install Puppet, copy this module, and install its dependencies per [spec/spec_helper_acceptance.rb](./spec/spec_helper_acceptance.rb) and then run all the tests under [spec/acceptance](./spec/acceptance). -Writing Tests -------------- +## Writing Tests -XXX getting started writing tests. +### Unit Tests -If you have commit access to the repository -=========================================== +When writing unit tests for Puppet, [rspec-puppet][] is your best friend. It provides tons of helper methods for testing your manifests against a +catalog (e.g. contain_file, contain_package, with_params, etc). It would be ridiculous to try and top rspec-puppet's [documentation][rspec-puppet_docs] +but here's a tiny sample: -Even if you have commit access to the repository, you will still need to -go through the process above, and have someone else review and merge -in your changes. The rule is that all changes must be reviewed by a -developer on the project (that did not write the code) to ensure that -all changes go through a code review process. +Sample manifest: -Having someone other than the author of the topic branch recorded as -performing the merge is the record that they performed the code -review. +```puppet +file { "a test file": + ensure => present, + path => "/etc/sample", +} +``` +Sample test: -Additional Resources -==================== +```ruby +it 'does a thing' do + expect(subject).to contain_file("a test file").with({:path => "/etc/sample"}) +end +``` -* [Getting additional help](http://puppet.com/community/get-help) +### Acceptance Tests -* [Writing tests](https://docs.puppet.com/guides/module_guides/bgtm.html#step-three-module-testing) +Writing acceptance tests for Puppet involves [beaker][] and its cousin [beaker-rspec][]. A common pattern for acceptance tests is to create a test manifest, apply it +twice to check for idempotency or errors, then run expectations. -* [General GitHub documentation](http://help.github.com/) +```ruby +it 'does an end-to-end thing' do + pp = <<-EOF + file { 'a test file': + ensure => present, + path => "/etc/sample", + content => "test string", + } + + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + +end + +describe file("/etc/sample") do + it { is_expected.to contain "test string" } +end + +``` + +# If you have commit access to the repository + +Even if you have commit access to the repository, you still need to go through the process above, and have someone else review and merge +in your changes. The rule is that **all changes must be reviewed by a project developer that did not write the code to ensure that +all changes go through a code review process.** +The record of someone performing the merge is the record that they performed the code review. Again, this should be someone other than the author of the topic branch. + +# Get Help + +### On the web +* [Puppet help messageboard](http://puppet.com/community/get-help) +* [Writing tests](https://docs.puppet.com/guides/module_guides/bgtm.html#step-three-module-testing) +* [General GitHub documentation](http://help.github.com/) * [GitHub pull request documentation](http://help.github.com/send-pull-requests/) +### On chat +* Slack (slack.puppet.com) #forge-modules, #puppet-dev, #windows, #voxpupuli +* IRC (freenode) #puppet-dev, #voxpupuli + + +[rspec-puppet]: http://rspec-puppet.com/ +[rspec-puppet_docs]: http://rspec-puppet.com/documentation/ +[beaker]: https://github.com/puppetlabs/beaker +[beaker-rspec]: https://github.com/puppetlabs/beaker-rspec diff -Nru puppet-module-puppetlabs-mysql-3.10.0/debian/changelog puppet-module-puppetlabs-mysql-5.3.0/debian/changelog --- puppet-module-puppetlabs-mysql-3.10.0/debian/changelog 2016-11-19 10:01:22.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/debian/changelog 2019-01-16 02:01:05.000000000 +0000 @@ -1,3 +1,33 @@ +puppet-module-puppetlabs-mysql (5.3.0-1ubuntu1) disco; urgency=medium + + * d/tests/spec/localhost/use_spec.rb: Check for mysql-{client,server} on + Ubuntu instead of mariadb-{client,server}. + + -- Logan Rosen Tue, 15 Jan 2019 21:01:05 -0500 + +puppet-module-puppetlabs-mysql (5.3.0-1) unstable; urgency=medium + + [ Thomas Bechtold ] + * Remove myself from Uploaders (Closes: #892676) + + [ Sebastien Badia ] + * New upstream version 5.3.0 (LP: #1581812) + * d/compat: Bump compat version to 11 + * d/docs: Add missing NOTICE file (for Apache2 license) + * d/upstream: Added Upstream metadata + * d/copyright: + + Remove unused license + + Update copyright years and fix globing + * d/control: + + Use salsa.debian.org in Vcs-* fields + + Added myself as Uploader + + Bump to Standards-Version 4.1.4 (no changes needed) + + Fix dependencies according new upstream (Closes: #893471) + + Added Rules-Requires-Root option + * d/watch: Bump to version 4 and use HTTPS for URI + + -- Sebastien Badia Sun, 29 Apr 2018 15:59:36 +0200 + puppet-module-puppetlabs-mysql (3.10.0-1) unstable; urgency=medium * Imported upstream release 3.10.0 diff -Nru puppet-module-puppetlabs-mysql-3.10.0/debian/compat puppet-module-puppetlabs-mysql-5.3.0/debian/compat --- puppet-module-puppetlabs-mysql-3.10.0/debian/compat 2016-11-19 10:01:22.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/debian/compat 2018-03-21 21:45:03.000000000 +0000 @@ -1 +1 @@ -10 +11 diff -Nru puppet-module-puppetlabs-mysql-3.10.0/debian/control puppet-module-puppetlabs-mysql-5.3.0/debian/control --- puppet-module-puppetlabs-mysql-3.10.0/debian/control 2016-11-19 10:01:22.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/debian/control 2019-01-16 02:01:05.000000000 +0000 @@ -1,20 +1,24 @@ Source: puppet-module-puppetlabs-mysql -Maintainer: Puppet Package Maintainers +Maintainer: Ubuntu Developers +XSBC-Original-Maintainer: Puppet Package Maintainers Uploaders: Stig Sandbeck Mathisen , - Thomas Bechtold + Sebastien Badia Section: admin Priority: optional -Build-Depends: debhelper (>= 10) -Standards-Version: 3.9.8 -Vcs-Browser: https://anonscm.debian.org/cgit/pkg-puppet/puppet-module-puppetlabs-mysql.git -Vcs-Git: https://anonscm.debian.org/git/pkg-puppet/puppet-module-puppetlabs-mysql.git +Build-Depends: debhelper (>= 11~) +Standards-Version: 4.1.4 +Rules-Requires-Root: no +Vcs-Browser: https://salsa.debian.org/puppet-team/puppet-module-puppetlabs-mysql +Vcs-Git: https://salsa.debian.org/puppet-team/puppet-module-puppetlabs-mysql.git Homepage: https://forge.puppet.com/puppetlabs/mysql Package: puppet-module-puppetlabs-mysql Architecture: all -Depends: ${misc:Depends}, - puppet (>= 4) | puppet-common (>= 3), - puppet-module-puppetlabs-stdlib +Depends: puppet (>= 4) | puppet-common (>= 3), + puppet-module-nanliu-staging, + puppet-module-puppetlabs-stdlib, + puppet-module-puppetlabs-translate, + ${misc:Depends} Description: Puppet module for MySQL Puppet lets you centrally manage every important aspect of your system using a cross-platform specification language that manages all the diff -Nru puppet-module-puppetlabs-mysql-3.10.0/debian/copyright puppet-module-puppetlabs-mysql-5.3.0/debian/copyright --- puppet-module-puppetlabs-mysql-3.10.0/debian/copyright 2016-11-19 10:01:22.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/debian/copyright 2018-03-21 21:49:51.000000000 +0000 @@ -2,12 +2,13 @@ Upstream-Name: puppetlabs-mysql Source: https://forge.puppetlabs.com/puppetlabs/mysql -Files: debian/* -Copyright: 2013 Thomas Bechtold +Files: * +Copyright: 2013-2018 Puppet Labs Inc License: Apache-2.0 -Files: * -Copyright: 2013 Puppet Labs Inc +Files: debian/* +Copyright: 2013 Thomas Bechtold + 2018 Sebastien Badia License: Apache-2.0 License: Apache-2.0 @@ -25,17 +26,3 @@ . On Debian systems, the complete text of the Apache License 2.0 can be found in "/usr/share/common-licenses/Apache-2.0" - -License: GPL-3+ - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - . - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - . - On Debian systems, the complete text of the GPL-3 can be found in - "/usr/share/common-licenses/GPL-3" diff -Nru puppet-module-puppetlabs-mysql-3.10.0/debian/puppet-module-puppetlabs-mysql.docs puppet-module-puppetlabs-mysql-5.3.0/debian/puppet-module-puppetlabs-mysql.docs --- puppet-module-puppetlabs-mysql-3.10.0/debian/puppet-module-puppetlabs-mysql.docs 2016-11-19 10:01:22.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/debian/puppet-module-puppetlabs-mysql.docs 2018-03-21 21:49:58.000000000 +0000 @@ -1 +1,2 @@ README.md +NOTICE diff -Nru puppet-module-puppetlabs-mysql-3.10.0/debian/rules puppet-module-puppetlabs-mysql-5.3.0/debian/rules --- puppet-module-puppetlabs-mysql-3.10.0/debian/rules 2016-11-19 10:01:22.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/debian/rules 2018-04-29 13:24:01.000000000 +0000 @@ -2,3 +2,6 @@ %: dh $@ +override_dh_fixperms: + dh_fixperms + chmod -x $(CURDIR)/debian/puppet-module-puppetlabs-mysql/usr/share/puppet/modules.available/puppetlabs-mysql/templates/mysqlbackup.sh.erb diff -Nru puppet-module-puppetlabs-mysql-3.10.0/debian/upstream/metadata puppet-module-puppetlabs-mysql-5.3.0/debian/upstream/metadata --- puppet-module-puppetlabs-mysql-3.10.0/debian/upstream/metadata 1970-01-01 00:00:00.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/debian/upstream/metadata 2018-03-22 00:33:35.000000000 +0000 @@ -0,0 +1,4 @@ +--- +Name: puppetlabs-mysql +Repository: https://github.com/puppetlabs/puppetlabs-mysql.git +Repository-Browse: https://github.com/puppetlabs/puppetlabs-mysql diff -Nru puppet-module-puppetlabs-mysql-3.10.0/debian/watch puppet-module-puppetlabs-mysql-5.3.0/debian/watch --- puppet-module-puppetlabs-mysql-3.10.0/debian/watch 2016-11-19 10:01:22.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/debian/watch 2018-03-21 21:50:25.000000000 +0000 @@ -1,2 +1,2 @@ -version=3 -http://qa.debian.org/cgi-bin/fakeupstream.cgi?upstream=forge.puppetlabs/puppetlabs/mysql .*/puppetlabs-mysql-(.+)\.tar\.gz +version=4 +https://qa.debian.org/cgi-bin/fakeupstream.cgi?upstream=forge.puppetlabs/puppetlabs/mysql .*/puppetlabs-mysql-(.+)\.tar\.gz diff -Nru puppet-module-puppetlabs-mysql-3.10.0/Gemfile puppet-module-puppetlabs-mysql-5.3.0/Gemfile --- puppet-module-puppetlabs-mysql-3.10.0/Gemfile 2016-11-07 20:14:07.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/Gemfile 2018-02-20 14:54:26.000000000 +0000 @@ -1,52 +1,137 @@ -#This file is generated by ModuleSync, do not edit. +source ENV['GEM_SOURCE'] || 'https://rubygems.org' -source ENV['GEM_SOURCE'] || "https://rubygems.org" +def location_for(place_or_version, fake_version = nil) + if place_or_version =~ %r{\A(git[:@][^#]*)#(.*)} + [fake_version, { git: Regexp.last_match(1), branch: Regexp.last_match(2), require: false }].compact + elsif place_or_version =~ %r{\Afile:\/\/(.*)} + ['>= 0', { path: File.expand_path(Regexp.last_match(1)), require: false }] + else + [place_or_version, { require: false }] + end +end -def location_from_env(env, default_location = []) - if location = ENV[env] - if location =~ /^((?:git|https?)[:@][^#]*)#(.*)/ - [{ :git => $1, :branch => $2, :require => false }] - elsif location =~ /^file:\/\/(.*)/ - ['>= 0', { :path => File.expand_path($1), :require => false }] - else - [location, { :require => false }] - end +def gem_type(place_or_version) + if place_or_version =~ %r{\Agit[:@]} + :git + elsif !place_or_version.nil? && place_or_version.start_with?('file:') + :file else - default_location + :gem end end -group :development, :unit_tests do - gem 'metadata-json-lint' - gem 'puppet_facts' - gem 'puppet-blacksmith', '>= 3.4.0' - gem 'puppetlabs_spec_helper', '>= 1.2.1' - gem 'rspec-puppet', '>= 2.3.2' - gem 'rspec-puppet-facts' - gem 'mocha', '< 1.2.0' - gem 'simplecov' - gem 'parallel_tests', '< 2.10.0' if RUBY_VERSION < '2.0.0' - gem 'parallel_tests' if RUBY_VERSION >= '2.0.0' - gem 'rubocop', '0.41.2' if RUBY_VERSION < '2.0.0' - gem 'rubocop' if RUBY_VERSION >= '2.0.0' - gem 'rubocop-rspec', '~> 1.6' if RUBY_VERSION >= '2.3.0' - gem 'json_pure', '<= 2.0.1' if RUBY_VERSION < '2.0.0' - gem 'rspec-puppet-facts' +ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments +minor_version = ruby_version_segments[0..1].join('.') + +group :development do + gem "fast_gettext", '1.1.0', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0') + gem "fast_gettext", require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0') + gem "json_pure", '<= 2.0.1', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0') + gem "json", '= 1.8.1', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9') + gem "puppet-module-posix-default-r#{minor_version}", require: false, platforms: [:ruby] + gem "puppet-module-posix-dev-r#{minor_version}", require: false, platforms: [:ruby] + gem "puppet-module-win-default-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem "puppet-module-win-dev-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem "puppet-blacksmith", '~> 3.4', require: false + gem "puppet-lint-i18n", require: false end group :system_tests do - gem 'beaker', *location_from_env('BEAKER_VERSION', []) if RUBY_VERSION >= '2.3.0' - gem 'beaker', *location_from_env('BEAKER_VERSION', ['< 3']) if RUBY_VERSION < '2.3.0' - gem 'beaker-pe' if RUBY_VERSION >= '2.3.0' - gem 'beaker-rspec', *location_from_env('BEAKER_RSPEC_VERSION', ['>= 3.4']) - gem 'serverspec' - gem 'beaker-puppet_install_helper' - gem 'master_manipulator' - gem 'beaker-hostgenerator', *location_from_env('BEAKER_HOSTGENERATOR_VERSION', []) + gem "puppet-module-posix-system-r#{minor_version}", require: false, platforms: [:ruby] + gem "puppet-module-win-system-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem "beaker", *location_for(ENV['BEAKER_VERSION'] || '~> 3.13') + gem "beaker-abs", *location_for(ENV['BEAKER_ABS_VERSION'] || '~> 0.1') + gem "beaker-pe", require: false + gem "beaker-hostgenerator" + gem "beaker-rspec" +end + +puppet_version = ENV['PUPPET_GEM_VERSION'] +puppet_type = gem_type(puppet_version) +facter_version = ENV['FACTER_GEM_VERSION'] +hiera_version = ENV['HIERA_GEM_VERSION'] + +def puppet_older_than?(version) + puppet_version = ENV['PUPPET_GEM_VERSION'] + !puppet_version.nil? && + Gem::Version.correct?(puppet_version) && + Gem::Requirement.new("< #{version}").satisfied_by?(Gem::Version.new(puppet_version.dup)) +end + +gems = {} + +gems['puppet'] = location_for(puppet_version) + +# If facter or hiera versions have been specified via the environment +# variables, use those versions. If not, and if the puppet version is < 3.5.0, +# use known good versions of both for puppet < 3.5.0. +if facter_version + gems['facter'] = location_for(facter_version) +elsif puppet_type == :gem && puppet_older_than?('3.5.0') + gems['facter'] = ['>= 1.6.11', '<= 1.7.5', require: false] +end + +if hiera_version + gems['hiera'] = location_for(ENV['HIERA_GEM_VERSION']) +elsif puppet_type == :gem && puppet_older_than?('3.5.0') + gems['hiera'] = ['>= 1.0.0', '<= 1.3.0', require: false] +end + +if Gem.win_platform? && (puppet_type != :gem || puppet_older_than?('3.5.0')) + # For Puppet gems < 3.5.0 (tested as far back as 3.0.0) on Windows + if puppet_type == :gem + gems['ffi'] = ['1.9.0', require: false] + gems['minitar'] = ['0.5.4', require: false] + gems['win32-eventlog'] = ['0.5.3', '<= 0.6.5', require: false] + gems['win32-process'] = ['0.6.5', '<= 0.7.5', require: false] + gems['win32-security'] = ['~> 0.1.2', '<= 0.2.5', require: false] + gems['win32-service'] = ['0.7.2', '<= 0.8.8', require: false] + else + gems['ffi'] = ['~> 1.9.0', require: false] + gems['minitar'] = ['~> 0.5.4', require: false] + gems['win32-eventlog'] = ['~> 0.5', '<= 0.6.5', require: false] + gems['win32-process'] = ['~> 0.6', '<= 0.7.5', require: false] + gems['win32-security'] = ['~> 0.1', '<= 0.2.5', require: false] + gems['win32-service'] = ['~> 0.7', '<= 0.8.8', require: false] + end + + gems['win32-dir'] = ['~> 0.3', '<= 0.4.9', require: false] + + if RUBY_VERSION.start_with?('1.') + gems['win32console'] = ['1.3.2', require: false] + # sys-admin was removed in Puppet 3.7.0 and doesn't compile under Ruby 2.x + gems['sys-admin'] = ['1.5.6', require: false] + end + + # Puppet < 3.7.0 requires these. + # Puppet >= 3.5.0 gem includes these as requirements. + # The following versions are tested to work with 3.0.0 <= puppet < 3.7.0. + gems['win32-api'] = ['1.4.8', require: false] + gems['win32-taskscheduler'] = ['0.2.2', require: false] + gems['windows-api'] = ['0.4.3', require: false] + gems['windows-pr'] = ['1.2.3', require: false] +elsif Gem.win_platform? + # If we're using a Puppet gem on Windows which handles its own win32-xxx gem + # dependencies (>= 3.5.0), set the maximum versions (see PUP-6445). + gems['win32-dir'] = ['<= 0.4.9', require: false] + gems['win32-eventlog'] = ['<= 0.6.5', require: false] + gems['win32-process'] = ['<= 0.7.5', require: false] + gems['win32-security'] = ['<= 0.2.5', require: false] + gems['win32-service'] = ['<= 0.8.8', require: false] end -gem 'facter', *location_from_env('FACTER_GEM_VERSION') -gem 'puppet', *location_from_env('PUPPET_GEM_VERSION') +gems.each do |gem_name, gem_params| + gem gem_name, *gem_params +end + +# Evaluate Gemfile.local and ~/.gemfile if they exist +extra_gemfiles = [ + "#{__FILE__}.local", + File.join(Dir.home, '.gemfile'), +] -if File.exists? "#{__FILE__}.local" - eval(File.read("#{__FILE__}.local"), binding) +extra_gemfiles.each do |gemfile| + if File.file?(gemfile) && File.readable?(gemfile) + eval(File.read(gemfile), binding) + end end +# vim: syntax=ruby diff -Nru puppet-module-puppetlabs-mysql-3.10.0/lib/facter/mysqld_version.rb puppet-module-puppetlabs-mysql-5.3.0/lib/facter/mysqld_version.rb --- puppet-module-puppetlabs-mysql-3.10.0/lib/facter/mysqld_version.rb 2016-11-07 20:14:07.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/lib/facter/mysqld_version.rb 2017-09-07 12:06:56.000000000 +0000 @@ -1,4 +1,4 @@ -Facter.add("mysqld_version") do +Facter.add('mysqld_version') do setcode do Facter::Util::Resolution.exec('mysqld -V 2>/dev/null') end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/lib/facter/mysql_server_id.rb puppet-module-puppetlabs-mysql-5.3.0/lib/facter/mysql_server_id.rb --- puppet-module-puppetlabs-mysql-3.10.0/lib/facter/mysql_server_id.rb 2016-09-06 22:04:13.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/lib/facter/mysql_server_id.rb 2017-09-07 12:06:56.000000000 +0000 @@ -1,9 +1,13 @@ -def get_mysql_id - Facter.value(:macaddress).split(':')[2..-1].inject(0) { |total,value| (total << 6) + value.hex } +def mysql_id_get + Facter.value(:macaddress).split(':')[2..-1].reduce(0) { |total, value| (total << 6) + value.hex } end -Facter.add("mysql_server_id") do +Facter.add('mysql_server_id') do setcode do - get_mysql_id rescue nil + begin + mysql_id_get + rescue + nil + end end end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/lib/facter/mysql_version.rb puppet-module-puppetlabs-mysql-5.3.0/lib/facter/mysql_version.rb --- puppet-module-puppetlabs-mysql-3.10.0/lib/facter/mysql_version.rb 2016-07-27 17:34:11.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/lib/facter/mysql_version.rb 2017-09-07 12:06:56.000000000 +0000 @@ -1,8 +1,6 @@ -Facter.add("mysql_version") do +Facter.add('mysql_version') do setcode do mysql_ver = Facter::Util::Resolution.exec('mysql --version') - if mysql_ver - mysql_ver.match(/\d+\.\d+\.\d+/)[0] - end + mysql_ver.match(%r{\d+\.\d+\.\d+})[0] if mysql_ver end end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/lib/puppet/parser/functions/mysql_deepmerge.rb puppet-module-puppetlabs-mysql-5.3.0/lib/puppet/parser/functions/mysql_deepmerge.rb --- puppet-module-puppetlabs-mysql-3.10.0/lib/puppet/parser/functions/mysql_deepmerge.rb 2016-07-27 17:34:06.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/lib/puppet/parser/functions/mysql_deepmerge.rb 2017-10-05 23:11:56.000000000 +0000 @@ -1,5 +1,6 @@ +# Recursively merges two or more hashes together and returns the resulting hash. module Puppet::Parser::Functions - newfunction(:mysql_deepmerge, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args| + newfunction(:mysql_deepmerge, type: :rvalue, doc: <<-'ENDHEREDOC') do |args| Recursively merges two or more hashes together and returns the resulting hash. For example: @@ -18,39 +19,39 @@ ENDHEREDOC if args.length < 2 - raise Puppet::ParseError, ("mysql_deepmerge(): wrong number of arguments (#{args.length}; must be at least 2)") + raise Puppet::ParseError, _('mysql_deepmerge(): wrong number of arguments (%{args_length}; must be at least 2)') % { args_length: args.length } end - result = Hash.new + result = {} args.each do |arg| - next if arg.is_a? String and arg.empty? # empty string is synonym for puppet's undef + next if arg.is_a?(String) && arg.empty? # empty string is synonym for puppet's undef # If the argument was not a hash, skip it. unless arg.is_a?(Hash) - raise Puppet::ParseError, "mysql_deepmerge: unexpected argument type #{arg.class}, only expects hash arguments" + raise Puppet::ParseError, _('mysql_deepmerge: unexpected argument type %{arg_class}, only expects hash arguments.') % { args_class: args.class } end # Now we have to traverse our hash assigning our non-hash values # to the matching keys in our result while following our hash values # and repeating the process. - overlay( result, arg ) + overlay(result, arg) end - return( result ) + return(result) end end -def has_normalized!(hash, key) - return true if hash.has_key?( key ) - return false unless key.match(/-|_/) - other_key = key.include?('-') ? key.gsub( '-', '_' ) : key.gsub( '_', '-' ) - return false unless hash.has_key?( other_key ) - hash[key] = hash.delete( other_key ) - return true; +def normalized?(hash, key) + return true if hash.key?(key) + return false unless key =~ %r{-|_} + other_key = key.include?('-') ? key.tr('-', '_') : key.tr('_', '-') + return false unless hash.key?(other_key) + hash[key] = hash.delete(other_key) + true end -def overlay( hash1, hash2 ) +def overlay(hash1, hash2) hash2.each do |key, value| - if(has_normalized!( hash1, key ) and value.is_a?(Hash) and hash1[key].is_a?(Hash)) - overlay( hash1[key], value ) + if normalized?(hash1, key) && value.is_a?(Hash) && hash1[key].is_a?(Hash) + overlay(hash1[key], value) else hash1[key] = value end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/lib/puppet/parser/functions/mysql_dirname.rb puppet-module-puppetlabs-mysql-5.3.0/lib/puppet/parser/functions/mysql_dirname.rb --- puppet-module-puppetlabs-mysql-3.10.0/lib/puppet/parser/functions/mysql_dirname.rb 2016-07-27 17:34:11.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/lib/puppet/parser/functions/mysql_dirname.rb 2017-10-05 23:11:56.000000000 +0000 @@ -1,15 +1,15 @@ +# Returns the dirname of a path. module Puppet::Parser::Functions - newfunction(:mysql_dirname, :type => :rvalue, :doc => <<-EOS + newfunction(:mysql_dirname, type: :rvalue, doc: <<-EOS Returns the dirname of a path. EOS - ) do |arguments| + ) do |arguments| - raise(Puppet::ParseError, "mysql_dirname(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 + if arguments.empty? + raise Puppet::ParseError, _('mysql_dirname(): Wrong number of arguments given (%{args_length} for 1)') % { args_length: args.length } + end path = arguments[0] return File.dirname(path) end end - -# vim: set ts=2 sw=2 et : diff -Nru puppet-module-puppetlabs-mysql-3.10.0/lib/puppet/parser/functions/mysql_password.rb puppet-module-puppetlabs-mysql-5.3.0/lib/puppet/parser/functions/mysql_password.rb --- puppet-module-puppetlabs-mysql-3.10.0/lib/puppet/parser/functions/mysql_password.rb 2016-07-27 17:34:11.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/lib/puppet/parser/functions/mysql_password.rb 2017-10-05 23:11:56.000000000 +0000 @@ -1,17 +1,18 @@ -# hash a string as mysql's "PASSWORD()" function would do it require 'digest/sha1' - +# Returns the mysql password hash from the clear text password. +# Hash a string as mysql's "PASSWORD()" function would do it module Puppet::Parser::Functions - newfunction(:mysql_password, :type => :rvalue, :doc => <<-EOS + newfunction(:mysql_password, type: :rvalue, doc: <<-EOS Returns the mysql password hash from the clear text password. EOS - ) do |args| + ) do |args| - raise(Puppet::ParseError, 'mysql_password(): Wrong number of arguments ' + - "given (#{args.size} for 1)") if args.size != 1 + if args.size != 1 + raise Puppet::ParseError, _('mysql_password(): Wrong number of arguments given (%{args_length} for 1)') % { args_length: args.length } + end return '' if args[0].empty? - return args[0] if args[0] =~ /\*[A-F0-9]{40}$/ + return args[0] if args[0] =~ %r{\*[A-F0-9]{40}$} '*' + Digest::SHA1.hexdigest(Digest::SHA1.digest(args[0])).upcase end end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/lib/puppet/parser/functions/mysql_strip_hash.rb puppet-module-puppetlabs-mysql-5.3.0/lib/puppet/parser/functions/mysql_strip_hash.rb --- puppet-module-puppetlabs-mysql-3.10.0/lib/puppet/parser/functions/mysql_strip_hash.rb 2016-07-27 17:34:06.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/lib/puppet/parser/functions/mysql_strip_hash.rb 2017-10-05 23:11:56.000000000 +0000 @@ -1,21 +1,19 @@ +# When given a hash this function strips out all blank entries. module Puppet::Parser::Functions - newfunction(:mysql_strip_hash, :type => :rvalue, :arity => 1, :doc => <<-EOS -TEMPORARY FUNCTION: EXPIRES 2014-03-10 -When given a hash this function strips out all blank entries. + newfunction(:mysql_strip_hash, type: :rvalue, arity: 1, doc: <<-EOS + TEMPORARY FUNCTION: EXPIRES 2014-03-10 + When given a hash this function strips out all blank entries. EOS - ) do |args| + ) do |args| hash = args[0] unless hash.is_a?(Hash) - raise(Puppet::ParseError, 'mysql_strip_hash(): Requires hash to work with') + raise(Puppet::ParseError, _('mysql_strip_hash(): Requires a hash to work.')) end # Filter out all the top level blanks. - hash.reject{|k,v| v == ''}.each do |k,v| - if v.is_a?(Hash) - v.reject!{|ki,vi| vi == '' } - end + hash.reject { |_k, v| v == '' }.each do |_k, v| + v.reject! { |_ki, vi| vi == '' } if v.is_a?(Hash) end - end end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/lib/puppet/provider/mysql_database/mysql.rb puppet-module-puppetlabs-mysql-5.3.0/lib/puppet/provider/mysql_database/mysql.rb --- puppet-module-puppetlabs-mysql-3.10.0/lib/puppet/provider/mysql_database/mysql.rb 2016-07-27 17:34:11.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/lib/puppet/provider/mysql_database/mysql.rb 2018-01-19 18:07:36.000000000 +0000 @@ -1,21 +1,20 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'mysql')) -Puppet::Type.type(:mysql_database).provide(:mysql, :parent => Puppet::Provider::Mysql) do +Puppet::Type.type(:mysql_database).provide(:mysql, parent: Puppet::Provider::Mysql) do desc 'Manages MySQL databases.' - commands :mysql => 'mysql' + commands mysql_raw: 'mysql' def self.instances - mysql([defaults_file, '-NBe', 'show databases'].compact).split("\n").collect do |name| + mysql_caller('show databases', 'regular').split("\n").map do |name| attributes = {} - mysql([defaults_file, '-NBe', "show variables like '%_database'", name].compact).split("\n").each do |line| - k,v = line.split(/\s/) + mysql_caller(["show variables like '%_database'", name], 'regular').split("\n").each do |line| + k, v = line.split(%r{\s}) attributes[k] = v end - new(:name => name, - :ensure => :present, - :charset => attributes['character_set_database'], - :collate => attributes['collation_database'] - ) + new(name: name, + ensure: :present, + charset: attributes['character_set_database'], + collate: attributes['collation_database']) end end @@ -24,14 +23,13 @@ def self.prefetch(resources) databases = instances resources.keys.each do |database| - if provider = databases.find { |db| db.name == database } - resources[database].provider = provider - end + provider = databases.find { |db| db.name == database } + resources[database].provider = provider if provider end end def create - mysql([defaults_file, '-NBe', "create database if not exists `#{@resource[:name]}` character set `#{@resource[:charset]}` collate `#{@resource[:collate]}`"].compact) + self.class.mysql_caller("create database if not exists `#{@resource[:name]}` character set `#{@resource[:charset]}` collate `#{@resource[:collate]}`", 'regular') @property_hash[:ensure] = :present @property_hash[:charset] = @resource[:charset] @@ -41,7 +39,7 @@ end def destroy - mysql([defaults_file, '-NBe', "drop database if exists `#{@resource[:name]}`"].compact) + self.class.mysql_caller("drop database if exists `#{@resource[:name]}`", 'regular') @property_hash.clear exists? ? (return false) : (return true) @@ -54,15 +52,14 @@ mk_resource_methods def charset=(value) - mysql([defaults_file, '-NBe', "alter database `#{resource[:name]}` CHARACTER SET #{value}"].compact) + self.class.mysql_caller("alter database `#{resource[:name]}` CHARACTER SET #{value}", 'regular') @property_hash[:charset] = value - charset == value ? (return true) : (return false) + (charset == value) ? (return true) : (return false) end def collate=(value) - mysql([defaults_file, '-NBe', "alter database `#{resource[:name]}` COLLATE #{value}"].compact) + self.class.mysql_caller("alter database `#{resource[:name]}` COLLATE #{value}", 'regular') @property_hash[:collate] = value - collate == value ? (return true) : (return false) + (collate == value) ? (return true) : (return false) end - end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/lib/puppet/provider/mysql_datadir/mysql.rb puppet-module-puppetlabs-mysql-5.3.0/lib/puppet/provider/mysql_datadir/mysql.rb --- puppet-module-puppetlabs-mysql-3.10.0/lib/puppet/provider/mysql_datadir/mysql.rb 2016-11-07 20:14:07.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/lib/puppet/provider/mysql_datadir/mysql.rb 2018-01-19 18:07:36.000000000 +0000 @@ -1,71 +1,86 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'mysql')) -Puppet::Type.type(:mysql_datadir).provide(:mysql, :parent => Puppet::Provider::Mysql) do - +Puppet::Type.type(:mysql_datadir).provide(:mysql, parent: Puppet::Provider::Mysql) do desc 'manage data directories for mysql instances' initvars - # Make sure we find mysqld on CentOS and mysql_install_db on Gentoo - ENV['PATH']=ENV['PATH'] + ':/usr/libexec:/usr/share/mysql/scripts:/opt/rh/mysql55/root/usr/bin:/opt/rh/mysql55/root/usr/libexec' - - commands :mysqld => 'mysqld' - commands :mysql_install_db => 'mysql_install_db' - + # Make sure we find mysqld on CentOS and mysql_install_db on Gentoo and Solaris 11 + ENV['PATH'] = [ + ENV['PATH'], + '/usr/libexec', + '/usr/share/mysql/scripts', + '/opt/rh/rh-mysql57/root/usr/bin', + '/opt/rh/rh-mysql57/root/usr/libexec', + '/opt/rh/rh-mysql56/root/usr/bin', + '/opt/rh/rh-mysql56/root/usr/libexec', + '/opt/rh/rh-mariadb101/root/usr/bin', + '/opt/rh/rh-mariadb101/root/usr/libexec', + '/opt/rh/rh-mariadb100/root/usr/bin', + '/opt/rh/rh-mariadb100/root/usr/libexec', + '/opt/rh/mysql55/root/usr/bin', + '/opt/rh/mysql55/root/usr/libexec', + '/opt/rh/mariadb55/root/usr/bin', + '/opt/rh/mariadb55/root/usr/libexec', + '/usr/mysql/5.5/bin', + '/usr/mysql/5.6/bin', + '/usr/mysql/5.7/bin', + ].join(':') + + commands mysqld: 'mysqld' + optional_commands mysql_install_db: 'mysql_install_db' + # rubocop:disable Lint/UselessAssignment def create name = @resource[:name] insecure = @resource.value(:insecure) || true defaults_extra_file = @resource.value(:defaults_extra_file) - user = @resource.value(:user) || "mysql" + user = @resource.value(:user) || 'mysql' basedir = @resource.value(:basedir) datadir = @resource.value(:datadir) || @resource[:name] - log_error = @resource.value(:log_error) || "/var/tmp/mysqld_initialize.log" - + log_error = @resource.value(:log_error) || '/var/tmp/mysqld_initialize.log' + # rubocop:enable Lint/UselessAssignment unless defaults_extra_file.nil? - if File.exist?(defaults_extra_file) - defaults_extra_file="--defaults-extra-file=#{defaults_extra_file}" - else - raise ArgumentError, "Defaults-extra-file #{defaults_extra_file} is missing" + unless File.exist?(defaults_extra_file) + raise ArgumentError, _('Defaults-extra-file %{file} is missing.') % { file: defaults_extra_file } end + defaults_extra_file = "--defaults-extra-file=#{defaults_extra_file}" end - if insecure == true - initialize="--initialize-insecure" - else - initialize="--initialize" - end - - opts = [ defaults_extra_file ] - %w(basedir datadir user).each do |opt| - val = eval(opt) - opts<<"--#{opt}=#{val}" unless val.nil? + initialize = if insecure == true + '--initialize-insecure' + else + '--initialize' + end + + opts = [defaults_extra_file] + %w[basedir datadir user].each do |opt| + val = eval(opt) # rubocop:disable Security/Eval + opts << "--#{opt}=#{val}" unless val.nil? end if mysqld_version.nil? - debug("Installing MySQL data directory with mysql_install_db #{opts.compact.join(" ")}") + debug("Installing MySQL data directory with mysql_install_db #{opts.compact.join(' ')}") mysql_install_db(opts.compact) + elsif (mysqld_type == 'mysql' || mysqld_type == 'percona') && Puppet::Util::Package.versioncmp(mysqld_version, '5.7.6') >= 0 + opts << "--log-error=#{log_error}" + opts << initialize.to_s + debug("Initializing MySQL data directory >= 5.7.6 with mysqld: #{opts.compact.join(' ')}") + mysqld(opts.compact) else - if (mysqld_type == "mysql" or mysqld_type == "percona") and Puppet::Util::Package.versioncmp(mysqld_version, '5.7.6') >= 0 - opts<<"--log-error=#{log_error}" - opts<<"#{initialize}" - debug("Initializing MySQL data directory >= 5.7.6 with mysqld: #{opts.compact.join(" ")}") - mysqld(opts.compact) - else - debug("Installing MySQL data directory with mysql_install_db #{opts.compact.join(" ")}") - mysql_install_db(opts.compact) - end + debug("Installing MySQL data directory with mysql_install_db #{opts.compact.join(' ')}") + mysql_install_db(opts.compact) end - exists? + exists? end def destroy - name = @resource[:name] - raise ArgumentError, "ERROR: Resource can not be removed" + name = @resource[:name] # rubocop:disable Lint/UselessAssignment + raise ArgumentError, _('ERROR: `Resource` can not be removed.') end def exists? datadir = @resource[:datadir] - (File.directory?("#{datadir}/mysql")) && (Dir.entries("#{datadir}/mysql") - %w{ . .. }).any? + File.directory?("#{datadir}/mysql") && (Dir.entries("#{datadir}/mysql") - %w[. ..]).any? end ## @@ -74,5 +89,4 @@ # Generates method for all properties of the property_hash mk_resource_methods - end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/lib/puppet/provider/mysql_grant/mysql.rb puppet-module-puppetlabs-mysql-5.3.0/lib/puppet/provider/mysql_grant/mysql.rb --- puppet-module-puppetlabs-mysql-3.10.0/lib/puppet/provider/mysql_grant/mysql.rb 2016-09-06 22:04:13.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/lib/puppet/provider/mysql_grant/mysql.rb 2018-01-19 18:07:36.000000000 +0000 @@ -1,77 +1,74 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'mysql')) -Puppet::Type.type(:mysql_grant).provide(:mysql, :parent => Puppet::Provider::Mysql) do - +Puppet::Type.type(:mysql_grant).provide(:mysql, parent: Puppet::Provider::Mysql) do desc 'Set grants for users in MySQL.' + commands mysql_raw: 'mysql' + def self.instances instances = [] - users.select{ |user| user =~ /.+@/ }.collect do |user| - user_string = self.cmd_user(user) + users.map do |user| + user_string = cmd_user(user) query = "SHOW GRANTS FOR #{user_string};" begin - grants = mysql([defaults_file, "-NBe", query].compact) + grants = mysql_caller(query, 'regular') rescue Puppet::ExecutionFailure => e # Silently ignore users with no grants. Can happen e.g. if user is # defined with fqdn and server is run with skip-name-resolve. Example: # Default root user created by mysql_install_db on a host with fqdn # of myhost.mydomain.my: root@myhost.mydomain.my, when MySQL is started # with --skip-name-resolve. - if e.inspect =~ /There is no such grant defined for user/ - next - else - raise Puppet::Error, "#mysql had an error -> #{e.inspect}" - end + next if e.inspect =~ %r{There is no such grant defined for user} + raise Puppet::Error, _('#mysql had an error -> %{inspect}') % { inspect: e.inspect } end # Once we have the list of grants generate entries for each. grants.each_line do |grant| # Match the munges we do in the type. - munged_grant = grant.delete("'").delete("`").delete('"') + munged_grant = grant.delete("'").delete('`').delete('"') # Matching: GRANT (SELECT, UPDATE) PRIVILEGES ON (*.*) TO ('root')@('127.0.0.1') (WITH GRANT OPTION) - if match = munged_grant.match(/^GRANT\s(.+)\sON\s(.+)\sTO\s(.*)@(.*?)(\s.*)?$/) - privileges, table, user, host, rest = match.captures - table.gsub!('\\\\', '\\') - - # split on ',' if it is not a non-'('-containing string followed by a - # closing parenthesis ')'-char - e.g. only split comma separated elements not in - # parentheses - stripped_privileges = privileges.strip.split(/\s*,\s*(?![^(]*\))/).map do |priv| - # split and sort the column_privileges in the parentheses and rejoin - if priv.include?('(') - type, col=priv.strip.split(/\s+|\b/,2) - type.upcase + " (" + col.slice(1...-1).strip.split(/\s*,\s*/).sort.join(', ') + ")" - else - # Once we split privileges up on the , we need to make sure we - # shortern ALL PRIVILEGES to just all. - priv == 'ALL PRIVILEGES' ? 'ALL' : priv.strip - end - end - # Same here, but to remove OPTION leaving just GRANT. - if rest.match(/WITH\sGRANT\sOPTION/) - options = ['GRANT'] + next unless match = munged_grant.match(%r{^GRANT\s(.+)\sON\s(.+)\sTO\s(.*)@(.*?)(\s.*)?$}) # rubocop:disable Lint/AssignmentInCondition + privileges, table, user, host, rest = match.captures + table.gsub!('\\\\', '\\') + + # split on ',' if it is not a non-'('-containing string followed by a + # closing parenthesis ')'-char - e.g. only split comma separated elements not in + # parentheses + stripped_privileges = privileges.strip.split(%r{\s*,\s*(?![^(]*\))}).map do |priv| + # split and sort the column_privileges in the parentheses and rejoin + if priv.include?('(') + type, col = priv.strip.split(%r{\s+|\b}, 2) + type.upcase + ' (' + col.slice(1...-1).strip.split(%r{\s*,\s*}).sort.join(', ') + ')' else - options = ['NONE'] + # Once we split privileges up on the , we need to make sure we + # shortern ALL PRIVILEGES to just all. + (priv == 'ALL PRIVILEGES') ? 'ALL' : priv.strip end - # fix double backslash that MySQL prints, so resources match - table.gsub!("\\\\", "\\") - # We need to return an array of instances so capture these - instances << new( - :name => "#{user}@#{host}/#{table}", - :ensure => :present, - :privileges => stripped_privileges.sort, - :table => table, - :user => "#{user}@#{host}", - :options => options - ) end + # Same here, but to remove OPTION leaving just GRANT. + options = if rest =~ %r{WITH\sGRANT\sOPTION} + ['GRANT'] + else + ['NONE'] + end + # fix double backslash that MySQL prints, so resources match + table.gsub!('\\\\', '\\') + # We need to return an array of instances so capture these + instances << new( + name: "#{user}@#{host}/#{table}", + ensure: :present, + privileges: stripped_privileges.sort, + table: table, + user: "#{user}@#{host}", + options: options, + ) end end - return instances + instances end def self.prefetch(resources) users = instances resources.keys.each do |name| - if provider = users.find { |user| user.name == name } + if provider = users.find { |user| user.name == name } # rubocop:disable Lint/AssignmentInCondition resources[name].provider = provider end end @@ -80,12 +77,12 @@ def grant(user, table, privileges, options) user_string = self.class.cmd_user(user) priv_string = self.class.cmd_privs(privileges) - table_string = self.class.cmd_table(table) + table_string = privileges.include?('PROXY') ? self.class.cmd_user(table) : self.class.cmd_table(table) query = "GRANT #{priv_string}" query << " ON #{table_string}" query << " TO #{user_string}" query << self.class.cmd_options(options) unless options.nil? - mysql([defaults_file, system_database, '-e', query].compact) + self.class.mysql_caller(query, 'system') end def create @@ -102,26 +99,30 @@ def revoke(user, table, revoke_privileges = ['ALL']) user_string = self.class.cmd_user(user) - table_string = self.class.cmd_table(table) + table_string = revoke_privileges.include?('PROXY') ? self.class.cmd_user(table) : self.class.cmd_table(table) priv_string = self.class.cmd_privs(revoke_privileges) # revoke grant option needs to be a extra query, because # "REVOKE ALL PRIVILEGES, GRANT OPTION [..]" is only valid mysql syntax # if no ON clause is used. # It hast to be executed before "REVOKE ALL [..]" since a GRANT has to # exist to be executed successfully - if revoke_privileges.include? 'ALL' + if revoke_privileges.include?('ALL') && !revoke_privileges.include?('PROXY') query = "REVOKE GRANT OPTION ON #{table_string} FROM #{user_string}" - mysql([defaults_file, system_database, '-e', query].compact) + self.class.mysql_caller(query, 'system') end query = "REVOKE #{priv_string} ON #{table_string} FROM #{user_string}" - mysql([defaults_file, system_database, '-e', query].compact) + self.class.mysql_caller(query, 'system') end def destroy # if the user was dropped, it'll have been removed from the user hash - # as the grants are alraedy removed by the DROP statement + # as the grants are already removed by the DROP statement if self.class.users.include? @property_hash[:user] - revoke(@property_hash[:user], @property_hash[:table]) + if @property_hash[:privileges].include?('PROXY') + revoke(@property_hash[:user], @property_hash[:table], @property_hash[:privileges]) + else + revoke(@property_hash[:user], @property_hash[:table]) + end end @property_hash.clear @@ -134,13 +135,13 @@ def flush @property_hash.clear - mysql([defaults_file, '-NBe', 'FLUSH PRIVILEGES'].compact) + self.class.mysql_caller('FLUSH PRIVILEGES', 'regular') end mk_resource_methods def diff_privileges(privileges_old, privileges_new) - diff = {:revoke => Array.new, :grant => Array.new} + diff = { revoke: [], grant: [] } if privileges_old.include? 'ALL' diff[:revoke] = privileges_old diff[:grant] = privileges_new @@ -150,15 +151,15 @@ diff[:revoke] = privileges_old - privileges_new diff[:grant] = privileges_new - privileges_old end - return diff + diff end def privileges=(privileges) diff = diff_privileges(@property_hash[:privileges], privileges) - if not diff[:revoke].empty? + unless diff[:revoke].empty? revoke(@property_hash[:user], @property_hash[:table], diff[:revoke]) end - if not diff[:grant].empty? + unless diff[:grant].empty? grant(@property_hash[:user], @property_hash[:table], diff[:grant], @property_hash[:options]) end @property_hash[:privileges] = privileges @@ -172,5 +173,4 @@ self.options end - end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/lib/puppet/provider/mysql_plugin/mysql.rb puppet-module-puppetlabs-mysql-5.3.0/lib/puppet/provider/mysql_plugin/mysql.rb --- puppet-module-puppetlabs-mysql-3.10.0/lib/puppet/provider/mysql_plugin/mysql.rb 2016-07-27 17:34:11.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/lib/puppet/provider/mysql_plugin/mysql.rb 2018-01-19 18:07:36.000000000 +0000 @@ -1,16 +1,15 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'mysql')) -Puppet::Type.type(:mysql_plugin).provide(:mysql, :parent => Puppet::Provider::Mysql) do +Puppet::Type.type(:mysql_plugin).provide(:mysql, parent: Puppet::Provider::Mysql) do desc 'Manages MySQL plugins.' - commands :mysql => 'mysql' + commands mysql_raw: 'mysql' def self.instances - mysql([defaults_file, '-NBe', 'show plugins'].compact).split("\n").collect do |line| - name, status, type, library, license = line.split(/\t/) - new(:name => name, - :ensure => :present, - :soname => library - ) + mysql_caller('show plugins', 'regular').split("\n").map do |line| + name, _status, _type, library, _license = line.split(%r{\t}) + new(name: name, + ensure: :present, + soname: library) end end @@ -19,7 +18,7 @@ def self.prefetch(resources) plugins = instances resources.keys.each do |plugin| - if provider = plugins.find { |pl| pl.name == plugin } + if provider = plugins.find { |pl| pl.name == plugin } # rubocop:disable Lint/AssignmentInCondition resources[plugin].provider = provider end end @@ -28,17 +27,17 @@ def create # Use plugin_name.so as soname if it's not specified. This won't work on windows as # there it should be plugin_name.dll - @resource[:soname].nil? ? (soname=@resource[:name] + '.so') : (soname=@resource[:soname]) - mysql([defaults_file, '-NBe', "install plugin #{@resource[:name]} soname '#{soname}'"].compact) + @resource[:soname].nil? ? (soname = @resource[:name] + '.so') : (soname = @resource[:soname]) + self.class.mysql_caller("install plugin #{@resource[:name]} soname '#{soname}'", 'regular') - @property_hash[:ensure] = :present + @property_hash[:ensure] = :present @property_hash[:soname] = @resource[:soname] exists? ? (return true) : (return false) end def destroy - mysql([defaults_file, '-NBe', "uninstall plugin #{@resource[:name]}"].compact) + self.class.mysql_caller("uninstall plugin #{@resource[:name]}", 'regular') @property_hash.clear exists? ? (return false) : (return true) @@ -49,5 +48,4 @@ end mk_resource_methods - end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/lib/puppet/provider/mysql.rb puppet-module-puppetlabs-mysql-5.3.0/lib/puppet/provider/mysql.rb --- puppet-module-puppetlabs-mysql-3.10.0/lib/puppet/provider/mysql.rb 2016-09-06 22:04:13.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/lib/puppet/provider/mysql.rb 2018-02-20 14:54:26.000000000 +0000 @@ -1,29 +1,27 @@ +# Puppet provider for mysql class Puppet::Provider::Mysql < Puppet::Provider - # Without initvars commands won't work. initvars # Make sure we find mysql commands on CentOS and FreeBSD - ENV['PATH']=ENV['PATH'] + ':/usr/libexec:/usr/local/libexec:/usr/local/bin' + ENV['PATH'] = ENV['PATH'] + ':/usr/libexec:/usr/local/libexec:/usr/local/bin' - commands :mysql => 'mysql' + # rubocop:disable Style/HashSyntax + commands :mysql_raw => 'mysql' commands :mysqld => 'mysqld' commands :mysqladmin => 'mysqladmin' + # rubocop:enable Style/HashSyntax # Optional defaults file def self.defaults_file - if File.file?("#{Facter.value(:root_home)}/.my.cnf") - "--defaults-extra-file=#{Facter.value(:root_home)}/.my.cnf" - else - nil - end + "--defaults-extra-file=#{Facter.value(:root_home)}/.my.cnf" if File.file?("#{Facter.value(:root_home)}/.my.cnf") end def self.mysqld_type # find the mysql "dialect" like mariadb / mysql etc. - mysqld_version_string.scan(/mariadb/i) { return "mariadb" } - mysqld_version_string.scan(/\s\(percona/i) { return "percona" } - return "mysql" + mysqld_version_string.scan(%r{mariadb}i) { return 'mariadb' } + mysqld_version_string.scan(%r{\s\(percona}i) { return 'percona' } + 'mysql' end def mysqld_type @@ -31,7 +29,9 @@ end def self.mysqld_version_string - # As the possibility of the mysqld being remote we need to allow the version string to be overridden, this can be done by facter.value as seen below. In the case that it has not been set and the facter value is nil we use the mysql -v command to ensure we report the correct version of mysql for later use cases. + # As the possibility of the mysqld being remote we need to allow the version string to be overridden, + # this can be done by facter.value as seen below. In the case that it has not been set and the facter + # value is nil we use the mysql -v command to ensure we report the correct version of mysql for later use cases. @mysqld_version_string ||= Facter.value(:mysqld_version) || mysqld('-V') end @@ -43,7 +43,7 @@ # note: be prepared for '5.7.6-rc-log' etc results # versioncmp detects 5.7.6-log to be newer then 5.7.6 # this is why we need the trimming. - mysqld_version_string.scan(/\d+\.\d+\.\d+/).first unless mysqld_version_string.nil? + mysqld_version_string.scan(%r{\d+\.\d+\.\d+}).first unless mysqld_version_string.nil? end def mysqld_version @@ -54,8 +54,18 @@ self.class.defaults_file end + def self.mysql_caller(text_of_sql, type) + if type.eql? 'system' + mysql_raw([defaults_file, '--host=', system_database, '-e', text_of_sql].flatten.compact) + elsif type.eql? 'regular' + mysql_raw([defaults_file, '-NBe', text_of_sql].flatten.compact) + else + raise Puppet::Error, _("#mysql_caller: Unrecognised type '%{type}'" % { type: type }) + end + end + def self.users - mysql([defaults_file, '-NBe', "SELECT CONCAT(User, '@',Host) AS User FROM mysql.user"].compact).split("\n") + mysql_caller("SELECT CONCAT(User, '@',Host) AS User FROM mysql.user", 'regular').split("\n") end # Optional parameter to run a statement on the MySQL system database. @@ -77,39 +87,33 @@ table_string = '' # We can't escape *.* so special case this. - if table == '*.*' - table_string << '*.*' - # Special case also for PROCEDURES - elsif table.start_with?('PROCEDURE ') - table_string << table.sub(/^PROCEDURE (.*)(\..*)/, 'PROCEDURE `\1`\2') - else - table_string << table.sub(/^(.*)(\..*)/, '`\1`\2') - end + table_string << if table == '*.*' + '*.*' + # Special case also for FUNCTIONs and PROCEDUREs + elsif table.start_with?('FUNCTION ', 'PROCEDURE ') + table.sub(%r{^(FUNCTION|PROCEDURE) (.*)(\..*)}, '\1 `\2`\3') + else + table.sub(%r{^(.*)(\..*)}, '`\1`\2') + end table_string end def self.cmd_privs(privileges) - if privileges.include?('ALL') - return 'ALL PRIVILEGES' - else - priv_string = '' - privileges.each do |priv| - priv_string << "#{priv}, " - end + return 'ALL PRIVILEGES' if privileges.include?('ALL') + priv_string = '' + privileges.each do |priv| + priv_string << "#{priv}, " end # Remove trailing , from the last element. - priv_string.sub(/, $/, '') + priv_string.sub(%r{, $}, '') end # Take in potential options and build up a query string with them. def self.cmd_options(options) option_string = '' options.each do |opt| - if opt == 'GRANT' - option_string << ' WITH GRANT OPTION' - end + option_string << ' WITH GRANT OPTION' if opt == 'GRANT' end option_string end - end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/lib/puppet/provider/mysql_user/mysql.rb puppet-module-puppetlabs-mysql-5.3.0/lib/puppet/provider/mysql_user/mysql.rb --- puppet-module-puppetlabs-mysql-3.10.0/lib/puppet/provider/mysql_user/mysql.rb 2016-11-07 20:14:07.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/lib/puppet/provider/mysql_user/mysql.rb 2018-02-20 14:54:26.000000000 +0000 @@ -1,42 +1,38 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'mysql')) -Puppet::Type.type(:mysql_user).provide(:mysql, :parent => Puppet::Provider::Mysql) do - +Puppet::Type.type(:mysql_user).provide(:mysql, parent: Puppet::Provider::Mysql) do desc 'manage users for a mysql database.' - commands :mysql => 'mysql' + commands mysql_raw: 'mysql' # Build a property_hash containing all the discovered information about MySQL # users. def self.instances - users = mysql([defaults_file, '-NBe', - "SELECT CONCAT(User, '@',Host) AS User FROM mysql.user"].compact).split("\n") + users = mysql_caller("SELECT CONCAT(User, '@',Host) AS User FROM mysql.user", 'regular').split("\n") # To reduce the number of calls to MySQL we collect all the properties in # one big swoop. - users.collect do |name| + users.map do |name| if mysqld_version.nil? ## Default ... + # rubocop:disable Metrics/LineLength query = "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, SSL_TYPE, SSL_CIPHER, X509_ISSUER, X509_SUBJECT, PASSWORD /*!50508 , PLUGIN */ FROM mysql.user WHERE CONCAT(user, '@', host) = '#{name}'" + elsif (mysqld_type == 'mysql' || mysqld_type == 'percona') && Puppet::Util::Package.versioncmp(mysqld_version, '5.7.6') >= 0 + query = "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, SSL_TYPE, SSL_CIPHER, X509_ISSUER, X509_SUBJECT, AUTHENTICATION_STRING, PLUGIN FROM mysql.user WHERE CONCAT(user, '@', host) = '#{name}'" else - if (mysqld_type == "mysql" or mysqld_type == "percona") and Puppet::Util::Package.versioncmp(mysqld_version, '5.7.6') >= 0 - query = "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, SSL_TYPE, SSL_CIPHER, X509_ISSUER, X509_SUBJECT, AUTHENTICATION_STRING, PLUGIN FROM mysql.user WHERE CONCAT(user, '@', host) = '#{name}'" - else - query = "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, SSL_TYPE, SSL_CIPHER, X509_ISSUER, X509_SUBJECT, PASSWORD /*!50508 , PLUGIN */ FROM mysql.user WHERE CONCAT(user, '@', host) = '#{name}'" - end + query = "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, SSL_TYPE, SSL_CIPHER, X509_ISSUER, X509_SUBJECT, PASSWORD /*!50508 , PLUGIN */ FROM mysql.user WHERE CONCAT(user, '@', host) = '#{name}'" end @max_user_connections, @max_connections_per_hour, @max_queries_per_hour, @max_updates_per_hour, ssl_type, ssl_cipher, x509_issuer, x509_subject, - @password, @plugin = mysql([defaults_file, "-NBe", query].compact).split(/\s/) + @password, @plugin = mysql_caller(query, 'regular').split(%r{\s}) @tls_options = parse_tls_options(ssl_type, ssl_cipher, x509_issuer, x509_subject) - - new(:name => name, - :ensure => :present, - :password_hash => @password, - :plugin => @plugin, - :max_user_connections => @max_user_connections, - :max_connections_per_hour => @max_connections_per_hour, - :max_queries_per_hour => @max_queries_per_hour, - :max_updates_per_hour => @max_updates_per_hour, - :tls_options => @tls_options, - ) + # rubocop:enable Metrics/LineLength + new(name: name, + ensure: :present, + password_hash: @password, + plugin: @plugin, + max_user_connections: @max_user_connections, + max_connections_per_hour: @max_connections_per_hour, + max_queries_per_hour: @max_queries_per_hour, + max_updates_per_hour: @max_updates_per_hour, + tls_options: @tls_options) end end @@ -44,11 +40,13 @@ # the contents of the property_hash generated by self.instances def self.prefetch(resources) users = instances + # rubocop:disable Lint/AssignmentInCondition resources.keys.each do |name| if provider = users.find { |user| user.name == name } resources[name].provider = provider end end + # rubocop:enable Lint/AssignmentInCondition end def create @@ -64,30 +62,32 @@ # Use CREATE USER to be compatible with NO_AUTO_CREATE_USER sql_mode # This is also required if you want to specify a authentication plugin if !plugin.nil? - if plugin == 'sha256_password' and !password_hash.nil? - mysql([defaults_file, system_database, '-e', "CREATE USER '#{merged_name}' IDENTIFIED WITH '#{plugin}' AS '#{password_hash}'"].compact) + if plugin == 'sha256_password' && !password_hash.nil? + self.class.mysql_caller("CREATE USER '#{merged_name}' IDENTIFIED WITH '#{plugin}' AS '#{password_hash}'", 'system') else - mysql([defaults_file, system_database, '-e', "CREATE USER '#{merged_name}' IDENTIFIED WITH '#{plugin}'"].compact) + self.class.mysql_caller("CREATE USER '#{merged_name}' IDENTIFIED WITH '#{plugin}'", 'system') end @property_hash[:ensure] = :present @property_hash[:plugin] = plugin else - mysql([defaults_file, system_database, '-e', "CREATE USER '#{merged_name}' IDENTIFIED BY PASSWORD '#{password_hash}'"].compact) + self.class.mysql_caller("CREATE USER '#{merged_name}' IDENTIFIED BY PASSWORD '#{password_hash}'", 'system') @property_hash[:ensure] = :present @property_hash[:password_hash] = password_hash end - mysql([defaults_file, system_database, '-e', "GRANT USAGE ON *.* TO '#{merged_name}' WITH MAX_USER_CONNECTIONS #{max_user_connections} MAX_CONNECTIONS_PER_HOUR #{max_connections_per_hour} MAX_QUERIES_PER_HOUR #{max_queries_per_hour} MAX_UPDATES_PER_HOUR #{max_updates_per_hour}"].compact) + # rubocop:disable Metrics/LineLength + self.class.mysql_caller("GRANT USAGE ON *.* TO '#{merged_name}' WITH MAX_USER_CONNECTIONS #{max_user_connections} MAX_CONNECTIONS_PER_HOUR #{max_connections_per_hour} MAX_QUERIES_PER_HOUR #{max_queries_per_hour} MAX_UPDATES_PER_HOUR #{max_updates_per_hour}", 'system') + # rubocop:enable Metrics/LineLength @property_hash[:max_user_connections] = max_user_connections @property_hash[:max_connections_per_hour] = max_connections_per_hour @property_hash[:max_queries_per_hour] = max_queries_per_hour @property_hash[:max_updates_per_hour] = max_updates_per_hour merged_tls_options = tls_options.join(' AND ') - if (((mysqld_type == "mysql" or mysqld_type == "percona") and Puppet::Util::Package.versioncmp(mysqld_version, '5.7.6') >= 0) or - (mysqld_type == 'mariadb' and Puppet::Util::Package.versioncmp(mysqld_version, '10.2.0') >= 0)) - mysql([defaults_file, system_database, '-e', "ALTER USER '#{merged_name}' REQUIRE #{merged_tls_options}"].compact) + if ((mysqld_type == 'mysql' || mysqld_type == 'percona') && Puppet::Util::Package.versioncmp(mysqld_version, '5.7.6') >= 0) || + (mysqld_type == 'mariadb' && Puppet::Util::Package.versioncmp(mysqld_version, '10.2.0') >= 0) + self.class.mysql_caller("ALTER USER '#{merged_name}' REQUIRE #{merged_tls_options}", 'system') else - mysql([defaults_file, system_database, '-e', "GRANT USAGE ON *.* TO '#{merged_name}' REQUIRE #{merged_tls_options}"].compact) + self.class.mysql_caller("GRANT USAGE ON *.* TO '#{merged_name}' REQUIRE #{merged_tls_options}", 'system') end @property_hash[:tls_options] = tls_options @@ -96,7 +96,7 @@ def destroy merged_name = @resource[:name].sub('@', "'@'") - mysql([defaults_file, system_database, '-e', "DROP USER '#{merged_name}'"].compact) + self.class.mysql_caller("DROP USER '#{merged_name}'", 'system') @property_hash.clear exists? ? (return false) : (return true) @@ -119,79 +119,88 @@ # We have a fact for the mysql version ... if mysqld_version.nil? # default ... if mysqld_version does not work - mysql([defaults_file, system_database, '-e', "SET PASSWORD FOR #{merged_name} = '#{string}'"].compact) + self.class.mysql_caller("SET PASSWORD FOR #{merged_name} = '#{string}'", 'system') + elsif (mysqld_type == 'mysql' || mysqld_type == 'percona') && Puppet::Util::Package.versioncmp(mysqld_version, '5.7.6') >= 0 + raise ArgumentError, _('Only mysql_native_password (*ABCD...XXX) hashes are supported.') unless string =~ %r{^\*} + self.class.mysql_caller("ALTER USER #{merged_name} IDENTIFIED WITH mysql_native_password AS '#{string}'", 'system') else - # Version >= 5.7.6 (many password related changes) - if (mysqld_type == "mysql" or mysqld_type == "percona") and Puppet::Util::Package.versioncmp(mysqld_version, '5.7.6') >= 0 - if string.match(/^\*/) - mysql([defaults_file, system_database, '-e', "ALTER USER #{merged_name} IDENTIFIED WITH mysql_native_password AS '#{string}'"].compact) - else - raise ArgumentError, "Only mysql_native_password (*ABCD...XXX) hashes are supported" - end - else - # older versions - mysql([defaults_file, system_database, '-e', "SET PASSWORD FOR #{merged_name} = '#{string}'"].compact) - end + self.class.mysql_caller("SET PASSWORD FOR #{merged_name} = '#{string}'", 'system') end - password_hash == string ? (return true) : (return false) + (password_hash == string) ? (return true) : (return false) end def max_user_connections=(int) merged_name = self.class.cmd_user(@resource[:name]) - mysql([defaults_file, system_database, '-e', "GRANT USAGE ON *.* TO #{merged_name} WITH MAX_USER_CONNECTIONS #{int}"].compact).chomp + self.class.mysql_caller("GRANT USAGE ON *.* TO #{merged_name} WITH MAX_USER_CONNECTIONS #{int}", 'system').chomp - max_user_connections == int ? (return true) : (return false) + (max_user_connections == int) ? (return true) : (return false) end def max_connections_per_hour=(int) merged_name = self.class.cmd_user(@resource[:name]) - mysql([defaults_file, system_database, '-e', "GRANT USAGE ON *.* TO #{merged_name} WITH MAX_CONNECTIONS_PER_HOUR #{int}"].compact).chomp + self.class.mysql_caller("GRANT USAGE ON *.* TO #{merged_name} WITH MAX_CONNECTIONS_PER_HOUR #{int}", 'system').chomp - max_connections_per_hour == int ? (return true) : (return false) + (max_connections_per_hour == int) ? (return true) : (return false) end def max_queries_per_hour=(int) merged_name = self.class.cmd_user(@resource[:name]) - mysql([defaults_file, system_database, '-e', "GRANT USAGE ON *.* TO #{merged_name} WITH MAX_QUERIES_PER_HOUR #{int}"].compact).chomp + self.class.mysql_caller("GRANT USAGE ON *.* TO #{merged_name} WITH MAX_QUERIES_PER_HOUR #{int}", 'system').chomp - max_queries_per_hour == int ? (return true) : (return false) + (max_queries_per_hour == int) ? (return true) : (return false) end def max_updates_per_hour=(int) merged_name = self.class.cmd_user(@resource[:name]) - mysql([defaults_file, system_database, '-e', "GRANT USAGE ON *.* TO #{merged_name} WITH MAX_UPDATES_PER_HOUR #{int}"].compact).chomp + self.class.mysql_caller("GRANT USAGE ON *.* TO #{merged_name} WITH MAX_UPDATES_PER_HOUR #{int}", 'system').chomp - max_updates_per_hour == int ? (return true) : (return false) + (max_updates_per_hour == int) ? (return true) : (return false) + end + + def plugin=(string) + merged_name = self.class.cmd_user(@resource[:name]) + + if (mysqld_type == 'mysql' || mysqld_type == 'percona') && Puppet::Util::Package.versioncmp(mysqld_version, '5.7.6') >= 0 + sql = "ALTER USER #{merged_name} IDENTIFIED WITH '#{string}'" + sql << " AS '#{@resource[:password_hash]}'" if string == 'mysql_native_password' + else + # See https://bugs.mysql.com/bug.php?id=67449 + sql = "UPDATE mysql.user SET plugin = '#{string}'" + sql << ((string == 'mysql_native_password') ? ", password = '#{@resource[:password_hash]}'" : ", password = ''") + sql << " WHERE CONCAT(user, '@', host) = '#{@resource[:name]}'" + end + + self.class.mysql_caller(sql, 'system') + (plugin == string) ? (return true) : (return false) end def tls_options=(array) merged_name = self.class.cmd_user(@resource[:name]) merged_tls_options = array.join(' AND ') - if (((mysqld_type == "mysql" or mysqld_type == "percona") and Puppet::Util::Package.versioncmp(mysqld_version, '5.7.6') >= 0) or - (mysqld_type == 'mariadb' and Puppet::Util::Package.versioncmp(mysqld_version, '10.2.0') >= 0)) - mysql([defaults_file, system_database, '-e', "ALTER USER #{merged_name} REQUIRE #{merged_tls_options}"].compact) + if ((mysqld_type == 'mysql' || mysqld_type == 'percona') && Puppet::Util::Package.versioncmp(mysqld_version, '5.7.6') >= 0) || + (mysqld_type == 'mariadb' && Puppet::Util::Package.versioncmp(mysqld_version, '10.2.0') >= 0) + self.class.mysql_caller("ALTER USER #{merged_name} REQUIRE #{merged_tls_options}", 'system') else - mysql([defaults_file, system_database, '-e', "GRANT USAGE ON *.* TO #{merged_name} REQUIRE #{merged_tls_options}"].compact) + self.class.mysql_caller("GRANT USAGE ON *.* TO #{merged_name} REQUIRE #{merged_tls_options}", 'system') end - tls_options == array ? (return true) : (return false) + (tls_options == array) ? (return true) : (return false) end def self.parse_tls_options(ssl_type, ssl_cipher, x509_issuer, x509_subject) if ssl_type == 'ANY' - return ['SSL'] + ['SSL'] elsif ssl_type == 'X509' - return ['X509'] + ['X509'] elsif ssl_type == 'SPECIFIED' options = [] - options << "CIPHER #{ssl_cipher}" if not ssl_cipher.nil? and not ssl_cipher.empty? - options << "ISSUER #{x509_issuer}" if not x509_issuer.nil? and not x509_issuer.empty? - options << "SUBJECT #{x509_subject}" if not x509_subject.nil? and not x509_subject.empty? - return options + options << "CIPHER #{ssl_cipher}" if !ssl_cipher.nil? && !ssl_cipher.empty? + options << "ISSUER #{x509_issuer}" if !x509_issuer.nil? && !x509_issuer.empty? + options << "SUBJECT #{x509_subject}" if !x509_subject.nil? && !x509_subject.empty? + options else - return ['NONE'] + ['NONE'] end end - end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/lib/puppet/type/mysql_database.rb puppet-module-puppetlabs-mysql-5.3.0/lib/puppet/type/mysql_database.rb --- puppet-module-puppetlabs-mysql-3.10.0/lib/puppet/type/mysql_database.rb 2016-07-27 17:34:11.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/lib/puppet/type/mysql_database.rb 2017-09-07 12:06:56.000000000 +0000 @@ -6,20 +6,19 @@ autorequire(:file) { '/root/.my.cnf' } autorequire(:class) { 'mysql::server' } - newparam(:name, :namevar => true) do + newparam(:name, namevar: true) do desc 'The name of the MySQL database to manage.' end newproperty(:charset) do desc 'The CHARACTER SET setting for the database' defaultto :utf8 - newvalue(/^\S+$/) + newvalue(%r{^\S+$}) end newproperty(:collate) do desc 'The COLLATE setting for the database' defaultto :utf8_general_ci - newvalue(/^\S+$/) + newvalue(%r{^\S+$}) end - end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/lib/puppet/type/mysql_datadir.rb puppet-module-puppetlabs-mysql-5.3.0/lib/puppet/type/mysql_datadir.rb --- puppet-module-puppetlabs-mysql-3.10.0/lib/puppet/type/mysql_datadir.rb 2016-07-27 17:34:11.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/lib/puppet/type/mysql_datadir.rb 2017-09-09 00:10:15.000000000 +0000 @@ -5,13 +5,13 @@ autorequire(:package) { 'mysql-server' } - newparam(:datadir, :namevar => true) do - desc "The datadir name" + newparam(:datadir, namevar: true) do + desc 'The datadir name' end newparam(:basedir) do desc 'The basedir name, default /usr.' - newvalues(/^\//) + newvalues(%r{^/}) end newparam(:user) do @@ -19,17 +19,16 @@ end newparam(:defaults_extra_file) do - desc "MySQL defaults-extra-file with absolute path (*.cnf)." - newvalues(/^\/.*\.cnf$/) + desc 'MySQL defaults-extra-file with absolute path (*.cnf).' + newvalues(%r{^/.*\.cnf$}) end - newparam(:insecure, :boolean => true) do - desc "Insecure initialization (needed for 5.7.6++)." + newparam(:insecure, boolean: true) do + desc 'Insecure initialization (needed for 5.7.6++).' end newparam(:log_error) do - desc "The path to the mysqld error log file (used with the --log-error option)" - newvalues(/^\//) + desc 'The path to the mysqld error log file (used with the --log-error option)' + newvalues(%r{^/}) end - end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/lib/puppet/type/mysql_grant.rb puppet-module-puppetlabs-mysql-5.3.0/lib/puppet/type/mysql_grant.rb --- puppet-module-puppetlabs-mysql-3.10.0/lib/puppet/type/mysql_grant.rb 2016-09-06 22:04:13.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/lib/puppet/type/mysql_grant.rb 2017-10-05 23:11:56.000000000 +0000 @@ -12,31 +12,35 @@ # 'ALL'. This can't be done in the munge in the property as that iterates # over the array and there's no way to replace the entire array before it's # returned to the provider. - if self[:ensure] == :present and Array(self[:privileges]).count > 1 and self[:privileges].to_s.include?('ALL') + if self[:ensure] == :present && Array(self[:privileges]).count > 1 && self[:privileges].to_s.include?('ALL') self[:privileges] = 'ALL' end # Sort the privileges array in order to ensure the comparision in the provider # self.instances method match. Otherwise this causes it to keep resetting the # privileges. - self[:privileges] = Array(self[:privileges]).map{ |priv| - # split and sort the column_privileges in the parentheses and rejoin - if priv.include?('(') - type, col=priv.strip.split(/\s+|\b/,2) - type.upcase + " (" + col.slice(1...-1).strip.split(/\s*,\s*/).sort.join(', ') + ")" - else - priv.strip.upcase - end - }.uniq.reject{|k| k == 'GRANT' or k == 'GRANT OPTION'}.sort! + # rubocop:disable Style/MultilineBlockChain + self[:privileges] = Array(self[:privileges]).map { |priv| + # split and sort the column_privileges in the parentheses and rejoin + if priv.include?('(') + type, col = priv.strip.split(%r{\s+|\b}, 2) + type.upcase + ' (' + col.slice(1...-1).strip.split(%r{\s*,\s*}).sort.join(', ') + ')' + else + priv.strip.upcase + end + }.uniq.reject { |k| k == 'GRANT' || k == 'GRANT OPTION' }.sort! end - + # rubocop:enable Style/MultilineBlockChain validate do - fail('privileges parameter is required.') if self[:ensure] == :present and self[:privileges].nil? - fail('table parameter is required.') if self[:ensure] == :present and self[:table].nil? - fail('user parameter is required.') if self[:ensure] == :present and self[:user].nil? - fail('name must match user and table parameters') if self[:name] != "#{self[:user]}/#{self[:table]}" + raise(_('`privileges` `parameter` is required.')) if self[:ensure] == :present && self[:privileges].nil? + raise(_('`privileges` `parameter`: PROXY can only be specified by itself.')) if Array(self[:privileges]).count > 1 && Array(self[:privileges]).include?('PROXY') + raise(_('`table` `parameter` is required.')) if self[:ensure] == :present && self[:table].nil? + raise(_('`user` `parameter` is required.')) if self[:ensure] == :present && self[:user].nil? + if self[:user] && self[:table] + raise(_('`name` `parameter` must match user@host/table format.')) if self[:name] != "#{self[:user]}/#{self[:table]}" + end end - newparam(:name, :namevar => true) do + newparam(:name, namevar: true) do desc 'Name to describe the grant.' munge do |value| @@ -44,18 +48,31 @@ end end - newproperty(:privileges, :array_matching => :all) do + newproperty(:privileges, array_matching: :all) do desc 'Privileges for user' + + validate do |value| + mysql_version = Facter.value(:mysql_version) + if value =~ %r{proxy}i && Puppet::Util::Package.versioncmp(mysql_version, '5.5.0') < 0 + raise(ArgumentError, _('PROXY user not supported on mysql versions < 5.5.0. Current version %{version}.') % { version: mysql_version }) + end + end end newproperty(:table) do desc 'Table to apply privileges to.' + validate do |value| + if Array(@resource[:privileges]).include?('PROXY') && !%r{^[0-9a-zA-Z$_]*@[\w%\.:\-\/]*$}.match(value) + raise(ArgumentError, _('`table` `property` for PROXY should be specified as proxy_user@proxy_host.')) + end + end + munge do |value| - value.delete("`") + value.delete('`') end - newvalues(/.*\..*/,/@/) + newvalues(%r{.*\..*}, %r{^[0-9a-zA-Z$_]*@[\w%\.:\-/]*$}) end newproperty(:user) do @@ -63,41 +80,38 @@ validate do |value| # http://dev.mysql.com/doc/refman/5.5/en/identifiers.html # If at least one special char is used, string must be quoted - # http://stackoverflow.com/questions/8055727/negating-a-backreference-in-regular-expressions/8057827#8057827 - if matches = /^(['`"])((?!\1).)*\1@([\w%\.:\-\/]+)$/.match(value) + # rubocop:disable Lint/AssignmentInCondition + # rubocop:disable Lint/UselessAssignment + if matches = %r{^(['`"])((?!\1).)*\1@([\w%\.:\-/]+)$}.match(value) user_part = matches[2] host_part = matches[3] - elsif matches = /^([0-9a-zA-Z$_]*)@([\w%\.:\-\/]+)$/.match(value) + elsif matches = %r{^([0-9a-zA-Z$_]*)@([\w%\.:\-/]+)$}.match(value) user_part = matches[1] host_part = matches[2] - elsif matches = /^((?!['`"]).*[^0-9a-zA-Z$_].*)@(.+)$/.match(value) + elsif matches = %r{^((?!['`"]).*[^0-9a-zA-Z$_].*)@(.+)$}.match(value) user_part = matches[1] host_part = matches[2] else - raise(ArgumentError, "Invalid database user #{value}") + raise(ArgumentError, _('Invalid database user %{user}.') % { user: value }) end - + # rubocop:enable Lint/AssignmentInCondition + # rubocop:enable Lint/UselessAssignment mysql_version = Facter.value(:mysql_version) unless mysql_version.nil? - if Puppet::Util::Package.versioncmp(mysql_version, '5.7.8') < 0 and user_part.size > 16 - raise(ArgumentError, 'MySQL usernames are limited to a maximum of 16 characters') - elsif Puppet::Util::Package.versioncmp(mysql_version, '10.0.0') < 0 and user_part.size > 32 - raise(ArgumentError, 'MySQL usernames are limited to a maximum of 32 characters') - elsif Puppet::Util::Package.versioncmp(mysql_version, '10.0.0') > 0 and user_part.size > 80 - raise(ArgumentError, 'MySQL usernames are limited to a maximum of 80 characters') - end + raise(ArgumentError, _('MySQL usernames are limited to a maximum of 16 characters.')) if Puppet::Util::Package.versioncmp(mysql_version, '5.7.8') < 0 && user_part.size > 16 + raise(ArgumentError, _('MySQL usernames are limited to a maximum of 32 characters.')) if Puppet::Util::Package.versioncmp(mysql_version, '10.0.0') < 0 && user_part.size > 32 + raise(ArgumentError, _('MySQL usernames are limited to a maximum of 80 characters.')) if Puppet::Util::Package.versioncmp(mysql_version, '10.0.0') > 0 && user_part.size > 80 end end munge do |value| - matches = /^((['`"]?).*\2)@(.+)$/.match(value) + matches = %r{^((['`"]?).*\2)@(.+)$}.match(value) "#{matches[1]}@#{matches[3].downcase}" end end - newproperty(:options, :array_matching => :all) do + newproperty(:options, array_matching: :all) do desc 'Options to grant.' end - end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/lib/puppet/type/mysql_plugin.rb puppet-module-puppetlabs-mysql-5.3.0/lib/puppet/type/mysql_plugin.rb --- puppet-module-puppetlabs-mysql-3.10.0/lib/puppet/type/mysql_plugin.rb 2016-07-27 17:34:11.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/lib/puppet/type/mysql_plugin.rb 2017-09-07 12:06:56.000000000 +0000 @@ -5,13 +5,12 @@ autorequire(:file) { '/root/.my.cnf' } - newparam(:name, :namevar => true) do + newparam(:name, namevar: true) do desc 'The name of the MySQL plugin to manage.' end newproperty(:soname) do desc 'The name of the library' - newvalue(/^\w+\.\w+$/) + newvalue(%r{^\w+\.\w+$}) end - end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/lib/puppet/type/mysql_user.rb puppet-module-puppetlabs-mysql-5.3.0/lib/puppet/type/mysql_user.rb --- puppet-module-puppetlabs-mysql-3.10.0/lib/puppet/type/mysql_user.rb 2016-11-07 20:14:07.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/lib/puppet/type/mysql_user.rb 2017-10-05 23:11:56.000000000 +0000 @@ -7,99 +7,95 @@ autorequire(:file) { '/root/.my.cnf' } autorequire(:class) { 'mysql::server' } - newparam(:name, :namevar => true) do + newparam(:name, namevar: true) do desc "The name of the user. This uses the 'username@hostname' or username@hostname." validate do |value| # http://dev.mysql.com/doc/refman/5.5/en/identifiers.html # If at least one special char is used, string must be quoted - # http://stackoverflow.com/questions/8055727/negating-a-backreference-in-regular-expressions/8057827#8057827 - if matches = /^(['`"])((?:(?!\1).)*)\1@([\w%\.:\-\/]+)$/.match(value) + mysql_version = Facter.value(:mysql_version) + # rubocop:disable Lint/AssignmentInCondition + # rubocop:disable Lint/UselessAssignment + if matches = %r{^(['`"])((?:(?!\1).)*)\1@([\w%\.:\-/]+)$}.match(value) user_part = matches[2] host_part = matches[3] - elsif matches = /^([0-9a-zA-Z$_]*)@([\w%\.:\-\/]+)$/.match(value) + elsif matches = %r{^([0-9a-zA-Z$_]*)@([\w%\.:\-/]+)$}.match(value) user_part = matches[1] host_part = matches[2] - elsif matches = /^((?!['`"]).*[^0-9a-zA-Z$_].*)@(.+)$/.match(value) + elsif matches = %r{^((?!['`"]).*[^0-9a-zA-Z$_].*)@(.+)$}.match(value) user_part = matches[1] host_part = matches[2] else - raise(ArgumentError, "Invalid database user #{value}") + raise ArgumentError, _('Invalid database user %{user}.') % { user: value } end - - mysql_version = Facter.value(:mysql_version) + # rubocop:enable Lint/AssignmentInCondition + # rubocop:enable Lint/UselessAssignment unless mysql_version.nil? - if Puppet::Util::Package.versioncmp(mysql_version, '5.7.8') < 0 and user_part.size > 16 - raise(ArgumentError, 'MySQL usernames are limited to a maximum of 16 characters') - elsif Puppet::Util::Package.versioncmp(mysql_version, '10.0.0') < 0 and user_part.size > 32 - raise(ArgumentError, 'MySQL usernames are limited to a maximum of 32 characters') - elsif Puppet::Util::Package.versioncmp(mysql_version, '10.0.0') > 0 and user_part.size > 80 - raise(ArgumentError, 'MySQL usernames are limited to a maximum of 80 characters') - end + raise(ArgumentError, _('MySQL usernames are limited to a maximum of 16 characters.')) if Puppet::Util::Package.versioncmp(mysql_version, '5.7.8') < 0 && user_part.size > 16 + raise(ArgumentError, _('MySQL usernames are limited to a maximum of 32 characters.')) if Puppet::Util::Package.versioncmp(mysql_version, '10.0.0') < 0 && user_part.size > 32 + raise(ArgumentError, _('MySQL usernames are limited to a maximum of 80 characters.')) if Puppet::Util::Package.versioncmp(mysql_version, '10.0.0') > 0 && user_part.size > 80 end end munge do |value| - matches = /^((['`"]?).*\2)@(.+)$/.match(value) + matches = %r{^((['`"]?).*\2)@(.+)$}.match(value) "#{matches[1]}@#{matches[3].downcase}" end end newproperty(:password_hash) do desc 'The password hash of the user. Use mysql_password() for creating such a hash.' - newvalue(/\w*/) + newvalue(%r{\w*}) end newproperty(:plugin) do desc 'The authentication plugin of the user.' - newvalue(/\w+/) + newvalue(%r{\w+}) end newproperty(:max_user_connections) do - desc "Max concurrent connections for the user. 0 means no (or global) limit." - newvalue(/\d+/) + desc 'Max concurrent connections for the user. 0 means no (or global) limit.' + newvalue(%r{\d+}) end newproperty(:max_connections_per_hour) do - desc "Max connections per hour for the user. 0 means no (or global) limit." - newvalue(/\d+/) + desc 'Max connections per hour for the user. 0 means no (or global) limit.' + newvalue(%r{\d+}) end newproperty(:max_queries_per_hour) do - desc "Max queries per hour for the user. 0 means no (or global) limit." - newvalue(/\d+/) + desc 'Max queries per hour for the user. 0 means no (or global) limit.' + newvalue(%r{\d+}) end newproperty(:max_updates_per_hour) do - desc "Max updates per hour for the user. 0 means no (or global) limit." - newvalue(/\d+/) + desc 'Max updates per hour for the user. 0 means no (or global) limit.' + newvalue(%r{\d+}) end - newproperty(:tls_options, :array_matching => :all) do - desc "Options to that set the TLS-related REQUIRE attributes for the user." + newproperty(:tls_options, array_matching: :all) do + desc 'Options to that set the TLS-related REQUIRE attributes for the user.' validate do |value| - value = [value] if not value.is_a?(Array) - if value.include? 'NONE' or value.include? 'SSL' or value.include? 'X509' + value = [value] unless value.is_a?(Array) + if value.include?('NONE') || value.include?('SSL') || value.include?('X509') if value.length > 1 - raise(ArgumentError, "REQUIRE tls options NONE, SSL and X509 cannot be used with other options, you may only use one of them.") + raise(ArgumentError, _('`tls_options` `property`: The values NONE, SSL and X509 cannot be used with other options, you may only pick one of them.')) end else value.each do |opt| - if not o = opt.match(/^(CIPHER|ISSUER|SUBJECT)/i) - raise(ArgumentError, "Invalid tls option #{o}") - end + o = opt.match(%r{^(CIPHER|ISSUER|SUBJECT)}i) + raise(ArgumentError, _('Invalid tls option %{option}.') % { option: o }) unless o end end end def insync?(is) # The current value may be nil and we don't # want to call sort on it so make sure we have arrays - if is.is_a?(Array) and @should.is_a?(Array) + if is.is_a?(Array) && @should.is_a?(Array) is.sort == @should.sort else is == @should end end end - end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/locales/config.yaml puppet-module-puppetlabs-mysql-5.3.0/locales/config.yaml --- puppet-module-puppetlabs-mysql-3.10.0/locales/config.yaml 1970-01-01 00:00:00.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/locales/config.yaml 2018-01-19 18:07:36.000000000 +0000 @@ -0,0 +1,26 @@ +--- +# This is the project-specific configuration file for setting up +# fast_gettext for your project. +gettext: + # This is used for the name of the .pot and .po files; they will be + # called .pot? + project_name: puppetlabs-mysql + # This is used in comments in the .pot and .po files to indicate what + # project the files belong to and should bea little more desctiptive than + # + package_name: puppetlabs-mysql + # The locale that the default messages in the .pot file are in + default_locale: en + # The email used for sending bug reports. + bugs_address: docs@puppet.com + # The holder of the copyright. + copyright_holder: Puppet, Inc. + # This determines which comments in code should be eligible for translation. + # Any comments that start with this string will be externalized. (Leave + # empty to include all.) + comments_tag: TRANSLATOR + # Patterns for +Dir.glob+ used to find all files that might contain + # translatable content, relative to the project root directory + source_files: + - './lib/**/*.rb' + diff -Nru puppet-module-puppetlabs-mysql-3.10.0/locales/ja/puppetlabs-mysql.po puppet-module-puppetlabs-mysql-5.3.0/locales/ja/puppetlabs-mysql.po --- puppet-module-puppetlabs-mysql-3.10.0/locales/ja/puppetlabs-mysql.po 1970-01-01 00:00:00.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/locales/ja/puppetlabs-mysql.po 2017-10-05 23:11:56.000000000 +0000 @@ -0,0 +1,190 @@ +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-09-06T16:20:13+01:00\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Kojima Ai , 2017\n" +"Language-Team: Japanese (Japan) (https://www.transifex.com/puppet/teams/29089/ja_JP/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: ja_JP\n" +"Plural-Forms: nplurals=1; plural=0;\n" +"X-Generator: Translate Toolkit 2.0.0\n" + +#. ./manifests/bindings/client_dev.pp:12 +msgid "No MySQL client development package configured for %{os}." +msgstr "%{os}向けに設定されたMySQLクライアント開発パッケージはありません。" + +#. ./manifests/bindings/daemon_dev.pp:12 +msgid "No MySQL daemon development package configured for %{os}." +msgstr "%{os}向けに設定されたMySQLデーモン開発パッケージはありません。" + +#. ./manifests/bindings.pp:38 +msgid "" +"::mysql::bindings::java cannot be managed by puppet on %{osfamily} as it is " +"not in official repositories. Please disable java mysql binding." +msgstr "" +"::mysql::bindings::javaは、公式なリポジトリではなく%{osfamily}にあるそのままの状態では、Puppetによる管理はできません。java" +" mysqlバインディングを無効にしてください。" + +#. ./manifests/bindings.pp:40 +msgid "" +"::mysql::bindings::php does not need to be managed by puppet on %{osfamily} " +"as it is included in mysql package by default." +msgstr "" +"::mysql::bindings::phpは、%{osfamily}上にデフォルトでMySQLパッケージに含まれた状態のまま、Puppetで管理する必要はありません。" + +#. ./manifests/bindings.pp:42 +msgid "" +"::mysql::bindings::ruby cannot be managed by puppet on %{osfamily} as it is " +"not in official repositories. Please disable ruby mysql binding." +msgstr "" +"::mysql::bindings::rubyは、公式なリポジトリではなく%{osfamily}にあるそのままの状態では、Puppetによる管理はできません。ruby" +" mysqlバインディングを無効にしてください。" + +#. ./manifests/params.pp:124 +msgid "" +"Unsupported platform: puppetlabs-%{module_name} currently doesn't support " +"%{os}." +msgstr "サポート対象外のプラットフォーム: puppetlabs-%{module_name}は、現在%{os}をサポートしていません" + +#. ./manifests/params.pp:381 +msgid "" +"Unsupported platform: puppetlabs-%{module_name} currently doesn't support " +"%{osfamily} or %{os}." +msgstr "" +"サポート対象外のプラットフォーム: " +"puppetlabs-%{module_name}は、現在%{osfamily}または%{os}をサポートしていません" + +#. ./manifests/params.pp:465 +msgid "" +"Unsupported platform: puppetlabs-%{module_name} only supports RedHat 5.0 and" +" beyond." +msgstr "サポート対象外のプラットフォーム: puppetlabs-%{module_name}は、RedHat 5.0以降のみをサポートしています" + +#. ./manifests/server/backup.pp:28 +msgid "" +"The 'prescript' option is not currently implemented for the %{provider} " +"backup provider." +msgstr "'prescript'オプションは、現在、%{provider}バックアッププロバイダ向けには実装されていません。" + +#. ./manifests/server.pp:48 +msgid "" +"The `old_root_password` attribute is no longer used and will be removed in a" +" future release." +msgstr "`old_root_password`属性は廃止予定であり、今後のリリースで廃止されます。" + +#. metadata.json +#: .summary +msgid "Installs, configures, and manages the MySQL service." +msgstr "MySQLサービスをインストール、設定、管理します。" + +#. metadata.json +#: .description +msgid "MySQL module" +msgstr "MySQLモジュール" + +#: ./lib/puppet/parser/functions/mysql_deepmerge.rb:22 +msgid "" +"mysql_deepmerge(): wrong number of arguments (%{args_length}; must be at " +"least 2)" +msgstr "mysql_deepmerge(): 引数の数が正しくありません(%{args_length}; 2以上にする必要があります)" + +#: ./lib/puppet/parser/functions/mysql_deepmerge.rb:30 +msgid "" +"mysql_deepmerge: unexpected argument type %{arg_class}, only expects hash " +"arguments." +msgstr "mysql_deepmerge: 予期せぬ引数タイプ%{arg_class}です。想定される引数はハッシュ引数のみです。" + +#: ./lib/puppet/parser/functions/mysql_dirname.rb:9 +msgid "" +"mysql_dirname(): Wrong number of arguments given (%{args_length} for 1)" +msgstr "mysql_dirname(): 指定された引数の数が正しくありません(%{args_length}は1)" + +#: ./lib/puppet/parser/functions/mysql_password.rb:11 +msgid "" +"mysql_password(): Wrong number of arguments given (%{args_length} for 1)" +msgstr "mysql_password(): 指定された引数の数が正しくありません(%{args_length}は1)" + +#: ./lib/puppet/parser/functions/mysql_strip_hash.rb:11 +msgid "mysql_strip_hash(): Requires a hash to work." +msgstr "mysql_strip_hash(): 動作するにはハッシュが必要です。" + +#: ./lib/puppet/provider/mysql_datadir/mysql.rb:24 +msgid "Defaults-extra-file %{file} is missing." +msgstr "Defaults-extra-file %{file}が見つかりません" + +#: ./lib/puppet/provider/mysql_datadir/mysql.rb:59 +msgid "ERROR: `Resource` can not be removed." +msgstr "ERROR: `Resource`を削除できませんでした。" + +#: ./lib/puppet/provider/mysql_grant/mysql.rb:19 +msgid "#mysql had an error -> %{inspect}" +msgstr "#mysqlにエラーがありました -> %{inspect}" + +#: ./lib/puppet/provider/mysql_user/mysql.rb:125 +msgid "Only mysql_native_password (*ABCD..XXX) hashes are supported." +msgstr "mysql_native_password (*ABCD...XXX)ハッシュのみサポートされています。" + +#: ./lib/puppet/type/mysql_grant.rb:34 +msgid "`privileges` `parameter` is required." +msgstr "`privileges` `parameter`が必要です。" + +#: ./lib/puppet/type/mysql_grant.rb:35 +msgid "`privileges` `parameter`: PROXY can only be specified by itself." +msgstr "`privileges` `parameter`: PROXYは自身で指定することのみ可能です。" + +#: ./lib/puppet/type/mysql_grant.rb:36 +msgid "`table` `parameter` is required." +msgstr "`table` `parameter`が必要です。" + +#: ./lib/puppet/type/mysql_grant.rb:37 +msgid "`user` `parameter` is required." +msgstr "`user` `parameter`が必要です。" + +#: ./lib/puppet/type/mysql_grant.rb:39 +msgid "`name` `parameter` must match user@host/table format." +msgstr "`name` `parameter`はuser@host/tableの形式と一致している必要があります。" + +#: ./lib/puppet/type/mysql_grant.rb:57 +msgid "" +"PROXY user not supported on mysql versions < 5.5.0. Current version " +"%{version}." +msgstr "PROXYユーザはmysql 5.5.0以前のバージョンではサポートされていません。現在のバージョン%{version}" + +#: ./lib/puppet/type/mysql_grant.rb:67 +msgid "" +"`table` `property` for PROXY should be specified as proxy_user@proxy_host." +msgstr "PROXYの`table` `property`はproxy_user@proxy_hostとして指定されている必要があります。" + +#: ./lib/puppet/type/mysql_grant.rb:96 ./lib/puppet/type/mysql_user.rb:29 +msgid "Invalid database user %{user}." +msgstr "無効なデータベースのユーザ%{user}" + +#: ./lib/puppet/type/mysql_grant.rb:102 ./lib/puppet/type/mysql_user.rb:34 +msgid "MySQL usernames are limited to a maximum of 16 characters." +msgstr "MySQLユーザ名は最大16文字に制限されています。" + +#: ./lib/puppet/type/mysql_grant.rb:103 ./lib/puppet/type/mysql_user.rb:35 +msgid "MySQL usernames are limited to a maximum of 32 characters." +msgstr "MySQLユーザ名は最大32文字に制限されています。" + +#: ./lib/puppet/type/mysql_grant.rb:104 ./lib/puppet/type/mysql_user.rb:36 +msgid "MySQL usernames are limited to a maximum of 80 characters." +msgstr "MySQLユーザ名は最大80文字に制限されています。" + +#: ./lib/puppet/type/mysql_user.rb:82 +msgid "" +"`tls_options` `property`: The values NONE, SSL and X509 cannot be used with " +"other options, you may only pick one of them." +msgstr "" +"`tls_options` `property`: " +"NONE、SSL、X509は他のオプションと同時に使用することはできません。いずれか1つのみ選択可能です。" + +#: ./lib/puppet/type/mysql_user.rb:87 +msgid "Invalid tls option %{option}." +msgstr "無効なtlsオプション%{option}" diff -Nru puppet-module-puppetlabs-mysql-3.10.0/locales/puppetlabs-mysql.pot puppet-module-puppetlabs-mysql-5.3.0/locales/puppetlabs-mysql.pot --- puppet-module-puppetlabs-mysql-3.10.0/locales/puppetlabs-mysql.pot 1970-01-01 00:00:00.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/locales/puppetlabs-mysql.pot 2017-10-05 23:11:56.000000000 +0000 @@ -0,0 +1,176 @@ +"Project-Id-Version: puppetlabs-mysql 3.11.0-50-gd122d86\n" +"\n" +"Report-Msgid-Bugs-To: docs@puppet.com\n" +"POT-Creation-Date: 2017-09-14 14:21+0100\n" +"PO-Revision-Date: 2017-09-14 14:21+0100\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" + +#. metadata.json +#: .summary +msgid "Installs, configures, and manages the MySQL service." +msgstr "" + +#. metadata.json +#: .description +msgid "MySQL module" +msgstr "" + +#. ./manifests/bindings/client_dev.pp:12 +msgid "No MySQL client development package configured for %{os}." +msgstr "" + +#. ./manifests/bindings/daemon_dev.pp:12 +msgid "No MySQL daemon development package configured for %{os}." +msgstr "" + +#. ./manifests/bindings.pp:38 +msgid "" +"::mysql::bindings::java cannot be managed by puppet on %{osfamily} as it is " +"not in official repositories. Please disable java mysql binding." +msgstr "" + +#. ./manifests/bindings.pp:40 +msgid "" +"::mysql::bindings::php does not need to be managed by puppet on %{osfamily} " +"as it is included in mysql package by default." +msgstr "" + +#. ./manifests/bindings.pp:42 +msgid "" +"::mysql::bindings::ruby cannot be managed by puppet on %{osfamily} as it is " +"not in official repositories. Please disable ruby mysql binding." +msgstr "" + +#. ./manifests/params.pp:124 +msgid "" +"Unsupported platform: puppetlabs-%{module_name} currently doesn't support " +"%{os}." +msgstr "" + +#. ./manifests/params.pp:381 +msgid "" +"Unsupported platform: puppetlabs-%{module_name} currently doesn't support " +"%{osfamily} or %{os}." +msgstr "" + +#. ./manifests/params.pp:465 +msgid "" +"Unsupported platform: puppetlabs-%{module_name} only supports RedHat 5.0 and " +"beyond." +msgstr "" + +#. ./manifests/server/backup.pp:28 +msgid "" +"The 'prescript' option is not currently implemented for the %{provider} " +"backup provider." +msgstr "" + +#. ./manifests/server.pp:48 +msgid "" +"The `old_root_password` attribute is no longer used and will be removed in a " +"future release." +msgstr "" + +#: ./lib/puppet/parser/functions/mysql_deepmerge.rb:22 +msgid "" +"mysql_deepmerge(): wrong number of arguments (%{args_length}; must be at " +"least 2)" +msgstr "" + +#: ./lib/puppet/parser/functions/mysql_deepmerge.rb:30 +msgid "" +"mysql_deepmerge: unexpected argument type %{arg_class}, only expects hash " +"arguments." +msgstr "" + +#: ./lib/puppet/parser/functions/mysql_dirname.rb:9 +msgid "mysql_dirname(): Wrong number of arguments given (%{args_length} for 1)" +msgstr "" + +#: ./lib/puppet/parser/functions/mysql_password.rb:11 +msgid "" +"mysql_password(): Wrong number of arguments given (%{args_length} for 1)" +msgstr "" + +#: ./lib/puppet/parser/functions/mysql_strip_hash.rb:11 +msgid "mysql_strip_hash(): Requires a hash to work." +msgstr "" + +#: ./lib/puppet/provider/mysql_datadir/mysql.rb:24 +msgid "Defaults-extra-file %{file} is missing." +msgstr "" + +#: ./lib/puppet/provider/mysql_datadir/mysql.rb:59 +msgid "ERROR: `Resource` can not be removed." +msgstr "" + +#: ./lib/puppet/provider/mysql_grant/mysql.rb:19 +msgid "#mysql had an error -> %{inspect}" +msgstr "" + +#: ./lib/puppet/provider/mysql_user/mysql.rb:125 +msgid "Only mysql_native_password (*ABCD...XXX) hashes are supported." +msgstr "" + +#: ./lib/puppet/type/mysql_grant.rb:34 +msgid "`privileges` `parameter` is required." +msgstr "" + +#: ./lib/puppet/type/mysql_grant.rb:35 +msgid "`privileges` `parameter`: PROXY can only be specified by itself." +msgstr "" + +#: ./lib/puppet/type/mysql_grant.rb:36 +msgid "`table` `parameter` is required." +msgstr "" + +#: ./lib/puppet/type/mysql_grant.rb:37 +msgid "`user` `parameter` is required." +msgstr "" + +#: ./lib/puppet/type/mysql_grant.rb:39 +msgid "`name` `parameter` must match user@host/table format." +msgstr "" + +#: ./lib/puppet/type/mysql_grant.rb:57 +msgid "" +"PROXY user not supported on mysql versions < 5.5.0. Current version " +"%{version}." +msgstr "" + +#: ./lib/puppet/type/mysql_grant.rb:67 +msgid "" +"`table` `property` for PROXY should be specified as proxy_user@proxy_host." +msgstr "" + +#: ./lib/puppet/type/mysql_grant.rb:96 ./lib/puppet/type/mysql_user.rb:29 +msgid "Invalid database user %{user}." +msgstr "" + +#: ./lib/puppet/type/mysql_grant.rb:102 ./lib/puppet/type/mysql_user.rb:34 +msgid "MySQL usernames are limited to a maximum of 16 characters." +msgstr "" + +#: ./lib/puppet/type/mysql_grant.rb:103 ./lib/puppet/type/mysql_user.rb:35 +msgid "MySQL usernames are limited to a maximum of 32 characters." +msgstr "" + +#: ./lib/puppet/type/mysql_grant.rb:104 ./lib/puppet/type/mysql_user.rb:36 +msgid "MySQL usernames are limited to a maximum of 80 characters." +msgstr "" + +#: ./lib/puppet/type/mysql_user.rb:82 +msgid "" +"`tls_options` `property`: The values NONE, SSL and X509 cannot be used with " +"other options, you may only pick one of them." +msgstr "" + +#: ./lib/puppet/type/mysql_user.rb:87 +msgid "Invalid tls option %{option}." +msgstr "" diff -Nru puppet-module-puppetlabs-mysql-3.10.0/MAINTAINERS.md puppet-module-puppetlabs-mysql-5.3.0/MAINTAINERS.md --- puppet-module-puppetlabs-mysql-3.10.0/MAINTAINERS.md 1970-01-01 00:00:00.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/MAINTAINERS.md 2017-05-08 20:52:37.000000000 +0000 @@ -0,0 +1,6 @@ +## Maintenance + +Maintainers: + - Puppet Forge Modules Team `forge-modules |at| puppet |dot| com` + +Tickets: https://tickets.puppet.com/browse/MODULES. Make sure to set component to `mysql`. diff -Nru puppet-module-puppetlabs-mysql-3.10.0/manifests/backup/mysqlbackup.pp puppet-module-puppetlabs-mysql-5.3.0/manifests/backup/mysqlbackup.pp --- puppet-module-puppetlabs-mysql-3.10.0/manifests/backup/mysqlbackup.pp 2016-09-06 22:04:13.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/manifests/backup/mysqlbackup.pp 2017-05-08 20:52:37.000000000 +0000 @@ -20,6 +20,7 @@ $prescript = false, $postscript = false, $execpath = '/usr/bin:/usr/sbin:/bin:/sbin', + $optional_args = [], ) inherits mysql::params { mysql_user { "${backupuser}@localhost": diff -Nru puppet-module-puppetlabs-mysql-3.10.0/manifests/backup/mysqldump.pp puppet-module-puppetlabs-mysql-5.3.0/manifests/backup/mysqldump.pp --- puppet-module-puppetlabs-mysql-3.10.0/manifests/backup/mysqldump.pp 2016-09-06 22:04:13.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/manifests/backup/mysqldump.pp 2017-05-08 20:52:37.000000000 +0000 @@ -20,9 +20,13 @@ $prescript = false, $postscript = false, $execpath = '/usr/bin:/usr/sbin:/bin:/sbin', + $optional_args = [], ) inherits mysql::params { - ensure_packages(['bzip2']) + if $backupcompress { + ensure_packages(['bzip2']) + Package['bzip2'] -> File['mysqlbackup.sh'] + } mysql_user { "${backupuser}@localhost": ensure => $ensure, @@ -50,7 +54,7 @@ user => 'root', hour => $time[0], minute => $time[1], - require => [File['mysqlbackup.sh'], Package['bzip2']], + require => File['mysqlbackup.sh'], } file { 'mysqlbackup.sh': diff -Nru puppet-module-puppetlabs-mysql-3.10.0/manifests/backup/xtrabackup.pp puppet-module-puppetlabs-mysql-5.3.0/manifests/backup/xtrabackup.pp --- puppet-module-puppetlabs-mysql-3.10.0/manifests/backup/xtrabackup.pp 2016-09-06 22:04:13.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/manifests/backup/xtrabackup.pp 2017-09-07 12:06:56.000000000 +0000 @@ -1,8 +1,8 @@ # See README.me for usage. class mysql::backup::xtrabackup ( $xtrabackup_package_name = $mysql::params::xtrabackup_package_name, - $backupuser = '', - $backuppassword = '', + $backupuser = undef, + $backuppassword = undef, $backupdir = '', $maxallowedpacket = '1M', $backupmethod = 'mysqldump', @@ -22,12 +22,29 @@ $prescript = false, $postscript = false, $execpath = '/usr/bin:/usr/sbin:/bin:/sbin', + $optional_args = [], ) inherits mysql::params { package{ $xtrabackup_package_name: ensure => $ensure, } + if $backupuser and $backuppassword { + mysql_user { "${backupuser}@localhost": + ensure => $ensure, + password_hash => mysql_password($backuppassword), + require => Class['mysql::server::root_password'], + } + + mysql_grant { "${backupuser}@localhost/*.*": + ensure => $ensure, + user => "${backupuser}@localhost", + table => '*.*', + privileges => [ 'RELOAD', 'LOCK TABLES', 'REPLICATION CLIENT' ], + require => Mysql_user["${backupuser}@localhost"], + } + } + cron { 'xtrabackup-weekly': ensure => $ensure, command => "/usr/local/sbin/xtrabackup.sh ${backupdir}", diff -Nru puppet-module-puppetlabs-mysql-3.10.0/manifests/bindings/client_dev.pp puppet-module-puppetlabs-mysql-5.3.0/manifests/bindings/client_dev.pp --- puppet-module-puppetlabs-mysql-3.10.0/manifests/bindings/client_dev.pp 2016-07-27 17:34:11.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/manifests/bindings/client_dev.pp 2017-10-05 23:11:56.000000000 +0000 @@ -9,7 +9,7 @@ provider => $mysql::bindings::client_dev_package_provider, } } else { - warning("No MySQL client development package configured for ${::operatingsystem}.") + warning(translate('No MySQL client development package configured for %{os}.', {'os' => $::operatingsystem })) } } diff -Nru puppet-module-puppetlabs-mysql-3.10.0/manifests/bindings/daemon_dev.pp puppet-module-puppetlabs-mysql-5.3.0/manifests/bindings/daemon_dev.pp --- puppet-module-puppetlabs-mysql-3.10.0/manifests/bindings/daemon_dev.pp 2016-07-27 17:34:11.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/manifests/bindings/daemon_dev.pp 2017-10-05 23:11:56.000000000 +0000 @@ -9,7 +9,7 @@ provider => $mysql::bindings::daemon_dev_package_provider, } } else { - warning("No MySQL daemon development package configured for ${::operatingsystem}.") + warning(translate('No MySQL daemon development package configured for %{os}.', {'os' => $::operatingsystem })) } } diff -Nru puppet-module-puppetlabs-mysql-3.10.0/manifests/bindings.pp puppet-module-puppetlabs-mysql-5.3.0/manifests/bindings.pp --- puppet-module-puppetlabs-mysql-3.10.0/manifests/bindings.pp 2016-07-27 17:34:11.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/manifests/bindings.pp 2018-02-20 14:54:26.000000000 +0000 @@ -35,11 +35,17 @@ case $::osfamily { 'Archlinux': { - if $java_enable { fail("::mysql::bindings::java cannot be managed by puppet on ${::osfamily} as it is not in official repositories. Please disable java mysql binding.") } + if $java_enable { fail(translate('::mysql::bindings::java cannot be managed by puppet on %{osfamily} + as it is not in official repositories. Please disable java mysql binding.', + {'osfamily' => $::osfamily })) } if $perl_enable { include '::mysql::bindings::perl' } - if $php_enable { warning("::mysql::bindings::php does not need to be managed by puppet on ${::osfamily} as it is included in mysql package by default.") } + if $php_enable { warning(translate('::mysql::bindings::php does not need to be managed by puppet on %{osfamily} + as it is included in mysql package by default.', + {'osfamily' => $::osfamily })) } if $python_enable { include '::mysql::bindings::python' } - if $ruby_enable { fail("::mysql::bindings::ruby cannot be managed by puppet on ${::osfamily} as it is not in official repositories. Please disable ruby mysql binding.") } + if $ruby_enable { fail(translate('::mysql::bindings::ruby cannot be managed by puppet on %{osfamily} + as it is not in official repositories. Please disable ruby mysql binding.', + {'osfamily' => $::osfamily } )) } } default: { diff -Nru puppet-module-puppetlabs-mysql-3.10.0/manifests/client.pp puppet-module-puppetlabs-mysql-5.3.0/manifests/client.pp --- puppet-module-puppetlabs-mysql-3.10.0/manifests/client.pp 2016-07-27 17:34:11.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/manifests/client.pp 2017-05-08 20:52:37.000000000 +0000 @@ -19,11 +19,9 @@ } } - # Anchor pattern workaround to avoid resources of mysql::client::install to # "float off" outside mysql::client - anchor { 'mysql::client::start': } -> - Class['mysql::client::install'] -> - anchor { 'mysql::client::end': } - + anchor { 'mysql::client::start': } + -> Class['mysql::client::install'] + -> anchor { 'mysql::client::end': } } diff -Nru puppet-module-puppetlabs-mysql-3.10.0/manifests/db.pp puppet-module-puppetlabs-mysql-5.3.0/manifests/db.pp --- puppet-module-puppetlabs-mysql-3.10.0/manifests/db.pp 2016-11-07 20:14:07.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/manifests/db.pp 2017-09-07 12:06:56.000000000 +0000 @@ -2,26 +2,20 @@ define mysql::db ( $user, $password, - $dbname = $name, - $charset = 'utf8', - $collate = 'utf8_general_ci', - $host = 'localhost', - $grant = 'ALL', - $sql = undef, - $enforce_sql = false, - $ensure = 'present', - $import_timeout = 300, - $import_cat_cmd = 'cat', + $dbname = $name, + $charset = 'utf8', + $collate = 'utf8_general_ci', + $host = 'localhost', + $grant = 'ALL', + Optional[Variant[Array, Hash, String]] $sql = undef, + $enforce_sql = false, + Enum['absent', 'present'] $ensure = 'present', + $import_timeout = 300, + $import_cat_cmd = 'cat', ) { #input validation - validate_re($ensure, '^(present|absent)$', - "${ensure} is not supported for ensure. Allowed values are 'present' and 'absent'.") $table = "${dbname}.*" - if !(is_array($sql) or is_string($sql)) { - fail('$sql must be either a string or an array.') - } - $sql_inputs = join([$sql], ' ') include '::mysql::client' @@ -38,7 +32,6 @@ $user_resource = { ensure => $ensure, password_hash => mysql_password($password), - provider => 'mysql', } ensure_resource('mysql_user', "${user}@${host}", $user_resource) diff -Nru puppet-module-puppetlabs-mysql-3.10.0/manifests/params.pp puppet-module-puppetlabs-mysql-5.3.0/manifests/params.pp --- puppet-module-puppetlabs-mysql-3.10.0/manifests/params.pp 2016-11-07 20:14:07.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/manifests/params.pp 2018-02-20 14:54:26.000000000 +0000 @@ -121,7 +121,8 @@ } } default: { - fail("Unsupported platform: puppetlabs-${module_name} currently doesn't support ${::operatingsystem}") + fail(translate('Unsupported platform: puppetlabs-%{module_name} currently doesn\'t support %{os}.', + {'module_name' => $module_name, 'os' => $::operatingsystem })) } } $config_file = '/etc/my.cnf' @@ -167,8 +168,25 @@ } 'Debian': { - $client_package_name = 'mysql-client' - $server_package_name = 'mysql-server' + if $::operatingsystem == 'Debian' and versioncmp($::operatingsystemrelease, '9') >= 0 { + $provider = 'mariadb' + } else { + $provider = 'mysql' + } + + if $provider == 'mariadb' { + $client_package_name = 'mariadb-client' + $server_package_name = 'mariadb-server' + $server_service_name = 'mariadb' + $client_dev_package_name = 'libmariadbclient-dev' + $daemon_dev_package_name = 'libmariadbd-dev' + } else { + $client_package_name = 'mysql-client' + $server_package_name = 'mysql-server' + $server_service_name = 'mysql' + $client_dev_package_name = 'libmysqlclient-dev' + $daemon_dev_package_name = 'libmysqld-dev' + } $basedir = '/usr' $config_file = '/etc/mysql/my.cnf' @@ -178,7 +196,6 @@ $pidfile = '/var/run/mysqld/mysqld.pid' $root_group = 'root' $mysql_group = 'adm' - $server_service_name = 'mysql' $socket = '/var/run/mysqld/mysqld.sock' $ssl_ca = '/etc/mysql/cacert.pem' $ssl_cert = '/etc/mysql/server-cert.pem' @@ -187,19 +204,20 @@ # mysql::bindings $java_package_name = 'libmysql-java' $perl_package_name = 'libdbd-mysql-perl' - $php_package_name = $::lsbdistcodename ? { - 'xenial' => 'php-mysql', - default => 'php5-mysql', + if ($::operatingsystem == 'Ubuntu' and versioncmp($::operatingsystemrelease, '16.04') >= 0) or + ($::operatingsystem == 'Debian' and versioncmp($::operatingsystemrelease, '9') >= 0) { + $php_package_name = 'php-mysql' + } else { + $php_package_name = 'php5-mysql' } $python_package_name = 'python-mysqldb' $ruby_package_name = $::lsbdistcodename ? { - 'trusty' => 'ruby-mysql', 'jessie' => 'ruby-mysql', + 'stretch' => 'ruby-mysql2', + 'trusty' => 'ruby-mysql', 'xenial' => 'ruby-mysql', default => 'libmysql-ruby', } - $client_dev_package_name = 'libmysqlclient-dev' - $daemon_dev_package_name = 'libmysqld-dev' } 'Archlinux': { @@ -363,7 +381,8 @@ } default: { - fail("Unsupported platform: puppetlabs-${module_name} currently doesn't support ${::osfamily} or ${::operatingsystem}") + fail(translate('Unsupported platform: puppetlabs-%{module_name} currently doesn\'t support %{osfamily} or %{os}.', + {'module_name' => $module_name, 'os' => $::operatingsystem, 'osfamily' => $::osfamily})) } } } @@ -371,7 +390,9 @@ case $::operatingsystem { 'Ubuntu': { - if versioncmp($::operatingsystemmajrelease, '14.10') > 0 { + # lint:ignore:only_variable_string + if versioncmp("${::operatingsystemmajrelease}", '14.10') > 0 { + # lint:endignore $server_service_provider = 'systemd' } else { $server_service_provider = 'upstart' @@ -445,6 +466,6 @@ ## Additional graceful failures if $::osfamily == 'RedHat' and $::operatingsystemmajrelease == '4' and $::operatingsystem != 'Amazon' { - fail("Unsupported platform: puppetlabs-${module_name} only supports RedHat 5.0 and beyond") + fail(translate('Unsupported platform: puppetlabs-%{module_name} only supports RedHat 5.0 and beyond.', {'module_name' => $module_name})) } } diff -Nru puppet-module-puppetlabs-mysql-3.10.0/manifests/server/backup.pp puppet-module-puppetlabs-mysql-5.3.0/manifests/server/backup.pp --- puppet-module-puppetlabs-mysql-3.10.0/manifests/server/backup.pp 2016-09-06 22:04:13.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/manifests/server/backup.pp 2018-02-20 14:54:26.000000000 +0000 @@ -21,10 +21,12 @@ $execpath = '/usr/bin:/usr/sbin:/bin:/sbin', $provider = 'mysqldump', $maxallowedpacket = '1M', + $optional_args = [], ) { if $prescript and $provider =~ /(mysqldump|mysqlbackup)/ { - warning("The \$prescript option is not currently implemented for the ${provider} backup provider.") + warning(translate("The 'prescript' option is not currently implemented for the %{provider} backup provider.", + {'provider' => $provider})) } create_resources('class', { @@ -49,6 +51,7 @@ 'postscript' => $postscript, 'execpath' => $execpath, 'maxallowedpacket' => $maxallowedpacket, + 'optional_args' => $optional_args, } }) diff -Nru puppet-module-puppetlabs-mysql-3.10.0/manifests/server/config.pp puppet-module-puppetlabs-mysql-5.3.0/manifests/server/config.pp --- puppet-module-puppetlabs-mysql-3.10.0/manifests/server/config.pp 2016-09-06 22:04:13.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/manifests/server/config.pp 2018-02-20 14:54:26.000000000 +0000 @@ -40,7 +40,8 @@ # on mariadb systems, $includedir is not defined, but /etc/my.cnf.d has # to be managed to place the server.cnf there $configparentdir = mysql_dirname($mysql::server::config_file) - if $configparentdir != '/' and $configparentdir != '/etc' and $configparentdir != $includedir and $configparentdir != mysql_dirname($includedir) { + if $configparentdir != '/' and $configparentdir != '/etc' and $configparentdir + != $includedir and $configparentdir != mysql_dirname($includedir) { file { $configparentdir: ensure => directory, mode => '0755', @@ -50,7 +51,8 @@ if $options['mysqld']['ssl-disable'] { notify {'ssl-disable': - message =>'Disabling SSL is evil! You should never ever do this except if you are forced to use a mysql version compiled without SSL support' + message =>'Disabling SSL is evil! You should never ever do this except + if you are forced to use a mysql version compiled without SSL support' } } } diff -Nru puppet-module-puppetlabs-mysql-3.10.0/manifests/server/installdb.pp puppet-module-puppetlabs-mysql-5.3.0/manifests/server/installdb.pp --- puppet-module-puppetlabs-mysql-3.10.0/manifests/server/installdb.pp 2016-09-06 22:04:13.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/manifests/server/installdb.pp 2017-05-08 20:52:37.000000000 +0000 @@ -19,11 +19,11 @@ if $options['mysqld']['log-error'] { file { $options['mysqld']['log-error']: - ensure => present, - owner => $mysqluser, - group => $::mysql::server::mysql_group, - mode => 'u+rw', - before => Mysql_datadir[ $datadir ], + ensure => present, + owner => $mysqluser, + group => $::mysql::server::mysql_group, + mode => 'u+rw', + require => Mysql_datadir[ $datadir ], } } diff -Nru puppet-module-puppetlabs-mysql-3.10.0/manifests/server/mysqltuner.pp puppet-module-puppetlabs-mysql-5.3.0/manifests/server/mysqltuner.pp --- puppet-module-puppetlabs-mysql-3.10.0/manifests/server/mysqltuner.pp 2016-07-27 17:34:11.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/manifests/server/mysqltuner.pp 2017-05-08 20:52:37.000000000 +0000 @@ -3,6 +3,7 @@ $ensure = 'present', $version = 'v1.3.0', $source = undef, + $environment = undef, # environment for staging::file ) { if $source { @@ -36,7 +37,8 @@ } staging::file { "mysqltuner-${_version}": - source => $_source, + source => $_source, + environment => $environment, } file { '/usr/local/bin/mysqltuner': ensure => $ensure, diff -Nru puppet-module-puppetlabs-mysql-3.10.0/manifests/server/service.pp puppet-module-puppetlabs-mysql-5.3.0/manifests/server/service.pp --- puppet-module-puppetlabs-mysql-3.10.0/manifests/server/service.pp 2016-07-27 17:34:11.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/manifests/server/service.pp 2018-02-20 14:54:26.000000000 +0000 @@ -12,7 +12,8 @@ $service_ensure = undef } - if $mysql::server::override_options and $mysql::server::override_options['mysqld'] and $mysql::server::override_options['mysqld']['user'] { + if $mysql::server::override_options and $mysql::server::override_options['mysqld'] + and $mysql::server::override_options['mysqld']['user'] { $mysqluser = $mysql::server::override_options['mysqld']['user'] } else { $mysqluser = $options['mysqld']['user'] @@ -40,19 +41,22 @@ File['mysql-config-file'] -> Service['mysqld'] } - if $mysql::server::override_options and $mysql::server::override_options['mysqld'] and $mysql::server::override_options['mysqld']['socket'] { + if $mysql::server::override_options and $mysql::server::override_options['mysqld'] + and $mysql::server::override_options['mysqld']['socket'] { $mysqlsocket = $mysql::server::override_options['mysqld']['socket'] } else { $mysqlsocket = $options['mysqld']['socket'] } - exec { 'wait_for_mysql_socket_to_open': - command => "test -S ${mysqlsocket}", - unless => "test -S ${mysqlsocket}", - tries => '3', - try_sleep => '10', - require => Service['mysqld'], - path => '/bin:/usr/bin', + if $service_ensure != 'stopped' { + exec { 'wait_for_mysql_socket_to_open': + command => "test -S ${mysqlsocket}", + unless => "test -S ${mysqlsocket}", + tries => '3', + try_sleep => '10', + require => Service['mysqld'], + path => '/bin:/usr/bin', + } } } } diff -Nru puppet-module-puppetlabs-mysql-3.10.0/manifests/server.pp puppet-module-puppetlabs-mysql-5.3.0/manifests/server.pp --- puppet-module-puppetlabs-mysql-3.10.0/manifests/server.pp 2016-09-06 22:04:13.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/manifests/server.pp 2017-10-05 23:11:56.000000000 +0000 @@ -45,7 +45,7 @@ $real_service_manage = $service_manage } if $old_root_password { - warning('old_root_password is no longer used and will be removed in a future release') + warning(translate('The `old_root_password` attribute is no longer used and will be removed in a future release.')) } # Create a merged together set of options. Rightmost hashes win over left. @@ -71,19 +71,19 @@ anchor { 'mysql::server::end': } if $restart { - Class['mysql::server::config'] ~> - Class['mysql::server::service'] + Class['mysql::server::config'] + ~> Class['mysql::server::service'] } - Anchor['mysql::server::start'] -> - Class['mysql::server::config'] -> - Class['mysql::server::install'] -> - Class['mysql::server::binarylog'] -> - Class['mysql::server::installdb'] -> - Class['mysql::server::service'] -> - Class['mysql::server::root_password'] -> - Class['mysql::server::providers'] -> - Anchor['mysql::server::end'] + Anchor['mysql::server::start'] + -> Class['mysql::server::config'] + -> Class['mysql::server::install'] + -> Class['mysql::server::binarylog'] + -> Class['mysql::server::installdb'] + -> Class['mysql::server::service'] + -> Class['mysql::server::root_password'] + -> Class['mysql::server::providers'] + -> Anchor['mysql::server::end'] } diff -Nru puppet-module-puppetlabs-mysql-3.10.0/metadata.json puppet-module-puppetlabs-mysql-5.3.0/metadata.json --- puppet-module-puppetlabs-mysql-3.10.0/metadata.json 2016-11-07 20:18:10.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/metadata.json 2018-02-20 14:55:47.000000000 +0000 @@ -1,6 +1,6 @@ { "name": "puppetlabs-mysql", - "version": "3.10.0", + "version": "5.3.0", "author": "Puppet Labs", "summary": "Installs, configures, and manages the MySQL service.", "license": "Apache-2.0", @@ -8,8 +8,18 @@ "project_page": "http://github.com/puppetlabs/puppetlabs-mysql", "issues_url": "https://tickets.puppetlabs.com/browse/MODULES", "dependencies": [ - {"name":"puppetlabs/stdlib","version_requirement":">= 3.2.0 < 5.0.0"}, - {"name":"puppet/staging","version_requirement":">= 1.0.1 < 3.0.0"} + { + "name": "puppetlabs/translate", + "version_requirement": ">= 1.0.0 < 2.0.0" + }, + { + "name": "puppetlabs/stdlib", + "version_requirement": ">= 3.2.0 < 5.0.0" + }, + { + "name": "puppet/staging", + "version_requirement": ">= 1.0.1 < 4.0.0" + } ], "data_provider": null, "operatingsystem_support": [ @@ -55,16 +65,14 @@ { "operatingsystem": "Debian", "operatingsystemrelease": [ - "6", "7", - "8" + "8", + "9" ] }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ - "10.04", - "12.04", "14.04", "16.04" ] @@ -73,8 +81,10 @@ "requirements": [ { "name": "puppet", - "version_requirement": ">= 3.0.0 < 5.0.0" + "version_requirement": ">= 4.7.0 < 6.0.0" } ], - "description": "MySQL module" + "description": "MySQL module", + "template-url": "file:///opt/puppetlabs/pdk/share/cache/pdk-templates.git", + "template-ref": "1.3.2-0-g07678c8" } diff -Nru puppet-module-puppetlabs-mysql-3.10.0/NOTICE puppet-module-puppetlabs-mysql-5.3.0/NOTICE --- puppet-module-puppetlabs-mysql-3.10.0/NOTICE 2016-07-27 17:34:11.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/NOTICE 2018-01-19 18:07:36.000000000 +0000 @@ -1,9 +1,6 @@ -mysql puppet module - -Copyright (C) 2013-2016 Puppet Labs, Inc. - -Puppet Labs can be contacted at: info@puppetlabs.com +Puppet Module - puppetlabs-mysql +Copyright 2018 Puppet, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -15,4 +12,4 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and -limitations under the License. +limitations under the License. \ No newline at end of file diff -Nru puppet-module-puppetlabs-mysql-3.10.0/Rakefile puppet-module-puppetlabs-mysql-5.3.0/Rakefile --- puppet-module-puppetlabs-mysql-3.10.0/Rakefile 2016-09-06 22:04:13.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/Rakefile 2018-02-20 14:54:26.000000000 +0000 @@ -1,38 +1,4 @@ -require 'puppet_blacksmith/rake_tasks' -require 'puppet-lint/tasks/puppet-lint' require 'puppetlabs_spec_helper/rake_tasks' - -PuppetLint.configuration.send('relative') -PuppetLint.configuration.send('disable_documentation') -PuppetLint.configuration.send('disable_single_quote_string_with_variables') - -desc 'Generate pooler nodesets' -task :gen_nodeset do - require 'beaker-hostgenerator' - require 'securerandom' - require 'fileutils' - - agent_target = ENV['TEST_TARGET'] - if ! agent_target - STDERR.puts 'TEST_TARGET environment variable is not set' - STDERR.puts 'setting to default value of "redhat-64default."' - agent_target = 'redhat-64default.' - end - - master_target = ENV['MASTER_TEST_TARGET'] - if ! master_target - STDERR.puts 'MASTER_TEST_TARGET environment variable is not set' - STDERR.puts 'setting to default value of "redhat7-64mdcl"' - master_target = 'redhat7-64mdcl' - end - - targets = "#{master_target}-#{agent_target}" - cli = BeakerHostGenerator::CLI.new([targets]) - nodeset_dir = "tmp/nodesets" - nodeset = "#{nodeset_dir}/#{targets}-#{SecureRandom.uuid}.yaml" - FileUtils.mkdir_p(nodeset_dir) - File.open(nodeset, 'w') do |fh| - fh.print(cli.execute) - end - puts nodeset -end +require 'puppet-syntax/tasks/puppet-syntax' +require 'puppet_blacksmith/rake_tasks' +require 'puppet_pot_generator/rake_tasks' diff -Nru puppet-module-puppetlabs-mysql-3.10.0/README.md puppet-module-puppetlabs-mysql-5.3.0/README.md --- puppet-module-puppetlabs-mysql-3.10.0/README.md 2016-11-07 20:14:07.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/README.md 2018-01-19 18:07:36.000000000 +0000 @@ -8,7 +8,7 @@ 3. [Usage - Configuration options and additional functionality](#usage) * [Customize server options](#customize-server-options) * [Create a database](#create-a-database) - * [Customize configuration](#create-custom-configuration) + * [Customize configuration](#customize-configuration) * [Work with an existing server](#work-with-an-existing-server) * [Specify passwords](#specify-passwords) * [Install Percona server on CentOS](#install-percona-server-on-centos) @@ -29,10 +29,9 @@ To install a server with the default options: -`include '::mysql::server'`. +`include '::mysql::server'`. -To customize options, such as the root -password or `/etc/my.cnf` settings, you must also pass in an override hash: +To customize options, such as the root password or `/etc/my.cnf` settings, you must also pass in an override hash: ```puppet class { '::mysql::server': @@ -42,7 +41,7 @@ } ``` -See [**Customize Server Options**](#customize-server-options) below for examples of the hash structure for $override_options`. +See [**Customize Server Options**](#customize-server-options) below for examples of the hash structure for $override_options. ## Usage @@ -67,9 +66,9 @@ thing = X ``` -...you can make an entry like `thing => true`, `thing => value`, or `thing => "` in the hash. Alternatively, you can pass an array, as `thing => ['value', 'value2']`, or list each `thing => value` separately on separate lines. +Entries can be created as `thing => true`, `thing => value`, or `thing => ""` in the hash. Alternatively, you can pass an array as `thing => ['value', 'value2']` or list each `thing => value` separately on individual lines. -You can pass a variable in the hash without setting a value for it; the variable would then use MySQL's default settings. To exclude an option from the my.cnf file --- for example, when using `override_options` to revert to a default value --- pass `thing => undef`. +You can pass a variable in the hash without setting a value for it; the variable would then use MySQL's default settings. To exclude an option from the `my.cnf` file --- for example, when using `override_options` to revert to a default value --- pass `thing => undef`. If an option needs multiple instances, pass an array. For example, @@ -83,7 +82,7 @@ produces -``` +```puppet [mysqld] replicate-do-db = base1 replicate-do-db = base2 @@ -147,7 +146,7 @@ To instantiate databases and users on an existing MySQL server, you need a `.my.cnf` file in `root`'s home directory. This file must specify the remote server address and credentials. For example: -``` +```puppet [client] user=root host=localhost @@ -174,7 +173,7 @@ ### Install Percona server on CentOS This example shows how to do a minimal installation of a Percona server on a -CentOS system. This sets up the Percona server, client, and bindings (including Perl and Python bindings). You can customize this usage and update the version as needed. +CentOS system. This sets up the Percona server, client, and bindings (including Perl and Python bindings). You can customize this usage and update the version as needed. This usage has been tested on Puppet 4.4 / CentOS 7 / Percona Server 5.7. @@ -249,14 +248,14 @@ **Note:** `sfo1.mirrors.digitalocean.com` is one of many mirrors available. You can use any official mirror. -``` +```puppet include apt apt::source { 'mariadb': location => 'http://sfo1.mirrors.digitalocean.com/mariadb/repo/10.1/ubuntu', release => $::lsbdistcodename, repos => 'main', - key => { + key => { id => '199369E5404BD5FC7D2FE43BCBCB082A1BB943DB', server => 'hkp://keyserver.ubuntu.com:80', }, @@ -277,7 +276,7 @@ Specify the version of the package you want with the `package_ensure` parameter. -``` +```puppet class {'::mysql::server': package_name => 'mariadb-server', package_ensure => '10.1.14+maria-1~trusty', @@ -308,20 +307,80 @@ Specify the version of the package you want with the `package_ensure` parameter. -``` +```puppet class {'::mysql::client': package_name => 'mariadb-client', package_ensure => '10.1.14+maria-1~trusty', bindings_enable => true, } -# Dependency management. Only use that part if you are installing the repository -# as shown in the Preliminary step of this example. +# Dependency management. Only use that part if you are installing the repository as shown in the Preliminary step of this example. Apt::Source['mariadb'] ~> Class['apt::update'] -> Class['::mysql::client'] ``` +### Install MySQL Community server on CentOS + +You can install MySQL Community Server on CentOS using the mysql module and Hiera. This example was tested with the following versions: + +* MySQL Community Server 5.6 +* Centos 7.3 +* Puppet 3.8.7 using Hiera +* puppetlabs-mysql module v3.9.0 + +In Puppet: + +```puppet +include ::mysql::server + +create_resources(yumrepo, hiera('yumrepo', {})) + +Yumrepo['repo.mysql.com'] -> Anchor['mysql::server::start'] +Yumrepo['repo.mysql.com'] -> Package['mysql_client'] + +create_resources(mysql::db, hiera('mysql::server::db', {})) +``` + +In Hiera: + +```yaml +--- + +# Centos 7.3 +yumrepo: + 'repo.mysql.com': + baseurl: "http://repo.mysql.com/yum/mysql-5.6-community/el/%{::operatingsystemmajrelease}/$basearch/" + descr: 'repo.mysql.com' + enabled: 1 + gpgcheck: true + gpgkey: 'http://repo.mysql.com/RPM-GPG-KEY-mysql' + +mysql::client::package_name: "mysql-community-client" # required for proper MySQL installation +mysql::server::package_name: "mysql-community-server" # required for proper MySQL installation +mysql::server::package_ensure: 'installed' # do not specify version here, unfortunately yum fails with error that package is already installed +mysql::server::root_password: "change_me_i_am_insecure" +mysql::server::manage_config_file: true +mysql::server::service_name: 'mysqld' # required for puppet module +mysql::server::override_options: + 'mysqld': + 'bind-address': '127.0.0.1' + 'log-error': /var/log/mysqld.log' # required for proper MySQL installation + 'mysqld_safe': + 'log-error': '/var/log/mysqld.log' # required for proper MySQL installation + +# create database + account with access, passwords are not encrypted +mysql::server::db: + "dev": + user: "dev" + password: "devpass" + host: "127.0.0.1" + grant: + - "ALL" + +``` + + ## Reference ### Classes @@ -362,13 +421,21 @@ ##### `create_root_user` -Whether root user should be created. Valid values are true, false. Defaults to true. +Whether root user should be created. + +Valid values are `true`, `false`. + +Defaults to `true`. This is useful for a cluster setup with Galera. The root user has to be created only once. You can set this parameter true on one node and set it to false on the remaining nodes. ##### `create_root_my_cnf` -Whether to create `/root/.my.cnf`. Valid values are true, false. Defaults to true. +Whether to create `/root/.my.cnf`. + +Valid values are `true`, `false`. + +Defaults to `true`. `create_root_my_cnf` allows creation of `/root/.my.cnf` independently of `create_root_user`. You can use this for a cluster setup with Galera where you want `/root/.my.cnf` to exist on all nodes. @@ -378,7 +445,7 @@ This is required if `create_root_user` or `create_root_my_cnf` are true. If `root_password` is 'UNSET', then `create_root_user` and `create_root_my_cnf` are assumed to be false --- that is, the MySQL root user and `/root/.my.cnf` are not created. -Password changes are supported; however, the old password must be set in `/root/.my.cnf`. Effectively, Puppet uses the old password, configured in `/root/my.cnf`, to set the new password in MySQL, and then updates `/root/.my.cnf` with the new password. +Password changes are supported; however, the old password must be set in `/root/.my.cnf`. Effectively, Puppet uses the old password, configured in `/root/my.cnf`, to set the new password in MySQL, and then updates `/root/.my.cnf` with the new password. ##### `old_root_password` @@ -404,21 +471,35 @@ ##### `manage_config_file` -Whether the MySQL configuration file should be managed. Valid values are true, false. Defaults to true. +Whether the MySQL configuration file should be managed. + +Valid values are `true`, `false`. + +Defaults to `true`. ##### `includedir` + The location, as a path, of !includedir for custom configuration overrides. ##### `install_options` + Passes [install_options](https://docs.puppetlabs.com/references/latest/type.html#package-attribute-install_options) array to managed package resources. You must pass the appropriate options for the specified package manager. ##### `purge_conf_dir` -Whether the `includedir` directory should be purged. Valid values are true, false. Defaults to false. +Whether the `includedir` directory should be purged. + +Valid values are `true`, `false`. + +Defaults to `false`. ##### `restart` -Whether the service should be restarted when things change. Valid values are true, false. Defaults to false. +Whether the service should be restarted when things change. + +Valid values are `true`, `false`. + +Defaults to `false`. ##### `root_group` @@ -430,11 +511,17 @@ ##### `package_ensure` -Whether the package exists or should be a specific version. Valid values are 'present', 'absent', or 'x.y.z'. Defaults to 'present'. +Whether the package exists or should be a specific version. + +Valid values are 'present', 'absent', or 'x.y.z'. + +Defaults to 'present'. ##### `package_manage` -Whether to manage the MySQL server package. Defaults to true. +Whether to manage the MySQL server package. + +Defaults to `true`. ##### `package_name` @@ -442,29 +529,45 @@ ##### `remove_default_accounts` -Specifies whether to automatically include `mysql::server::account_security`. Valid values are true, false. Defaults to false. +Specifies whether to automatically include `mysql::server::account_security`. + +Valid values are `true`, `false`. + +Defaults to `false`. ##### `service_enabled` -Specifies whether the service should be enabled. Valid values are true, false. Defaults to true. +Specifies whether the service should be enabled. + +Valid values are `true`, `false`. + +Defaults to `true`. ##### `service_manage` -Specifies whether the service should be managed. Valid values are true, false. Defaults to true. +Specifies whether the service should be managed. + +Valid values are `true`, `false`. + +Defaults to `true`. ##### `service_name` -The name of the MySQL server service. Defaults are OS dependent, defined in params.pp. +The name of the MySQL server service. + +Defaults are OS dependent, defined in 'params.pp'. ##### `service_provider` -The provider to use to manage the service. For Ubuntu, defaults to 'upstart'; otherwise, default is undefined. +The provider to use to manage the service. + +For Ubuntu, defaults to 'upstart'; otherwise, default is undefined. ##### `users` -Optional hash of users to create, which are passed to [mysql_user](#mysql_user). +Optional hash of users to create, which are passed to [mysql_user](#mysql_user). -``` +```puppet users => { 'someuser@localhost' => { ensure => 'present', @@ -480,9 +583,9 @@ ##### `grants` -Optional hash of grants, which are passed to [mysql_grant](#mysql_grant). +Optional hash of grants, which are passed to [mysql_grant](#mysql_grant). -``` +```puppet grants => { 'someuser@localhost/somedb.*' => { ensure => 'present', @@ -498,7 +601,7 @@ Optional hash of databases to create, which are passed to [mysql_database](#mysql_database). -``` +```puppet databases => { 'somedb' => { ensure => 'present', @@ -523,30 +626,39 @@ ##### `backupdirmode` -Permissions applied to the backup directory. This parameter is passed directly -to the `file` resource. +Permissions applied to the backup directory. This parameter is passed directly to the `file` resource. ##### `backupdirowner` -Owner for the backup directory. This parameter is passed directly to the `file` -resource. +Owner for the backup directory. This parameter is passed directly to the `file` resource. ##### `backupdirgroup` -Group owner for the backup directory. This parameter is passed directly to the -`file` resource. +Group owner for the backup directory. This parameter is passed directly to the `file` resource. ##### `backupcompress` -Whether backups should be compressed. Valid values are true, false. Defaults to true. +Whether backups should be compressed. + +Valid values are `true`, `false`. + +Defaults to `true`. ##### `backuprotate` -How many days to keep backups. Valid value is an integer. Defaults to '30'. +How many days to keep backups. + +Valid value is an integer. + +Defaults to 30. ##### `delete_before_dump` -Whether to delete old .sql files before backing up. Setting to true deletes old files before backing up, while setting to false deletes them after backup. Valid values are true, false. Defaults to false. +Whether to delete old .sql files before backing up. Setting to true deletes old files before backing up, while setting to false deletes them after backup. + +Valid values are `true`, `false`. + +Defaults to `false`. ##### `backupdatabases` @@ -554,19 +666,31 @@ ##### `file_per_database` -Whether a separate file be used per database. Valid values are true, false. Defaults to false. +Whether a separate file be used per database. + +Valid values are `true`, `false`. + +Defaults to `false`. ##### `include_routines` -Whether or not to include routines for each database when doing a `file_per_database` backup. Defaults to false. +Whether or not to include routines for each database when doing a `file_per_database` backup. + +Defaults to `false`. ##### `include_triggers` -Whether or not to include triggers for each database when doing a `file_per_database` backup. Defaults to false. +Whether or not to include triggers for each database when doing a `file_per_database` backup. + +Defaults to `false`. ##### `ensure` -Allows you to remove the backup scripts. Valid values are 'present', 'absent'. Defaults to 'present'. +Allows you to remove the backup scripts. + +Valid values are 'present', 'absent'. + +Defaults to 'present'. ##### `execpath` @@ -576,9 +700,11 @@ An array of two elements to set the backup time. Allows ['23', '5'] (i.e., 23:05) or ['3', '45'] (i.e., 03:45) for HH:MM times. +#### mysql::server::backup + ##### `postscript` -A script that is executed when the backup is finished. This could be used to (r)sync the backup to a central store. This script can be either a single line that is directly executed or a number of lines supplied as an array. It could also be one or more externally managed (executable) files. +A script that is executed when the backup is finished. This could be used to sync the backup to a central store. This script can be either a single line that is directly executed or a number of lines supplied as an array. It could also be one or more externally managed (executable) files. ##### `prescript` @@ -596,6 +722,10 @@ Defines the maximum SQL statement size for the backup dump script. The default value is 1MB, as this is the default MySQL Server value. +##### `optional_args` + +Specifies an array of optional arguments which should be passed through to the backup tool. (Currently only supported by the xtrabackup provider.) + #### mysql::server::monitor ##### `mysql_monitor_username` @@ -608,7 +738,7 @@ ##### `mysql_monitor_hostname` -The hostname from which the monitoring user requests are allowed access. +The hostname from which the monitoring user requests are allowed access. #### mysql::server::mysqltuner @@ -616,45 +746,79 @@ ##### `ensure` -Ensures that the resource exists. Valid values are `present`, `absent`. Defaults to `present`. +Ensures that the resource exists. + +Valid values are 'present', 'absent'. + +Defaults to 'present'. ##### `version` -The version to install from the major/MySQLTuner-perl github repository. Must be a valid tag. Defaults to 'v1.3.0'. +The version to install from the major/MySQLTuner-perl github repository. Must be a valid tag. + +Defaults to 'v1.3.0'. -##### `source` +##### `environment` -Specifies the source. If not specified, defaults to `https://github.com/major/MySQLTuner-perl/raw/${version}/mysqltuner.pl` +Environment variables active during download, e.g. to download via proxies: environment => 'https_proxy=http://proxy.example.com:80' #### mysql::bindings ##### `client_dev` -Specifies whether `::mysql::bindings::client_dev` should be included. Valid values are true', false. Defaults to false. +Specifies whether `::mysql::bindings::client_dev` should be included. + +Valid values are `true`', `false`. + +Defaults to `false`. ##### `daemon_dev` -Specifies whether `::mysql::bindings::daemon_dev` should be included. Valid values are true, false. Defaults to false. +Specifies whether `::mysql::bindings::daemon_dev` should be included. + +Valid values are `true`, `false`. + +Defaults to `false`. ##### `java_enable` -Specifies whether `::mysql::bindings::java` should be included. Valid values are true, false. Defaults to false. +Specifies whether `::mysql::bindings::java` should be included. + +Valid values are `true`, `false`. + +Defaults to `false`. ##### `perl_enable` -Specifies whether `mysql::bindings::perl` should be included. Valid values are true, false. Defaults to false. +Specifies whether `mysql::bindings::perl` should be included. + +Valid values are `true`, `false`. + +Defaults to `false`. ##### `php_enable` -Specifies whether `mysql::bindings::php` should be included. Valid values are true, false. Defaults to false. +Specifies whether `mysql::bindings::php` should be included. + +Valid values are `true`, `false`. + +Defaults to `false`. ##### `python_enable` -Specifies whether `mysql::bindings::python` should be included. Valid values are true, false. Defaults to false. +Specifies whether `mysql::bindings::python` should be included. + +Valid values are `true`, `false`. + +Defaults to `false`. ##### `ruby_enable` -Specifies whether `mysql::bindings::ruby` should be included. Valid values are true, false. Defaults to false. +Specifies whether `mysql::bindings::ruby` should be included. + +Valid values are `true`, `false`. + +Defaults to `false`. ##### `install_options` @@ -662,79 +826,131 @@ ##### `client_dev_package_ensure` -Whether the package should be present, absent, or a specific version. Valid values are 'present', 'absent', or 'x.y.z'. Only applies if `client_dev => true`. - +Whether the package should be present, absent, or a specific version. + +Valid values are 'present', 'absent', or 'x.y.z'. + +Only applies if `client_dev => true`. + ##### `client_dev_package_name` -The name of the client_dev package to install. Only applies if `client_dev => true`. - +The name of the client_dev package to install. + +Only applies if `client_dev => true`. + ##### `client_dev_package_provider` -The provider to use to install the client_dev package. Only applies if `client_dev => true`. +The provider to use to install the client_dev package. + +Only applies if `client_dev => true`. ##### `daemon_dev_package_ensure` -Whether the package should be present, absent, or a specific version. Valid values are 'present', 'absent', or 'x.y.z'. Only applies if `daemon_dev => true`. +Whether the package should be present, absent, or a specific version. + +Valid values are 'present', 'absent', or 'x.y.z'. + +Only applies if `daemon_dev => true`. ##### `daemon_dev_package_name` -The name of the daemon_dev package to install. Only applies if `daemon_dev => true`. +The name of the daemon_dev package to install. + +Only applies if `daemon_dev => true`. ##### `daemon_dev_package_provider` -The provider to use to install the daemon_dev package. Only applies if `daemon_dev => true`. +The provider to use to install the daemon_dev package. + +Only applies if `daemon_dev => true`. ##### `java_package_ensure` -Whether the package should be present, absent, or a specific version. Valid values are 'present', 'absent', or 'x.y.z'. Only applies if `java_enable => true`. +Whether the package should be present, absent, or a specific version. + +Valid values are 'present', 'absent', or 'x.y.z'. + +Only applies if `java_enable => true`. ##### `java_package_name` -The name of the Java package to install. Only applies if `java_enable => true`. +The name of the Java package to install. + +Only applies if `java_enable => true`. ##### `java_package_provider` -The provider to use to install the Java package. Only applies if `java_enable => true`. +The provider to use to install the Java package. + +Only applies if `java_enable => true`. ##### `perl_package_ensure` -Whether the package should be present, absent, or a specific version. Valid values are 'present', 'absent', or 'x.y.z'. Only applies if `perl_enable => true`. +Whether the package should be present, absent, or a specific version. + +Valid values are 'present', 'absent', or 'x.y.z'. + +Only applies if `perl_enable => true`. ##### `perl_package_name` -The name of the Perl package to install. Only applies if `perl_enable => true`. +The name of the Perl package to install. + +Only applies if `perl_enable => true`. ##### `perl_package_provider` -The provider to use to install the Perl package. Only applies if `perl_enable => true`. +The provider to use to install the Perl package. + +Only applies if `perl_enable => true`. ##### `php_package_ensure` -Whether the package should be present, absent, or a specific version. Valid values are 'present', 'absent', or 'x.y.z'. Only applies if `php_enable => true`. - +Whether the package should be present, absent, or a specific version. + +Valid values are 'present', 'absent', or 'x.y.z'. + +Only applies if `php_enable => true`. + ##### `php_package_name` -The name of the PHP package to install. Only applies if `php_enable => true`. +The name of the PHP package to install. + +Only applies if `php_enable => true`. ##### `python_package_ensure` -Whether the package should be present, absent, or a specific version. Valid values are 'present', 'absent', or 'x.y.z'. Only applies if `python_enable => true`. +Whether the package should be present, absent, or a specific version. + +Valid values are 'present', 'absent', or 'x.y.z'. + +Only applies if `python_enable => true`. ##### `python_package_name` -The name of the Python package to install. Only applies if `python_enable => true`. +The name of the Python package to install. + +Only applies if `python_enable => true`. ##### `python_package_provider` -The provider to use to install the PHP package. Only applies if `python_enable => true`. +The provider to use to install the Python package. + +Only applies if `python_enable => true`. ##### `ruby_package_ensure` -Whether the package should be present, absent, or a specific version. Valid values are 'present', 'absent', or 'x.y.z'. Only applies if `ruby_enable => true`. +Whether the package should be present, absent, or a specific version. + +Valid values are 'present', 'absent', or 'x.y.z'. + +Only applies if `ruby_enable => true`. ##### `ruby_package_name` -The name of the Ruby package to install. Only applies if `ruby_enable => true`. +The name of the Ruby package to install. + +Only applies if `ruby_enable => true`. ##### `ruby_package_provider` @@ -744,18 +960,27 @@ ##### `bindings_enable` -Whether to automatically install all bindings. Valid values are true, false. Default to false. +Whether to automatically install all bindings. + +Valid values are `true`, `false`. + +Default to `false`. ##### `install_options` + Array of install options for managed package resources. You must pass the appropriate options for the package manager. ##### `package_ensure` -Whether the MySQL package should be present, absent, or a specific version. Valid values are 'present', 'absent', or 'x.y.z'. +Whether the MySQL package should be present, absent, or a specific version. + +Valid values are 'present', 'absent', or 'x.y.z'. ##### `package_manage` -Whether to manage the MySQL client package. Defaults to true. +Whether to manage the MySQL client package. + +Defaults to `true`. ##### `package_name` @@ -765,7 +990,7 @@ #### mysql::db -``` +```puppet mysql_database { 'information_schema': ensure => 'present', charset => 'utf8', @@ -781,50 +1006,74 @@ ##### `user` The user for the database you're creating. - + ##### `password` The password for $user for the database you're creating. ##### `dbname` -The name of the database to create. Defaults to $name. - +The name of the database to create. + +Defaults to "$name". + ##### `charset` -The character set for the database. Defaults to 'utf8'. +The character set for the database. + +Defaults to 'utf8'. ##### `collate` -The collation for the database. Defaults to 'utf8_general_ci'. - +The collation for the database. + +Defaults to 'utf8_general_ci'. + ##### `host` -The host to use as part of user@host for grants. Defaults to 'localhost'. +The host to use as part of user@host for grants. + +Defaults to 'localhost'. ##### `grant` -The privileges to be granted for user@host on the database. Defaults to 'ALL'. +The privileges to be granted for user@host on the database. + +Defaults to 'ALL'. ##### `sql` -The path to the sqlfile you want to execute. This can be single file specified as string, or it can be an array of strings. Defaults to undef. +The path to the sqlfile you want to execute. This can be single file specified as string, or it can be an array of strings. + +Defaults to `undef`. ##### `enforce_sql` -Specifies whether executing the sqlfiles should happen on every run. If set to false, sqlfiles only run once. Valid values are true, false. Defaults to false. - +Specifies whether executing the sqlfiles should happen on every run. If set to false, sqlfiles only run once. + +Valid values are `true`, `false`. + +Defaults to `false`. + ##### `ensure` -Specifies whether to create the database. Valid values are 'present', 'absent'. Defaults to 'present'. +Specifies whether to create the database. + +Valid values are 'present', 'absent'. + +Defaults to 'present'. ##### `import_timeout` -Timeout, in seconds, for loading the sqlfiles. Defaults to '300'. +Timeout, in seconds, for loading the sqlfiles. + +Defaults to 300. ##### `import_cat_cmd` -Command to read the sqlfile for importing the database. Useful for compressed sqlfiles. For example, you can use 'zcat' for .gz files. Defaults to 'cat'. +Command to read the sqlfile for importing the database. Useful for compressed sqlfiles. For example, you can use 'zcat' for .gz files. + +Defaults to 'cat'. ### Types @@ -834,7 +1083,11 @@ ##### `ensure` -Whether the resource is present. Valid values are 'present', 'absent'. Defaults to 'present'. +Whether the resource is present. + +Valid values are 'present', 'absent'. + +Defaults to 'present'. ##### `name` @@ -842,17 +1095,21 @@ ##### `charset` -The CHARACTER SET setting for the database. Defaults to ':utf8'. +The CHARACTER SET setting for the database. + +Defaults to ':utf8'. ##### `collate` -The COLLATE setting for the database. Defaults to ':utf8_general_ci'. +The COLLATE setting for the database. + +Defaults to ':utf8_general_ci'. #### mysql_user Creates and manages user grants within MySQL. -``` +```puppet mysql_user { 'root@127.0.0.1': ensure => 'present', max_connections_per_hour => '0', @@ -864,7 +1121,7 @@ You can also specify an authentication plugin. -``` +```puppet mysql_user{ 'myuser'@'localhost': ensure => 'present', plugin => 'unix_socket', @@ -872,7 +1129,8 @@ ``` TLS options can be specified for a user. -``` + +```puppet mysql_user{ 'myuser'@'localhost': ensure => 'present', tls_options => ['SSL'], @@ -889,19 +1147,35 @@ ##### `max_user_connections` -Maximum concurrent connections for the user. Must be an integer value. A value of '0' specifies no (or global) limit. +Maximum concurrent connections for the user. + +Must be an integer value. + +A value of '0' specifies no (or global) limit. ##### `max_connections_per_hour` -Maximum connections per hour for the user. Must be an integer value. A value of '0' specifies no (or global) limit. +Maximum connections per hour for the user. + +Must be an integer value. + +A value of '0' specifies no (or global) limit. ##### `max_queries_per_hour` -Maximum queries per hour for the user. Must be an integer value. A value of '0' specifies no (or global) limit. +Maximum queries per hour for the user. + +Must be an integer value. + +A value of '0' specifies no (or global) limit. ##### `max_updates_per_hour` -Maximum updates per hour for the user. Must be an integer value. A value of '0' specifies no (or global) limit. +Maximum updates per hour for the user. + +Must be an integer value. + +A value of '0' specifies no (or global) limit. ##### `tls_options` @@ -912,7 +1186,7 @@ `mysql_grant` creates grant permissions to access databases within MySQL. To create grant permissions to access databases with MySQL, use it you must create the title of the resource as shown below, following the pattern of `username@hostname/database.table`: -``` +```puppet mysql_grant { 'root@localhost/*.*': ensure => 'present', options => ['GRANT'], @@ -924,7 +1198,7 @@ It is possible to specify privileges down to the column level: -``` +```puppet mysql_grant { 'root@localhost/mysql.user': ensure => 'present', privileges => ['SELECT (Host, User)'], @@ -937,11 +1211,15 @@ ##### `ensure` -Whether the resource is present. Valid values are 'present', 'absent'. Defaults to 'present'. +Whether the resource is present. + +Valid values are 'present', 'absent'. + +Defaults to 'present'. ##### `name` -Name to describe the grant. Must in a 'user/table' format. +Name to describe the grant. Must in a 'user/table' format. ##### `privileges` @@ -963,7 +1241,7 @@ `mysql_plugin` can be used to load plugins into the MySQL Server. -``` +```puppet mysql_plugin { 'auth_socket': ensure => 'present', soname => 'auth_socket.so', @@ -972,7 +1250,11 @@ ##### `ensure` -Whether the resource is present. Valid values are 'present', 'absent'. Defaults to 'present'. +Whether the resource is present. + +Valid values are 'present', 'absent'. + +Defaults to 'present'. ##### `name` @@ -984,12 +1266,9 @@ #### `mysql_datadir` -Initializes the MySQL data directory with version specific code. Pre MySQL 5.7.6 -it uses mysql_install_db. After MySQL 5.7.6 it uses mysqld --initialize-insecure. +Initializes the MySQL data directory with version specific code. Pre MySQL 5.7.6 it uses mysql_install_db. After MySQL 5.7.6 it uses mysqld --initialize-insecure. -Insecure initialization is needed, as mysqld version 5.7 introduced "secure by default" mode. -This means MySQL generates a random password and writes it to STDOUT. This means puppet -can never accesss the database server afterwards, as no credencials are available. +Insecure initialization is needed, as mysqld version 5.7 introduced 'secure by default' mode. This means MySQL generates a random password and writes it to STDOUT. This means puppet can never access the database server afterwards, as no credentials are available. This type is an internal type and should not be called directly. @@ -1001,9 +1280,11 @@ #### `mysql_server_id` -Generates a unique id, based on the node's MAC address, which can be used as -`server_id`. This fact will *always* return `0` on nodes that have only -loopback interfaces. Because those nodes aren't connected to the outside world, this shouldn't cause any conflicts. +Generates a unique id, based on the node's MAC address, which can be used as `server_id`. This fact will *always* return `0` on nodes that have only loopback interfaces. Because those nodes aren't connected to the outside world, this shouldn't cause any conflicts. + +### Tasks + +The MySQL module has an example task that allows a user to execute arbitary SQL against a database. Please refer to to the [PE documentation](https://puppet.com/docs/pe/2017.3/orchestrator/running_tasks.html) or [Bolt documentation](https://puppet.com/docs/bolt/latest/bolt.html) on how to execute a task. ## Limitations @@ -1020,16 +1301,13 @@ **Note:** The mysqlbackup.sh does not work and is not supported on MySQL 5.7 and greater. +Debian 9 compatibility has not been fully verified. + ## Development -Puppet Labs modules on the Puppet Forge are open projects, and community -contributions are essential for keeping them great. We can't access the -huge number of platforms and myriad of hardware, software, and deployment -configurations that Puppet is intended to serve. - -We want to keep it as easy as possible to contribute changes so that our -modules work in your environment. There are a few guidelines that we need -contributors to follow so that we can have a chance of keeping on top of things. +Puppet modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can't access the huge number of platforms and myriad of hardware, software, and deployment configurations that Puppet is intended to serve. + +We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things. Check out our the complete [module contribution guide](https://docs.puppetlabs.com/forge/contributing.html). @@ -1048,3 +1326,4 @@ * Chris Weyl * Daniël van Eeden * Jan-Otto Kröpke +* Timothy Sven Nelson diff -Nru puppet-module-puppetlabs-mysql-3.10.0/readmes/README_ja_JP.md puppet-module-puppetlabs-mysql-5.3.0/readmes/README_ja_JP.md --- puppet-module-puppetlabs-mysql-3.10.0/readmes/README_ja_JP.md 1970-01-01 00:00:00.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/readmes/README_ja_JP.md 2018-01-19 18:07:36.000000000 +0000 @@ -0,0 +1,1329 @@ +# mysql + +#### 目次 + +1. [モジュールについて - モジュールの機能とその有益性](#モジュールについて) +2. [セットアップ - mysql導入の基本](#セットアップ) + * [mysqlの導入](#mysqlの導入) +3. [使用方法 - 設定オプションとその他の機能](#使用方法) + * [サーバオプションのカスタマイズ](#サーバオプションのカスタマイズ) + * [データベースの作成](#データベースの作成) + * [設定のカスタマイズ](#設定のカスタマイズ) + * [既存のサーバに対する操作](#既存のサーバに対する操作) + * [パスワードの指定](#パスワードの指定) + * [CentOSへのPerconaサーバのインストール](#centosへのperconaサーバのインストール) + *[UbuntuへのMariaDBのインストール](#ubuntuへのmariadbのインストール) +4. [参考 - モジュールの機能と動作について](#参考) +5. [制約事項 - OSの互換性など](#制約事項) +6. [開発 - モジュール貢献についてのガイドライン](#開発) + +## モジュールについて + +mysqlモジュールは、MySQLサービスをインストール、設定、管理します。 + +このモジュールは、MySQLのインストールと設定を管理するとともに、データベース、ユーザ、GRANT権限などのMySQLリソースを管理できるようにPuppetの機能を拡張します。 + +## セットアップ + +### mysqlの導入 + +デフォルトのオプションを使用してサーバをインストールするには、次のコマンドを使用します。 + +`include '::mysql::server'`. + +ルートパスワードや`/etc/my.cnf`の設定値などのオプションをカスタマイズするには、オーバーライドハッシュも渡す必要があります。 + +```puppet +class { '::mysql::server': + root_password => 'strongpassword', + remove_default_accounts => true, + override_options => $override_options +} +``` + +$override_options用のハッシュ構造体の例については、後述の[**サーバオプションのカスタマイズ**](#サーバオプションのカスタマイズ)を参照してください。 + +## 使用方法 + +サーバに関するすべてのインタラクションは`mysql::server`を使用して行われ、クライアントのインストールには`mysql::client`が、バインディングのインストールには`mysql::bindings`が使用されます。 + +### サーバオプションのカスタマイズ + +サーバオプションを定義するには、`mysql::server`でオーバーライドのハッシュ構造体を作成します。このハッシュは、my.cnfファイルに含まれているハッシュと似ています。 + +```puppet +$override_options = { + 'section' => { + 'item' => 'thing', + } +} +``` + +この形式のオプションを従来の方法で示すと次のようになります。 + +``` +[section] +thing = X +``` + +ハッシュ内では`thing => true`、`thing => value`、または`thing => ""`の形でエントリを作成できます。または、`thing => ['value', 'value2']`の形で配列を渡したり、`thing => value`を独立した行に個別にリストすることもできます。 + +値を設定せずに変数をハッシュに含めて渡すことができます。この場合、変数にはMySQLのデフォルトの設定値が使用されます。オプションを`my.cnf`ファイルから除外するには(たとえば`override_options`を使用してデフォルト値に戻す場合など)、`thing => undef`を渡します。 + +オプションに複数のインスタンスが必要な場合は配列を渡します。たとえば次の例の場合は、 + +```puppet +$override_options = { + 'mysqld' => { + 'replicate-do-db' => ['base1', 'base2'], + } +} +``` + +次のようになります。 + +```puppet +[mysqld] +replicate-do-db = base1 +replicate-do-db = base2 +``` + +バージョンに固有なパラメータを実装するには、[mysqld-5.5]のようにバージョンを指定します。こうすると、1つのconfigで複数の異なるバージョンのMySQLに対応できます。 + +### データベースの作成 + +ユーザおよび割り当てられたいくつかの権限を含むデータベースを作成するには、次のようにします。 + +```puppet +mysql::db { 'mydb': + user => 'myuser', + password => 'mypass', + host => 'localhost', + grant => ['SELECT', 'UPDATE'], +} +``` + +エクスポートされたリソースを含む別のリソース名を使用するには、次のようにします。 + +```puppet + @@mysql::db { "mydb_${fqdn}": + user => 'myuser', + password => 'mypass', + dbname => 'mydb', + host => ${fqdn}, + grant => ['SELECT', 'UPDATE'], + tag => $domain, +} +``` + +さらに、これをリモートDBサーバに集めることができます。 + +```puppet +Mysql::Db <<| tag == $domain |>> +``` + +データベースの作成時にファイルにsqlパラメータを設定する場合は、新しいデータベースにファイルがインポートされます。 + +サイズの大きいsqlファイルの場合は、`import_timeout`パラメータの値(デフォルト値300秒)を大きくします。 + +```puppet +mysql::db { 'mydb': + user => 'myuser', + password => 'mypass', + host => 'localhost', + grant => ['SELECT', 'UPDATE'], + sql => '/path/to/sqlfile.gz', + import_cat_cmd => 'zcat', + import_timeout => 900, +} +``` + +### 設定のカスタマイズ + +MySQLカスタム設定を追加するには、`includedir`にファイルを追加します。こうすると設定値をオーバーライドしたり別の設定値を追加したりすることができ、`mysql::server`で`override_options`を使用しない場合に役立ちます。`includedir`の場所は、デフォルトでは`/etc/mysql/conf.d`に設定されます。 + +### 既存のサーバに対する操作 + +既存のMySQLサーバ上にデータベースとユーザのインスタンスを作成するには、`root`のホームディレクトリに`.my.cnf`ファイルが必要です。次の例のように、このファイルでリモートサーバのアドレスと認証情報を指定する必要があります。 + +```puppet +[client] +user=root +host=localhost +password=secret +``` + +このモジュールは、`mysqld_version`ファクトから、使用されているサーバのバージョンを認識します。デフォルトでは、`mysqld_version`は`mysqld -V`の出力に設定されています。リモートMySQLサーバに対する操作を行う場合は、`mysqld_version`に対応するカスタムファクトを設定しないと正常に動作しない可能性があります。 + +リモートサーバに対する操作を行う際には、Puppetマニフェスト内で`mysql::server`クラスを使用*しない*でください。 + +### パスワードの指定 + +パスワードは、プレーンテキストとして渡せるだけでなく、次のようにハッシュとして入力することもできます。 + +```puppet +mysql::db { 'mydb': + user => 'myuser', + password => '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4', + host => 'localhost', + grant => ['SELECT', 'UPDATE'], +} +``` + +### CentOSへのPerconaサーバのインストール + +次の例は、CentOSシステムへのPerconaサーバの最小限のインストール方法を示します。 +この例では、Perconaサーバ、クライアント、バインディング(PerlとPythonのバインディングを含む)がセットアップされます。この方法をカスタマイズして必要に応じバージョンを更新することができます。 + +この方法は、Puppet 4.4/CentOS 7/Perconaサーバ5.7でテストされています。 + +**注意:** yumレポジトリのインストールはこのパッケージには含まれていません。 +この例は、インストールの詳細を示したものに過ぎません。 + +```puppet +yumrepo { 'percona': + descr => 'CentOS $releasever - Percona', + baseurl => 'http://repo.percona.com/centos/$releasever/os/$basearch/', + gpgkey => 'http://www.percona.com/downloads/percona-release/RPM-GPG-KEY-percona', + enabled => 1, + gpgcheck => 1, +} + +class {'mysql::server': + package_name => 'Percona-Server-server-57', + package_ensure => '5.7.11-4.1.el7', + service_name => 'mysql', + config_file => '/etc/my.cnf', + includedir => '/etc/my.cnf.d', + root_password => 'PutYourOwnPwdHere', + override_options => { + mysqld => { + log-error => '/var/log/mysqld.log', + pid-file => '/var/run/mysqld/mysqld.pid', + }, + mysqld_safe => { + log-error => '/var/log/mysqld.log', + }, + } +} + +# 注意:Percona-Server-server-57をインストールするとPercona-Server-client-57もインストールされます。 +# 次の例は、Percona MySQLクライアントを単独でインストールする方法を示します。 +class {'mysql::client': + package_name => 'Percona-Server-client-57', + package_ensure => '5.7.11-4.1.el7', +} + +# 通常、以下のパッケージはPercona-Server-server-57とともにインストールされます。 +# バインディングもインストールする必要がある場合は、このコードでインストールできます。 +class { 'mysql::bindings': + client_dev_package_name => 'Percona-Server-shared-57', + client_dev_package_ensure => '5.7.11-4.1.el7', + client_dev => true, + daemon_dev_package_name => 'Percona-Server-devel-57', + daemon_dev_package_ensure => '5.7.11-4.1.el7', + daemon_dev => true, + perl_enable => true, + perl_package_name => 'perl-DBD-MySQL', + python_enable => true, + python_package_name => 'MySQL-python', +} + +# 依存関係の定義 +Yumrepo['percona']-> +Class['mysql::server'] + +Yumrepo['percona']-> +Class['mysql::client'] + +Yumrepo['percona']-> +Class['mysql::bindings'] +``` + +### UbuntuへのMariaDBのインストール + +#### オプション:MariaDBの公式のレポジトリのインストール + +次の例では、distroレポジトリでなく公式のMariaDBレポジトリの最新の安定版(現在10.1)を使用しています。代わりに、Ubuntuレポジトリのパッケージを使用することもできます。必要に応じた正しいバージョンのレポジトリを使用してください。 + +**注意:** `sfo1.mirrors.digitalocean.com`は利用可能な多くのミラーの一例であり、公式のミラーであればいずれも使用できます。 + +```puppet +include apt + +apt::source { 'mariadb': + location => 'http://sfo1.mirrors.digitalocean.com/mariadb/repo/10.1/ubuntu', + release => $::lsbdistcodename, + repos => 'main', + key => { + id => '199369E5404BD5FC7D2FE43BCBCB082A1BB943DB', + server => 'hkp://keyserver.ubuntu.com:80', + }, + include => { + src => false, + deb => true, + }, +} +``` + +#### MariaDBサーバのインストール + +次の例では、Ubuntu TrustyへのMariaDBサーバのインストール方法を示しています。`my.cnf`のバージョンとパラメータは、必要に応じて調整してください。`my.cnf`のパラメータはすべて`override_options`パラメータを使用して定義できます。 + +フォルダ`/var/log/mysql`と`/var/run/mysqld`は自動的に作成されますが、他のカスタムフォルダを使用する場合は、それらがコードの必須要件になります。 + +以下に示す値はすべて、最小限の構成にする場合の例です。 + +必要なパッケージのバージョンを、`package_ensure`パラメータで指定してください。 + +```puppet +class {'::mysql::server': + package_name => 'mariadb-server', + package_ensure => '10.1.14+maria-1~trusty', + service_name => 'mysql', + root_password => 'AVeryStrongPasswordUShouldEncrypt!', + override_options => { + mysqld => { + 'log-error' => '/var/log/mysql/mariadb.log', + 'pid-file' => '/var/run/mysqld/mysqld.pid', + }, + mysqld_safe => { + 'log-error' => '/var/log/mysql/mariadb.log', + }, + } +} + +# 依存関係の管理。レポジトリをインストールする場合は +# この例の前のステップで示されている部分だけを使用してください。 +Apt::Source['mariadb'] ~> +Class['apt::update'] -> +Class['::mysql::server'] + +``` + +#### MariaDBクライアントのインストール + +次の例は、MariaDBクライアントとすべてのバインディングを一度にインストールする方法を示します。このインストール操作は、サーバのインストール操作とは別に行うことができます。 + +必要なパッケージのバージョンを、`package_ensure`パラメータで指定してください。 + +```puppet +class {'::mysql::client': + package_name => 'mariadb-client', + package_ensure => '10.1.14+maria-1~trusty', + bindings_enable => true, +} + +# 依存関係の管理。レポジトリをインストールする場合はこの例の前のステップで示されている部分だけを使用してください。 +Apt::Source['mariadb'] ~> +Class['apt::update'] -> +Class['::mysql::client'] +``` + +### CentOSへのMySQL Communityサーバのインストール + +MySQLモジュールおよびHieraを使用して、MySQL CommunityサーバーをCentOSにインストールすることができます。この例は以下のバージョンでテスト済みです。 + +* MySQL Community Server 5.6 +* Centos 7.3 +* Hieraを使用したPuppet 3.8.7 +* puppetlabs-mysqlモジュールv3.9.0 + +Puppetで: + +```puppet +include ::mysql::server + +create_resources(yumrepo, hiera('yumrepo', {})) + +Yumrepo['repo.mysql.com'] -> Anchor['mysql::server::start'] +Yumrepo['repo.mysql.com'] -> Package['mysql_client'] + +create_resources(mysql::db, hiera('mysql::server::db', {})) +``` + +Hieraで: + +```yaml +--- + +# Centos 7.3 +yumrepo: + 'repo.mysql.com': + baseurl: "http://repo.mysql.com/yum/mysql-5.6-community/el/%{::operatingsystemmajrelease}/$basearch/" + descr: 'repo.mysql.com' + enabled: 1 + gpgcheck: true + gpgkey: 'http://repo.mysql.com/RPM-GPG-KEY-mysql' + +mysql::client::package_name: "mysql-community-client" # 適切なMySQL導入のために必要 +mysql::server::package_name: "mysql-community-server" #適切なMySQL導入のために必要 +mysql::server::package_ensure: 'installed' #ここではバージョンを指定しないでください。残念ながら、パッケージがインストールされているエラーでyumは失敗しました。 +mysql::server::root_password: "change_me_i_am_insecure" +mysql::server::manage_config_file: true +mysql::server::service_name: 'mysqld' # Puppetモジュールに必要 +mysql::server::override_options: + 'mysqld': + 'bind-address': '127.0.0.1' + 'log-error': /var/log/mysqld.log' # 適切なMySQL導入のために必要 + 'mysqld_safe': + 'log-error': '/var/log/mysqld.log' # 適切なMySQL導入のために必要 + +# データベース+アクセスできるアカウント、暗号化されていないパスワードを作成 +mysql::server::db: + "dev": + user: "dev" + password: "devpass" + host: "127.0.0.1" + grant: + - "ALL" + +``` + + +## 参考 + +### クラス + +#### パブリッククラス + +* [`mysql::server`](#mysqlserver):MySQLをインストールして設定します。 +* [`mysql::server::monitor`](#mysqlservermonitor):モニタするユーザをセットアップします。 +* [`mysql::server::mysqltuner`](#mysqlservermysqltuner):MySQL tunerスクリプトをインストールします。 +* [`mysql::server::backup`](#mysqlserverbackup):cronを使用してMySQLバックアップをセットアップします。 +* [`mysql::bindings`](#mysqlbindings):さまざまなMySQL言語バインディングをインストールします。 +* [`mysql::client`](#mysqlclient):MySQLクライアントをインストールします(サーバ以外)。 + +#### プライベートクラス + +* `mysql::server::install`:パッケージをインストールします。 +* `mysql::server::installdb`:mysqldデータディレクトリ(/var/lib/mysqlなど)のセットアップを実行します。 +* `mysql::server::config`:MySQLを設定します。 +* `mysql::server::service`:サービスを管理します。 +* `mysql::server::account_security`:デフォルトのMySQLアカウントを削除します。 +* `mysql::server::root_password`:MySQLのルートパスワードを設定します。 +* `mysql::server::providers`:ユーザ、GRANT権限、データベースを作成します。 +* `mysql::bindings::client_dev`:MySQLクライアント開発パッケージをインストールします。 +* `mysql::bindings::daemon_dev`:MySQLデーモン開発パッケージをインストールします。 +* `mysql::bindings::java`:javaバインディングをインストールします。 +* `mysql::bindings::perl`:Perlバインディングをインストールします。 +* `mysql::bindings::php`:PHPバインディングをインストールします。 +* `mysql::bindings::python`:Pythonバインディングをインストールします。 +* `mysql::bindings::ruby`:Rubyバインディングをインストールします。 +* `mysql::client::install`:MySQLクライアントをインストールします。 +* `mysql::backup::mysqldump`:mysqldumpのバックアップを実行します。 +* `mysql::backup::mysqlbackup`:Oracle MySQL Enterprise Backupを使用してバックアップを実行します。 +* `mysql::backup::xtrabackup`:PerconaのXtraBackupを使用してバックアップを実行します。 + +### パラメータ + +#### mysql::server + +##### `create_root_user` + +ルートユーザを作成するかどうかを指定します。 + +有効な値:`true`、`false`。 + +デフォルト値:`true`。 + +このパラメータは、Galeraでクラスタをセットアップする場合に役立ちます。ルートユーザの作成が必要なのは一度だけです。このパラメータを、1つのノードに対しtrueに設定し、他のすべてのノードに対してfalseに設定できます。 + +##### `create_root_my_cnf` + +`/root/.my.cnf`を作成するかどうかを指定します。 + +有効な値:`true`、`false`。 + +デフォルト値:`true`。 + +`create_root_my_cnf`を使用すると`create_root_user`に左右されずに`/root/.my.cnf`を作成できます。すべてのノードに`/root/.my.cnf`が存在するようにしたい場合に、Galeraでこの機能を使用してクラスタをセットアップできます。 + +##### `root_password` + +MySQLのルートパスワード。Puppetは、このパラメータを使用して、ルートパスワードの設定や`/root/.my.cnf`の更新を試みます。 + +`create_root_user`または`create_root_my_cnf`がtrueの場合にこのパラメータが必要です。`root_password`が'UNSET'の場合は`create_root_user`と`create_root_my_cnf`がfalseになります(MySQLルートユーザと`/root/.my.cnf`が作成されません)。 + +パスワード変更はサポートされますが、`/root/.my.cnf`に旧パスワードが設定されている必要があります。実際には、Puppetは`/root/.my.cnf`に設定されている旧パスワードを使用してMySQLで新しいパスワードを設定してから、`/root/.my.cnf`を新しいパスワードで更新します。 + +##### `old_root_password` + +現在、このパラメータでは何も行わず、下位互換性を確保するためだけに存在します。ルートパスワードの変更についての詳細は、上記の`root_password`パラメータの説明を参照してください。 + +##### `override_options` + +MySQLに渡すオーバーライドオプションを指定します。構造はmy.cnfファイルのハッシュと同様です。 + +```puppet +$override_options = { + 'section' => { + 'item' => 'thing', + } +} +``` + +使用方法の詳細は、上記の[**サーバオプションのカスタマイズ**](#サーバオプションのカスタマイズ)を参照してください。 + +##### `config_file` + +MySQL設定ファイルの場所を示すパス。 + +##### `manage_config_file` + +MySQL設定ファイルを管理するかどうかを指定します。 + +有効な値:`true`、`false`。 + +デフォルト値:`true`。 + +##### `includedir` + +カスタム設定オーバーライド用の!includedirの場所を示すパス。 + +##### `install_options` + +管理対象のパッケージリソースに[install_options](https://docs.puppetlabs.com/references/latest/type.html#package-attribute-install_options)配列を渡します。指定されているパッケージマネージャに対応する正しいオプションを渡す必要があります。 + +##### `purge_conf_dir` + +`includedir`ディレクトリをパージするかどうかを指定します。 + +有効な値:`true`、`false`。 + +デフォルト値:`false`。 + +##### `restart` + +何らかの変更があった場合にサービスを再起動するかどうかを指定します。 + +有効な値:`true`、`false`。 + +デフォルト値:`false`。 + +##### `root_group` + +ルートに使用するグループの名前。グループ名またはグループIDのいずれかです。詳細については[`group`ファイルの属性](https://docs.puppetlabs.com/references/latest/type.html#file-attribute-group)を参照してください。 + +##### `mysql_group` + +MySQLデーモンユーザのグループの名前。グループ名またはグループIDのいずれかです。詳細については[`group`ファイルの属性](https://docs.puppetlabs.com/references/latest/type.html#file-attribute-group)を参照してください。 + +##### `package_ensure` + +パッケージが存在するかどうか、またはパッケージが特定のバージョンでなければならないかどうかを指定します。 + +有効な値:'present'、'absent'、または'x.y.z'。 + +デフォルト値:'present'。 + +##### `package_manage` + +MySQLサーバパッケージを管理するかどうかを指定します。 + +デフォルト値:`true`。 + +##### `package_name` + +インストールするMySQLサーバパッケージの名前。 + +##### `remove_default_accounts` + +`mysql::server::account_security`を自動的に含めるかどうかを指定します。 + +有効な値:`true`、`false`。 + +デフォルト値:`false`。 + +##### `service_enabled` + +サービスの有効化を指定します。 + +有効な値:`true`、`false`。 + +デフォルト値:`true`。 + +##### `service_manage` + +サービスを管理するかどうかを指定します。 + +有効な値:`true`、`false`。 + +デフォルト値:`true`。 + +##### `service_name` + +MySQLサーバサービスの名前。 + +デフォルト値はOSにより異なり、'params.pp'に定義されています。 + +##### `service_provider` + +サービスの管理に使用するプロバイダ。 + +Ubuntuの場合のデフォルト値は'upstart'、Ubuntu以外の場合のデフォルト値は定義されていません。 + +##### `users` + +作成するユーザのハッシュ(オプション)。[mysql_user](#mysql_user)に渡されます。 + +```puppet +users => { + 'someuser@localhost' => { + ensure => 'present', + max_connections_per_hour => '0', + max_queries_per_hour => '0', + max_updates_per_hour => '0', + max_user_connections => '0', + password_hash => '*F3A2A51A9B0F2BE2468926B4132313728C250DBF', + tls_options => ['NONE'], + }, +} +``` + +##### `grants` + +[mysql_grant](#mysql_grant)に渡されるGRANT権限のハッシュ(オプション)。 + +```puppet +grants => { + 'someuser@localhost/somedb.*' => { + ensure => 'present', + options => ['GRANT'], + privileges => ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], + table => 'somedb.*', + user => 'someuser@localhost', + }, +} +``` + +##### `databases` + +作成されるデータベースのハッシュ(オプション)。[mysql_database](#mysql_database)に渡されます。 + +```puppet +databases => { + 'somedb' => { + ensure => 'present', + charset => 'utf8', + }, +} +``` + +#### mysql::server::backup + +##### `backupuser` + +バックアップ用に作成するMySQLユーザ。 + +##### `backuppassword` + +バックアップ用のMySQLユーザパスワード。 + +##### `backupdir` + +バックアップを保存するディレクトリ。 + +##### `backupdirmode` + +バックアップディレクトリに適用されるパーミッション。このパラメータは`file`リソースに直接渡されます。 + +##### `backupdirowner` + +バックアップディレクトリの所有者。このパラメータは`file`リソースに直接渡されます。 + +##### `backupdirgroup` + +バックアップディレクトリのグループ所有者。このパラメータは`file`リソースに直接渡されます。 + +##### `backupcompress` + +バックアップを圧縮するかどうかを指定します。 + +有効な値:`true`、`false`。 + +デフォルト値:`true`。 + +##### `backuprotate` + +バックアップを保持する日数。 + +有効な値:整数値。 + +デフォルト値:30。 + +##### `delete_before_dump` + +バックアップ前に古い.sqlファイルを削除するかどうかを設定します。trueに設定すると古いファイルがバックアップ前に削除され、falseに設定するとバックアップ後に削除されます。 + +有効な値:`true`、`false`。 + +デフォルト値:`false`。 + +##### `backupdatabases` + +バックアップするデータベースの配列を指定します。 + +##### `file_per_database` + +データベースごとに個別のファイルを使用するかどうかを設定します。 + +有効な値:`true`、`false`。 + +デフォルト値:`false`。 + +##### `include_routines` + +`file_per_database`バックアップを実行する際にデータベースごとにルーチンを含めるかどうかを設定します。 + +デフォルト値:`false`。 + +##### `include_triggers` + +`file_per_database`バックアップを実行する際にデータベースごとにトリガを含めるかどうかを設定します。 + +デフォルト値:`false`。 + +##### `ensure` + +バックアップスクリプトを削除できます。 + +有効な値:'present'、'absent'。 + +デフォルト値:'present'。 + +##### `execpath` + +MySQLを標準的でない場所にインストールする場合にカスタムパスを設定できます。デフォルト値:`/usr/bin:/usr/sbin:/bin:/sbin`。 + +##### `time` + +バックアップ時刻を設定する2つの要素の配列。時刻をHH:MM形式で['23', '5'](23:05)または['3', '45'](03:45)に設定できます。 + +#### mysql::server::backup + +##### `postscript` + +バックアップ終了時に実行されるスクリプト。この機能を使用すると、バックアップを中央ストアに同期させることができます。このスクリプトは、直接実行される1つの行であっても、配列を形成する複数の行であっても構いません。あるいは、外部で管理される1つ以上の(実行可能な)ファイルにすることもできます。 + +##### `prescript` + +バックアップ開始前に実行されるスクリプト。 + +##### `provider` + +サーバのバックアップの実行について設定します。有効な値は以下のとおりです。 + +* `mysqldump`:mysqldumpを使用してバックアップを実行。バックアップのタイプ:Logical(デフォルト値)。 +* `mysqlbackup`:OracleのMySQL Enterprise Backupを使用してバックアップを実行します。バックアップのタイプ:Physical。このタイプのバックアップを使用するにはOracleの`meb`パッケージが必要です。RPM形式のものとTAR形式のものがあります。Ubuntuの場合は、[meb-deb](https://github.com/dveeden/meb-deb)を使用して公式のtarballからパッケージを作成できます。 +* `xtrabackup:PerconaのXtraBackupを使用してバックアップを実行します。バックアップのタイプ:Physical。 + +##### `maxallowedpacket` + +バックアップダンプスクリプト用のSQLステートメントの最大サイズを定義ます。デフォルト値は1MBで、MySQL Serverのデフォルト値と同じです。 + +##### `optional_args` + +バックアップツールに渡すべきオプションの引数の配列を指定します(現在はxtrabackupプロバイダでのみサポート)。 + +#### mysql::server::monitor + +##### `mysql_monitor_username` + +MySQLのモニタ用に作成するユーザ名。 + +##### `mysql_monitor_password` + +MySQLのモニタ用に作成するパスワード。 + +##### `mysql_monitor_hostname` + +モニタするユーザリクエストへのアクセスが許可されたホスト名。 + +#### mysql::server::mysqltuner + +**注意**:ネットワークに接続されていないシステムでこのクラスを使用する場合は、mysqltuner.plスクリプトをダウンロードし、`http(s)://`、`puppet://`、`ftp://`、または完全修飾ファイルパスを使用して、アクセス可能な場所でホストされるようにしておく必要があります。 + +##### `ensure` + +リソースが存在することを確認します。 + +有効な値:'present'、'absent'。 + +デフォルト値:'present'。 + +##### `version` + +major/MySQLTuner-perl githubレポジトリからインストールするバージョン。有効なタグでなければなりません。 + +デフォルト値:'v1.3.0'。 + +##### `environment` + +プロキシを使用したダウンロードなどのダウンロード中に有効な環境変数:environment => 'https_proxy=http://proxy.example.com:80' + +#### mysql::bindings + +##### `client_dev` + +`::mysql::bindings::client_dev`を含めるかどうかを指定します。 + +有効な値:`true`、`false`。 + +デフォルト値:`false`。 + +##### `daemon_dev` + +`::mysql::bindings::daemon_dev`を含めるかどうかを指定します。 + +有効な値:`true`、`false`。 + +デフォルト値:`false`。 + +##### `java_enable` + +`::mysql::bindings::java`を含めるかどうかを指定します。 + +有効な値:`true`、`false`。 + +デフォルト値:`false`。 + +##### `perl_enable` + +`mysql::bindings::perl`を含めるかどうかを指定します。 + +有効な値:`true`、`false`。 + +デフォルト値:`false`。 + +##### `php_enable` + +`mysql::bindings::php`を含めるかどうかを指定します。 + +有効な値:`true`、`false`。 + +デフォルト値:`false`。 + +##### `python_enable` + +`mysql::bindings::python`を含めるかどうかを指定します。 + +有効な値:`true`、`false`。 + +デフォルト値:`false`。 + +##### `ruby_enable` + +`mysql::bindings::ruby`を含めるかどうかを指定します。 + +有効な値:`true`、`false`。 + +デフォルト値:`false`。 + +##### `install_options` + +管理対象のパッケージリソースに`install_options`を渡します。パッケージマネージャに対応する[正しいオプション](https://docs.puppetlabs.com/references/latest/type.html#package-attribute-install_options)を渡す必要があります。 + +##### `client_dev_package_ensure` + +パッケージが、存在するかしないか、または特定のバージョンでなければならないかどうかを指定します。 + +有効な値:'present'、'absent'、または'x.y.z'。 + +適用されるのは`client_dev => true`の場合だけです。 + +##### `client_dev_package_name` + +インストールするclient_devパッケージの名前。 + +適用されるのは`client_dev => true`の場合だけです。 + +##### `client_dev_package_provider` + +client_devパッケージのインストールに使用するプロバイダ。 + +適用されるのは`client_dev => true`の場合だけです。 + +##### `daemon_dev_package_ensure` + +パッケージが、存在するかしないか、または特定のバージョンでなければならないかどうかを指定します。 + +有効な値:'present'、'absent'、または'x.y.z'。 + +適用されるのはdaemon_dev => true`の場合だけです。 + +##### `daemon_dev_package_name` + +インストールするdaemon_devパッケージの名前。 + +適用されるのはdaemon_dev => true`の場合だけです。 + +##### `daemon_dev_package_provider` + +daemon_devパッケージのインストールに使用するプロバイダ。 + +適用されるのはdaemon_dev => true`の場合だけです。 + +##### `java_package_ensure` + +パッケージが、存在するかしないか、または特定のバージョンでなければならないかどうかを指定します。 + +有効な値:'present'、'absent'、または'x.y.z'。 + +適用されるのは`java_enable => true`の場合だけです。 + +##### `java_package_name` + +インストールするJavaパッケージの名前。 + +適用されるのは`java_enable => true`の場合だけです。 + +##### `java_package_provider` + +Javaパッケージのインストールに使用するプロバイダ。 + +適用されるのは`java_enable => true`の場合だけです。 + +##### `perl_package_ensure` + +パッケージが、存在するかしないか、または特定のバージョンでなければならないかどうかを指定します。 + +有効な値:'present'、'absent'、または'x.y.z'。 + +適用されるのは`perl_enable => true`の場合だけです。 + +##### `perl_package_name` + +インストールするPerlパッケージの名前。 + +適用されるのは`perl_enable => true`の場合だけです。 + +##### `perl_package_provider` + +Perlパッケージのインストールに使用するプロバイダ。 + +適用されるのは`perl_enable => true`の場合だけです。 + +##### `php_package_ensure` + +パッケージが、存在するかしないか、または特定のバージョンでなければならないかどうかを指定します。 + +有効な値:'present'、'absent'、または'x.y.z'。 + +適用されるのは`php_enable => true`の場合だけです。 + +##### `php_package_name` + +インストールするPHPパッケージの名前。 + +適用されるのは`php_enable => true`の場合だけです。 + +##### `python_package_ensure` + +パッケージが、存在するかしないか、または特定のバージョンでなければならないかどうかを指定します。 + +有効な値:'present'、'absent'、または'x.y.z'。 + +適用されるのは`python_enable => true`の場合だけです。 + +##### `python_package_name` + +インストールするPythonパッケージの名前。 + +適用されるのは`python_enable => true`の場合だけです。 + +##### `python_package_provider` + +Pythonパッケージのインストールに使用するプロバイダ。 + +適用されるのは`python_enable => true`の場合だけです。 + +##### `ruby_package_ensure` + +パッケージが、存在するかしないか、または特定のバージョンでなければならないかどうかを指定します。 + +有効な値:'present'、'absent'、または'x.y.z'。 + +適用されるのは`ruby_enable => true`の場合だけです。 + +##### `ruby_package_name` + +インストールするRubyパッケージの名前。 + +適用されるのは`ruby_enable => true`の場合だけです。 + +##### `ruby_package_provider` + +Rubyパッケージのインストールに使用するプロバイダ。 + +#### mysql::client + +##### `bindings_enable` + +すべてのバインディングを自動的にインストールするかどうかを指定します。 + +有効な値:`true`、`false`。 + +デフォルト値:`false`。 + +##### `install_options` + +管理対象のパッケージリソースに関するインストールオプションの配列。パッケージマネージャに対応する正しいオプションを渡す必要があります。 + +##### `package_ensure` + +MySQLパッケージが、存在するかしないか、または特定のバージョンでなければならないかどうかを指定します。 + +有効な値:'present'、'absent'、または'x.y.z'。 + +##### `package_manage` + +MySQLクライアントパッケージを管理するかどうかを指定します。 + +デフォルト値:`true`。 + +##### `package_name` + +インストールするMySQLクライアントパッケージの名前。 + +### 定義 + +#### mysql::db + +```puppet +mysql_database { 'information_schema': + ensure => 'present', + charset => 'utf8', + collate => 'utf8_swedish_ci', +} +mysql_database { 'mysql': + ensure => 'present', + charset => 'latin1', + collate => 'latin1_swedish_ci', +} +``` + +##### `user` + +作成するデータベースのユーザ。 + +##### `password` + +作成するデータベースの$userのパスワード。 + +##### `dbname` + +作成するデータベースの名前。 + +デフォルト値:"$name"。 + +##### `charset` + +データベースに使用するキャラクタセット。 + +デフォルト値:'utf8'。 + +##### `collate` + +データベースの照合順序。 + +デフォルト値:'utf8_general_ci'。 + +##### `host` + +GRANT権限を付与するuser@hostの一部として使用するホスト。 + +デフォルト値:'localhost'。 + +##### `grant` + +データベースに対してuser@hostに付与される権限。 + +デフォルト値:'ALL'。 + +##### `sql` + +実行するsqlfileへのパス。文字列として指定された1つのファイル、または文字列の配列のいずれかです。 + +デフォルト値:`undef`。 + +##### `enforce_sql` + +sqlfilesを毎回実行するかどうかを指定します。falseに設定した場合はsqlfilesは1回しか実行されません。 + +有効な値:`true`、`false`。 + +デフォルト値:`false`。 + +##### `ensure` + +データベースを作成するかどうかを指定します。 + +有効な値:'present'、'absent'。 + +デフォルト値:'present'。 + +##### `import_timeout` + +sqlfilesをロードするときのタイムアウト(秒)。 + +デフォルト値:300。 + +##### `import_cat_cmd` + +データベースをインポートするためにsqlfileを読み込むコマンド。sqlfilesが圧縮されている場合に役立ちます。たとえば.gzファイルの場合に'zcat'を使用することができます。 + +デフォルト値:'cat'。 + +### タイプ + +#### mysql_database + +`mysql_database`は、MySQLでデータベースを作成し、管理します。 + +##### `ensure` + +リソースの存在を指定します。 + +有効な値:'present'、'absent'。 + +デフォルト値:'present'。 + +##### `name` + +管理するMySQLデータベースの名前。 + +##### `charset` + +データベースに使用するキャラクタセットの設定。 + +デフォルト値:'utf8'。 + +##### `collate` + +データベースに使用する照合順序の設定。 + +デフォルト値:'utf8_general_ci'。 + +#### mysql_user + +MySQLでのユーザのGRANT権限を作成し、管理します。 + +```puppet +mysql_user { 'root@127.0.0.1': + ensure => 'present', + max_connections_per_hour => '0', + max_queries_per_hour => '0', + max_updates_per_hour => '0', + max_user_connections => '0', +} +``` + +認証プラグインを指定することもできます。 + +```puppet +mysql_user{ 'myuser'@'localhost': + ensure => 'present', + plugin => 'unix_socket', +} +``` + +ユーザに対しTLSオプションを指定できます。 + +```puppet +mysql_user{ 'myuser'@'localhost': + ensure => 'present', + tls_options => ['SSL'], +} +``` + +##### `name` + +ユーザ名('username@hostname'またはusername@hostname)。 + +##### `password_hash` + +ユーザのパスワードハッシュ。このようなハッシュを作成するには、mysql_password()を使用してください。 + +##### `max_user_connections` + +同時に接続するユーザ数の最大値。 + +整数値でなければなりません。 + +指定値が'0'の場合は無制限(またはグローバル)になります。 + +##### `max_connections_per_hour` + +ユーザの1時間あたりの接続回数最大値。 + +整数値でなければなりません。 + +指定値が'0'の場合は無制限(またはグローバル)になります。 + +##### `max_queries_per_hour` + +ユーザの1時間あたりのクエリ数最大値。 + +整数値でなければなりません。 + +指定値が'0'の場合は無制限(またはグローバル)になります。 + +##### `max_updates_per_hour` + +ユーザの1時間あたりの更新回数最大値。 + +整数値でなければなりません。 + +指定値が'0'の場合は無制限(またはグローバル)になります。 + +##### `tls_options` + +1つ以上のtls_optionの値を使用するMySQLアカウント用のSSL関連のオプション。'NONE'の場合はアカウントにTLSオプションが指定されません。使用可能なオプションは、MySQLドキュメントに示されているとおり、'SSL'、'X509'、'CIPHER *cipher*'、'ISSUER *issuer*'、'SUBJECT *subject*'です。 + + +#### mysql_grant + +`mysql_grant`は、MySQLでデータベースにアクセスするのに必要なGRANT権限を作成します。MySQLでデータベースにアクセスするためのGRANT権限を作成するには、`username@hostname/database.table`のパターンに続けて次のようにリソースのタイトルを作成する必要があります。 + +```puppet +mysql_grant { 'root@localhost/*.*': + ensure => 'present', + options => ['GRANT'], + privileges => ['ALL'], + table => '*.*', + user => 'root@localhost', +} +``` + +次のように、列レベルまで詳細に権限を指定することができます。 + +```puppet +mysql_grant { 'root@localhost/mysql.user': + ensure => 'present', + privileges => ['SELECT (Host, User)'], + table => 'mysql.user', + user => 'root@localhost', +} +``` + +GRANT権限を取り消す場合は['NONE']を指定します。 + +##### `ensure` + +リソースの存在を指定します。 + +有効な値:'present'、'absent'。 + +デフォルト値:'present'。 + +##### `name` + +GRANT権限を示す名前。'user/table'の形式でなければなりません。 + +##### `privileges` + +ユーザに許可を与える権限。 + +##### `table` + +権限が適用されるテーブル。 + +##### `user` + +権限が付与されるユーザ。 + +##### `options` + +権限を付与するMySQLオプション(オプション)。 + +#### mysql_plugin + +`mysql_plugin`を使用してMySQLサーバにプラグインをロードできます。 + +```puppet +mysql_plugin { 'auth_socket': + ensure => 'present', + soname => 'auth_socket.so', +} +``` + +##### `ensure` + +リソースの存在を指定します。 + +有効な値:'present'、'absent'。 + +デフォルト値:'present'。 + +##### `name` + +管理するMySQLプラグインの名前。 + +##### `soname` + +ライブラリファイルの名前。 + +#### `mysql_datadir` + +バージョンに固有なコードでMySQLデータディレクトリを初期化します。MySQL 5.7.6より前のバージョンではmysql_install_dbを、後のバージョンではmysqld --initialize-insecureを使用します。 + +安全でない初期化が必要なのは、mysqldバージョン5.7で'secure by default'モードが導入されているからです。これは、MySQLがランダムなパスワードを作成してSTDOUTに書き込むことを意味します。したがって、使用可能な認証情報がないためPuppetが後でデータベースサーバにアクセスすることはできません。 + +このタイプは内部タイプであるため、直接呼び出すことはできません。 + +### ファクト + +#### `mysql_version` + +`mysql --version`からの出力を解析してMySQLのバージョンを判断します。 + +#### `mysql_server_id` + +ノードのMACアドレスに基づいて、`server_id`として使用可能な一意なIDを作成します。ループバックインターフェイスしかないノードでは、このファクトは*常に*`0`を返します。これらのノードは外部に接続されていないため、これが衝突の原因になる可能性はありません。 + +### タスク + +MySQLモジュールにはサンプルタスクがあり、ユーザはデータベースに対して任意のSQLを実行できます。[Puppet Enterpriseマニュアル](https://puppet.com/docs/pe/2017.3/orchestrator/running_tasks.html)または[Boltマニュアル](https://puppet.com/docs/bolt/latest/bolt.html)で、タスクを実行する方法に関する情報を参照してください。 + +## 制約事項 + +このモジュールは以下のプラットフォームでテストされています。 + +* RedHat Enterprise Linux 5、6、7 +* Debian 6、7、8 +* CentOS 5、 6、7 +* Ubuntu 10.04、12.04、14.04、16.04 +* Scientific Linux 5、6 +* SLES 11 + +他のプラットフォームでは最小限のテストしか行っていないため、保証はできません。 + +**注意:** mysqlbackup.shは、MySQL 5.7以降では動作せず、サポートされていません。 + +Debian 9の互換性は完全には検証されていません。 + +## 開発 + +Puppet Forge上のPuppetモジュールはオープンプロジェクトであり、その価値を維持するにはコミュニティからの貢献が欠かせません。Puppetが提供する膨大な数のプラットフォームや、無数のハードウェア、ソフトウェア、デプロイ設定に弊社がアクセスすることは不可能です。 + +弊社は、できるだけ変更に貢献しやすくして、弊社のモジュールがユーザの環境で機能する状態を維持したいと考えています。弊社では、状況を把握できるよう、貢献者に従っていただくべきいくつかのガイドラインを設けています。 + +弊社の詳細な[モジュール貢献についてのガイドライン](https://docs.puppetlabs.com/forge/contributing.html)をご確認ください。 + +### 作成者 + +このモジュールは、David Schmittが作成したものをベースにして、以下の作成者による貢献内容が加えられています(Puppet Labsを除く)。 + +* Larry Ludwig +* Christian G. Warden +* Daniel Black +* Justin Ellison +* Lowe Schmidt +* Matthias Pigulla +* William Van Hevelingen +* Michael Arnold +* Chris Weyl +* Daniël van Eeden +* Jan-Otto Kröpke +* Timothy Sven Nelson \ No newline at end of file diff -Nru puppet-module-puppetlabs-mysql-3.10.0/spec/acceptance/locales_spec.rb puppet-module-puppetlabs-mysql-5.3.0/spec/acceptance/locales_spec.rb --- puppet-module-puppetlabs-mysql-3.10.0/spec/acceptance/locales_spec.rb 1970-01-01 00:00:00.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/spec/acceptance/locales_spec.rb 2018-01-19 18:07:36.000000000 +0000 @@ -0,0 +1,103 @@ +require 'spec_helper_acceptance' +require 'beaker/i18n_helper' + +describe 'mysql localization', if: (fact('osfamily') == 'Debian' || fact('osfamily') == 'RedHat') && puppet_version =~ %r{(^4\.10\.[56789]|5\.\d\.\d)} do + before :all do + hosts.each do |host| + on(host, "sed -i \"96i FastGettext.locale='ja'\" /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet.rb") + change_locale_on(host, 'ja_JP.utf-8') + end + end + + context 'when triggering puppet simple string error' do + let(:pp) do + <<-MANIFEST + class { 'mysql::server': + config_file => '/tmp/mysql.sFlJdV/my.cnf', + includedir => '/tmp/mysql.sFlJdV/include', + manage_config_file => 'true', + override_options => { 'mysqld' => { 'key_buffer_size' => '32M' }}, + package_ensure => 'present', + purge_conf_dir => 'true', + remove_default_accounts => 'true', + restart => 'true', + root_group => 'root', + root_password => 'test', + old_root_password => 'kittensnmittens', + service_enabled => 'false' + } + MANIFEST + end + + it 'displays Japanese error' do + apply_manifest(pp, catch_error: true) do |r| + expect(r.stderr).to match(%r{`old_root_password`属性は廃止予定であり、今後のリリースで廃止されます。}i) + end + end + end + + context 'when triggering puppet interpolated string failure' do + let(:pp) do + <<-MANIFEST + class { 'mysql::server': root_password => 'password' } + class { 'mysql::server::backup': + backupuser => 'myuser', + backuppassword => 'mypassword', + backupdir => '/tmp/backups', + backupcompress => true, + prescript => true, + provider => 'mysqldump', + execpath => '/usr/bin:/usr/sbin:/bin:/sbin:/opt/zimbra/bin', + } + MANIFEST + end + + it 'displays Japanese failure' do + apply_manifest(pp, catch_failures: true) do |r| + expect(r.stderr).to match(%r{'prescript'オプションは、現在、mysqldumpバックアッププロバイダ向けには実装されていません。}i) + end + end + end + + context 'when triggering ruby simple string failure' do + let(:pp) do + <<-MANIFEST + mysql::db { 'mydb': + user => 'thisisalongusernametestfortodayandtomorrowandthenextday', + password => 'mypass', + host => 'localhost', + grant => ['SELECT', 'UPDATE'], + } + MANIFEST + end + + it 'displays Japanese failure' do + apply_manifest(pp, expect_failures: true) do |r| + expect(r.stderr).to match(%r{MySQLユーザ名は最大\d{2}文字に制限されています。}i) + end + end + end + + context 'when triggering ruby interpolated string error' do + let(:pp) do + <<-MANIFEST + mysql_user{ '"name@localhost': + ensure => 'present', + } + MANIFEST + end + + it 'displays Japanese error' do + apply_manifest(pp, expect_failures: true) do |r| + expect(r.stderr).to match(%r{無効なデータベースのユーザ"name@localhost}i) + end + end + end + + after :all do + hosts.each do |host| + on(host, 'sed -i "96d" /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet.rb') + change_locale_on(host, 'en_US') + end + end +end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/spec/acceptance/mysql_backup_spec.rb puppet-module-puppetlabs-mysql-5.3.0/spec/acceptance/mysql_backup_spec.rb --- puppet-module-puppetlabs-mysql-3.10.0/spec/acceptance/mysql_backup_spec.rb 2016-09-06 22:04:13.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/spec/acceptance/mysql_backup_spec.rb 2018-02-20 14:54:26.000000000 +0000 @@ -1,12 +1,10 @@ require 'spec_helper_acceptance' -require 'puppet' require 'puppet/util/package' require_relative './mysql_helper.rb' describe 'mysql::server::backup class' do context 'should work with no errors' do - it 'when configuring mysql backups' do - pp = <<-EOS + pp = <<-MANIFEST class { 'mysql::server': root_password => 'password' } mysql::db { [ 'backup1', @@ -29,28 +27,30 @@ ], execpath => '/usr/bin:/usr/sbin:/bin:/sbin:/opt/zimbra/bin', } - EOS - - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_failures => true) + MANIFEST + it 'when configuring mysql backups' do + apply_manifest(pp, catch_failures: true) + apply_manifest(pp, catch_failures: true) end end describe 'mysqlbackup.sh' do - it 'should run mysqlbackup.sh with no errors' do + before(:all) do pre_run - if ! version_is_greater_than('5.7.0') - shell("/usr/local/sbin/mysqlbackup.sh") do |r| - expect(r.stderr).to eq("") + end + + it 'runs mysqlbackup.sh with no errors' do + unless version_is_greater_than('5.7.0') + shell('/usr/local/sbin/mysqlbackup.sh') do |r| + expect(r.stderr).to eq('') end end end - it 'should dump all databases to single file' do - pre_run - if ! version_is_greater_than('5.7.0') + it 'dumps all databases to single file' do + unless version_is_greater_than('5.7.0') shell('ls -l /tmp/backups/mysql_backup_*-*.sql.bz2 | wc -l') do |r| - expect(r.stdout).to match(/1/) + expect(r.stdout).to match(%r{1}) expect(r.exit_code).to be_zero end end @@ -58,29 +58,27 @@ context 'should create one file per database per run' do it 'executes mysqlbackup.sh a second time' do - pre_run - if ! version_is_greater_than('5.7.0') + unless version_is_greater_than('5.7.0') shell('sleep 1') shell('/usr/local/sbin/mysqlbackup.sh') end end it 'creates at least one backup tarball' do - pre_run - if ! version_is_greater_than('5.7.0') + unless version_is_greater_than('5.7.0') shell('ls -l /tmp/backups/mysql_backup_*-*.sql.bz2 | wc -l') do |r| - expect(r.stdout).to match(/2/) + expect(r.stdout).to match(%r{2}) expect(r.exit_code).to be_zero end end end end + # rubocop:enable RSpec/MultipleExpectations, RSpec/ExampleLength end context 'with one file per database' do context 'should work with no errors' do - it 'when configuring mysql backups' do - pp = <<-EOS + pp = <<-MANIFEST class { 'mysql::server': root_password => 'password' } mysql::db { [ 'backup1', @@ -104,63 +102,61 @@ ], execpath => '/usr/bin:/usr/sbin:/bin:/sbin:/opt/zimbra/bin', } - EOS - - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_failures => true) + MANIFEST + it 'when configuring mysql backups' do + apply_manifest(pp, catch_failures: true) + apply_manifest(pp, catch_failures: true) end end describe 'mysqlbackup.sh' do - it 'should run mysqlbackup.sh with no errors without root credentials' do + before(:all) do pre_run - if ! version_is_greater_than('5.7.0') - shell("HOME=/tmp/dontreadrootcredentials /usr/local/sbin/mysqlbackup.sh") do |r| - expect(r.stderr).to eq("") + end + + it 'runs mysqlbackup.sh with no errors without root credentials' do + unless version_is_greater_than('5.7.0') + shell('HOME=/tmp/dontreadrootcredentials /usr/local/sbin/mysqlbackup.sh') do |r| + expect(r.stderr).to eq('') end end end - it 'should create one file per database' do - pre_run - if ! version_is_greater_than('5.7.0') - ['backup1', 'backup2'].each do |database| + it 'creates one file per database' do + unless version_is_greater_than('5.7.0') + %w[backup1 backup2].each do |database| shell("ls -l /tmp/backups/mysql_backup_#{database}_*-*.sql.bz2 | wc -l") do |r| - expect(r.stdout).to match(/1/) + expect(r.stdout).to match(%r{1}) expect(r.exit_code).to be_zero end end end end - context 'should create one file per database per run' do - it 'executes mysqlbackup.sh a second time' do - pre_run - if ! version_is_greater_than('5.7.0') - shell('sleep 1') - shell('HOME=/tmp/dontreadrootcredentials /usr/local/sbin/mysqlbackup.sh') - end + it 'executes mysqlbackup.sh a second time' do + unless version_is_greater_than('5.7.0') + shell('sleep 1') + shell('HOME=/tmp/dontreadrootcredentials /usr/local/sbin/mysqlbackup.sh') end + end - it 'has one file per database per run' do - pre_run - if ! version_is_greater_than('5.7.0') - ['backup1', 'backup2'].each do |database| - shell("ls -l /tmp/backups/mysql_backup_#{database}_*-*.sql.bz2 | wc -l") do |r| - expect(r.stdout).to match(/2/) - expect(r.exit_code).to be_zero - end + it 'has one file per database per run' do + unless version_is_greater_than('5.7.0') + %w[backup1 backup2].each do |database| + shell("ls -l /tmp/backups/mysql_backup_#{database}_*-*.sql.bz2 | wc -l") do |r| + expect(r.stdout).to match(%r{2}) + expect(r.exit_code).to be_zero end end end end + # rubocop:enable RSpec/MultipleExpectations, RSpec/ExampleLength end end context 'with triggers and routines' do - it 'when configuring mysql backups with triggers and routines' do - pre_run - pp = <<-EOS + pre_run + pp = <<-MANIFEST class { 'mysql::server': root_password => 'password' } mysql::db { [ 'backup1', @@ -189,15 +185,16 @@ execpath => '/usr/bin:/usr/sbin:/bin:/sbin:/opt/zimbra/bin', require => Package['bzip2'], } - EOS - apply_manifest(pp, :catch_failures => true) + MANIFEST + it 'when configuring mysql backups with triggers and routines' do + apply_manifest(pp, catch_failures: true) end - it 'should run mysqlbackup.sh with no errors' do + it 'runs mysqlbackup.sh with no errors' do pre_run - if ! version_is_greater_than('5.7.0') - shell("/usr/local/sbin/mysqlbackup.sh") do |r| - expect(r.stderr).to eq("") + unless version_is_greater_than('5.7.0') + shell('/usr/local/sbin/mysqlbackup.sh') do |r| + expect(r.stderr).to eq('') end end end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/spec/acceptance/mysql_db_spec.rb puppet-module-puppetlabs-mysql-5.3.0/spec/acceptance/mysql_db_spec.rb --- puppet-module-puppetlabs-mysql-3.10.0/spec/acceptance/mysql_db_spec.rb 2016-07-27 17:34:11.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/spec/acceptance/mysql_db_spec.rb 2018-01-19 18:07:36.000000000 +0000 @@ -3,25 +3,26 @@ describe 'mysql::db define' do describe 'creating a database' do let(:pp) do - <<-EOS + <<-MANIFEST class { 'mysql::server': root_password => 'password' } mysql::db { 'spec1': user => 'root1', password => 'password', } - EOS + MANIFEST end - it_behaves_like "a idempotent resource" + + it_behaves_like 'a idempotent resource' describe command("mysql -e 'show databases;'") do its(:exit_status) { is_expected.to eq 0 } - its(:stdout) { is_expected.to match /^spec1$/ } + its(:stdout) { is_expected.to match %r{^spec1$} } end end describe 'creating a database with post-sql' do let(:pp) do - <<-EOS + <<-MANIFEST class { 'mysql::server': override_options => { 'root_password' => 'password' } } file { '/tmp/spec.sql': ensure => file, @@ -33,33 +34,35 @@ password => 'password', sql => '/tmp/spec.sql', } - EOS + MANIFEST end - it_behaves_like "a idempotent resource" + + it_behaves_like 'a idempotent resource' describe command("mysql -e 'show tables;' spec2") do its(:exit_status) { is_expected.to eq 0 } - its(:stdout) { is_expected.to match /^table1$/ } + its(:stdout) { is_expected.to match %r{^table1$} } end end describe 'creating a database with dbname parameter' do - let(:check_command) { " | grep realdb" } + let(:check_command) { ' | grep realdb' } let(:pp) do - <<-EOS + <<-MANIFEST class { 'mysql::server': override_options => { 'root_password' => 'password' } } mysql::db { 'spec1': user => 'root1', password => 'password', dbname => 'realdb', } - EOS + MANIFEST end - it_behaves_like "a idempotent resource" + + it_behaves_like 'a idempotent resource' describe command("mysql -e 'show databases;'") do its(:exit_status) { is_expected.to eq 0 } - its(:stdout) { is_expected.to match /^realdb$/ } + its(:stdout) { is_expected.to match %r{^realdb$} } end end end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/spec/acceptance/mysql_helper.rb puppet-module-puppetlabs-mysql-5.3.0/spec/acceptance/mysql_helper.rb --- puppet-module-puppetlabs-mysql-3.10.0/spec/acceptance/mysql_helper.rb 2016-09-06 22:04:13.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/spec/acceptance/mysql_helper.rb 2017-10-05 23:11:56.000000000 +0000 @@ -1,8 +1,8 @@ - def pre_run - apply_manifest("class { 'mysql::server': root_password => 'password' }", :catch_failures => true) - @mysql_version = (on default, 'mysql --version').output.chomp.match(/\d+\.\d+\.\d+/)[0] - end +def pre_run + apply_manifest("class { 'mysql::server': root_password => 'password' }", catch_failures: true) + @mysql_version = (on default, 'mysql --version').output.chomp.match(%r{\d+\.\d+\.\d+})[0] +end - def version_is_greater_than(version) - return Puppet::Util::Package.versioncmp(@mysql_version, version) > 0 - end +def version_is_greater_than(version) + Puppet::Util::Package.versioncmp(@mysql_version, version) > 0 +end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/spec/acceptance/mysql_server_spec.rb puppet-module-puppetlabs-mysql-5.3.0/spec/acceptance/mysql_server_spec.rb --- puppet-module-puppetlabs-mysql-3.10.0/spec/acceptance/mysql_server_spec.rb 2016-09-06 22:04:13.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/spec/acceptance/mysql_server_spec.rb 2018-01-19 18:07:36.000000000 +0000 @@ -1,12 +1,13 @@ require 'spec_helper_acceptance' describe 'mysql class' do + # rubocop:disable RSpec/InstanceVariable describe 'advanced config' do before(:all) do @tmpdir = default.tmpdir('mysql') end let(:pp) do - <<-EOS + <<-MANIFEST class { 'mysql::server': config_file => '#{@tmpdir}/my.cnf', includedir => '#{@tmpdir}/include', @@ -45,10 +46,10 @@ }, } } - EOS + MANIFEST end - it_behaves_like "a idempotent resource" + it_behaves_like 'a idempotent resource' end describe 'minimal config' do @@ -56,7 +57,7 @@ @tmpdir = default.tmpdir('mysql') end let(:pp) do - <<-EOS + <<-MANIFEST class { 'mysql::server': config_file => '#{@tmpdir}/my.cnf', includedir => '#{@tmpdir}/include', @@ -74,34 +75,35 @@ grants => {}, databases => {}, } - EOS + MANIFEST end - it_behaves_like "a idempotent resource" + it_behaves_like 'a idempotent resource' end + # rubocop:enable RSpec/InstanceVariable describe 'syslog configuration' do let(:pp) do - <<-EOS + <<-MANIFEST class { 'mysql::server': override_options => { 'mysqld' => { 'log-error' => undef }, 'mysqld_safe' => { 'log-error' => false, 'syslog' => true }}, } - EOS + MANIFEST end - it_behaves_like "a idempotent resource" + it_behaves_like 'a idempotent resource' end context 'when changing the password' do let(:password) { 'THE NEW SECRET' } let(:pp) { "class { 'mysql::server': root_password => '#{password}' }" } - it 'should not display the password' do - result = apply_manifest(pp, :catch_failures => true) + it 'does not display the password' do + result = apply_manifest(pp, catch_failures: true) # this does not actually prove anything, as show_diff in the puppet config defaults to false. - expect(result.stdout).not_to match /#{password}/ + expect(result.stdout).not_to match %r{#{password}} end - it_behaves_like "a idempotent resource" + it_behaves_like 'a idempotent resource' end end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/spec/acceptance/sql_task_spec.rb puppet-module-puppetlabs-mysql-5.3.0/spec/acceptance/sql_task_spec.rb --- puppet-module-puppetlabs-mysql-3.10.0/spec/acceptance/sql_task_spec.rb 1970-01-01 00:00:00.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/spec/acceptance/sql_task_spec.rb 2018-01-19 18:07:36.000000000 +0000 @@ -0,0 +1,23 @@ +# run a test task +require 'spec_helper_acceptance' + +describe 'mysql tasks', if: puppet_version =~ %r{(5\.\d\.\d)} && fact('operatingsystem') != 'SLES' do + describe 'execute some sql' do + pp = <<-MANIFEST + class { 'mysql::server': root_password => 'password' } + mysql::db { 'spec1': + user => 'root1', + password => 'password', + } + MANIFEST + + it 'sets up a mysql instance' do + apply_manifest_on(hosts, pp, catch_failures: true) + end + + it 'execute arbitary sql' do + result = run_task(task_name: 'mysql::sql', params: 'sql="show databases;" password=password') + expect_multiple_regexes(result: result, regexes: [%r{information_schema}, %r{#{task_summary_line}}]) + end + end +end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/spec/acceptance/types/mysql_database_spec.rb puppet-module-puppetlabs-mysql-5.3.0/spec/acceptance/types/mysql_database_spec.rb --- puppet-module-puppetlabs-mysql-3.10.0/spec/acceptance/types/mysql_database_spec.rb 2016-07-27 17:34:11.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/spec/acceptance/types/mysql_database_spec.rb 2018-01-19 18:07:36.000000000 +0000 @@ -2,37 +2,38 @@ describe 'mysql_database' do describe 'setup' do - it 'should work with no errors' do - pp = <<-EOS + pp = <<-MANIFEST class { 'mysql::server': } - EOS - - apply_manifest(pp, :catch_failures => true) + MANIFEST + it 'works with no errors' do + apply_manifest(pp, catch_failures: true) end end describe 'creating database' do - it 'should work without errors' do - pp = <<-EOS + pp = <<-MANIFEST mysql_database { 'spec_db': ensure => present, } - EOS - - apply_manifest(pp, :catch_failures => true) + MANIFEST + it 'works without errors' do + apply_manifest(pp, catch_failures: true) end - it 'should find the database' do + it 'finds the database #stdout' do + shell("mysql -NBe \"SHOW DATABASES LIKE 'spec_db'\"") do |r| + expect(r.stdout).to match(%r{^spec_db$}) + end + end + it 'finds the database #stderr' do shell("mysql -NBe \"SHOW DATABASES LIKE 'spec_db'\"") do |r| - expect(r.stdout).to match(/^spec_db$/) expect(r.stderr).to be_empty end end end describe 'charset and collate' do - it 'should create two db of different types idempotently' do - pp = <<-EOS + pp = <<-MANIFEST mysql_database { 'spec_latin1': charset => 'latin1', collate => 'latin1_swedish_ci', @@ -41,22 +42,30 @@ charset => 'utf8', collate => 'utf8_general_ci', } - EOS - - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) + MANIFEST + it 'creates two db of different types idempotently' do + apply_manifest(pp, catch_failures: true) + apply_manifest(pp, catch_changes: true) end - it 'should find latin1 db' do + it 'finds latin1 db #stdout' do + shell("mysql -NBe \"SHOW VARIABLES LIKE '%_database'\" spec_latin1") do |r| + expect(r.stdout).to match(%r{^character_set_database\tlatin1\ncollation_database\tlatin1_swedish_ci$}) + end + end + it 'finds latin1 db #stderr' do shell("mysql -NBe \"SHOW VARIABLES LIKE '%_database'\" spec_latin1") do |r| - expect(r.stdout).to match(/^character_set_database\tlatin1\ncollation_database\tlatin1_swedish_ci$/) expect(r.stderr).to be_empty end end - it 'should find utf8 db' do + it 'finds utf8 db #stdout' do + shell("mysql -NBe \"SHOW VARIABLES LIKE '%_database'\" spec_utf8") do |r| + expect(r.stdout).to match(%r{^character_set_database\tutf8\ncollation_database\tutf8_general_ci$}) + end + end + it 'finds utf8 db #stderr' do shell("mysql -NBe \"SHOW VARIABLES LIKE '%_database'\" spec_utf8") do |r| - expect(r.stdout).to match(/^character_set_database\tutf8\ncollation_database\tutf8_general_ci$/) expect(r.stderr).to be_empty end end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/spec/acceptance/types/mysql_grant_spec.rb puppet-module-puppetlabs-mysql-5.3.0/spec/acceptance/types/mysql_grant_spec.rb --- puppet-module-puppetlabs-mysql-3.10.0/spec/acceptance/types/mysql_grant_spec.rb 2016-09-06 22:04:13.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/spec/acceptance/types/mysql_grant_spec.rb 2018-02-20 14:54:26.000000000 +0000 @@ -1,23 +1,21 @@ require 'spec_helper_acceptance' -require 'puppet' require 'puppet/util/package' require_relative '../mysql_helper.rb' describe 'mysql_grant' do before(:all) do - pp = <<-EOS + pp = <<-MANIFEST class { 'mysql::server': root_password => 'password', } - EOS + MANIFEST - apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, catch_failures: true) end describe 'missing privileges for user' do - it 'should fail' do - pp = <<-EOS - mysql_user { 'test1@tester': + pp = <<-MANIFEST + mysql_user { 'test1@tester': ensure => present, } mysql_grant { 'test1@tester/test.*': @@ -26,19 +24,18 @@ user => 'test1@tester', require => Mysql_user['test1@tester'], } - EOS - - expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/privileges parameter is required/) + MANIFEST + it 'fails' do + expect(apply_manifest(pp, expect_failures: true).stderr).to match(%r{`privileges` `parameter` is required}) end - it 'should not find the user' do - expect(shell("mysql -NBe \"SHOW GRANTS FOR test1@tester\"", { :acceptable_exit_codes => 1}).stderr).to match(/There is no such grant defined for user 'test1' on host 'tester'/) + it 'does not find the user' do + expect(shell('mysql -NBe "SHOW GRANTS FOR test1@tester"', acceptable_exit_codes: 1).stderr).to match(%r{There is no such grant defined for user 'test1' on host 'tester'}) end end describe 'missing table for user' do - it 'should fail' do - pp = <<-EOS + pp = <<-MANIFEST mysql_user { 'atest@tester': ensure => present, } @@ -48,19 +45,18 @@ privileges => ['ALL'], require => Mysql_user['atest@tester'], } - EOS - - apply_manifest(pp, :expect_failures => true) + MANIFEST + it 'fails' do + apply_manifest(pp, expect_failures: true) end - it 'should not find the user' do - expect(shell("mysql -NBe \"SHOW GRANTS FOR atest@tester\"", {:acceptable_exit_codes => 1}).stderr).to match(/There is no such grant defined for user 'atest' on host 'tester'/) + it 'does not find the user' do + expect(shell('mysql -NBe "SHOW GRANTS FOR atest@tester"', acceptable_exit_codes: 1).stderr).to match(%r{There is no such grant defined for user 'atest' on host 'tester'}) end end describe 'adding privileges' do - it 'should work without errors' do - pp = <<-EOS + pp = <<-MANIFEST mysql_user { 'test2@tester': ensure => present, } @@ -71,22 +67,25 @@ privileges => ['SELECT', 'UPDATE'], require => Mysql_user['test2@tester'], } - EOS - - apply_manifest(pp, :catch_failures => true) + MANIFEST + it 'works without errors' do + apply_manifest(pp, catch_failures: true) end - it 'should find the user' do - shell("mysql -NBe \"SHOW GRANTS FOR test2@tester\"") do |r| - expect(r.stdout).to match(/GRANT SELECT, UPDATE.*TO 'test2'@'tester'/) + it 'finds the user #stdout' do + shell('mysql -NBe "SHOW GRANTS FOR test2@tester"') do |r| + expect(r.stdout).to match(%r{GRANT SELECT, UPDATE.*TO 'test2'@'tester'}) + end + end + it 'finds the user #stderr' do + shell('mysql -NBe "SHOW GRANTS FOR test2@tester"') do |r| expect(r.stderr).to be_empty end end end describe 'adding privileges with special character in name' do - it 'should work without errors' do - pp = <<-EOS + pp = <<-MANIFEST mysql_user { 'test-2@tester': ensure => present, } @@ -97,41 +96,25 @@ privileges => ['SELECT', 'UPDATE'], require => Mysql_user['test-2@tester'], } - EOS - - apply_manifest(pp, :catch_failures => true) + MANIFEST + it 'works without errors' do + apply_manifest(pp, catch_failures: true) end - it 'should find the user' do + it 'finds the user #stdout' do shell("mysql -NBe \"SHOW GRANTS FOR 'test-2'@tester\"") do |r| - expect(r.stdout).to match(/GRANT SELECT, UPDATE.*TO 'test-2'@'tester'/) - expect(r.stderr).to be_empty + expect(r.stdout).to match(%r{GRANT SELECT, UPDATE.*TO 'test-2'@'tester'}) end end - end - - describe 'adding privileges with invalid name' do - it 'should fail' do - pp = <<-EOS - mysql_user { 'test2@tester': - ensure => present, - } - mysql_grant { 'test': - ensure => 'present', - table => 'test.*', - user => 'test2@tester', - privileges => ['SELECT', 'UPDATE'], - require => Mysql_user['test2@tester'], - } - EOS - - expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/name must match user and table parameters/) + it 'finds the user #stderr' do + shell("mysql -NBe \"SHOW GRANTS FOR 'test-2'@tester\"") do |r| + expect(r.stderr).to be_empty + end end end describe 'adding option' do - it 'should work without errors' do - pp = <<-EOS + pp = <<-MANIFEST mysql_user { 'test3@tester': ensure => present, } @@ -143,22 +126,25 @@ privileges => ['SELECT', 'UPDATE'], require => Mysql_user['test3@tester'], } - EOS - - apply_manifest(pp, :catch_failures => true) + MANIFEST + it 'works without errors' do + apply_manifest(pp, catch_failures: true) end - it 'should find the user' do - shell("mysql -NBe \"SHOW GRANTS FOR test3@tester\"") do |r| - expect(r.stdout).to match(/GRANT SELECT, UPDATE ON `test`.* TO 'test3'@'tester' WITH GRANT OPTION$/) + it 'finds the user #stdout' do + shell('mysql -NBe "SHOW GRANTS FOR test3@tester"') do |r| + expect(r.stdout).to match(%r{GRANT SELECT, UPDATE ON `test`.* TO 'test3'@'tester' WITH GRANT OPTION$}) + end + end + it 'finds the user #stderr' do + shell('mysql -NBe "SHOW GRANTS FOR test3@tester"') do |r| expect(r.stderr).to be_empty end end end describe 'adding all privileges without table' do - it 'should fail' do - pp = <<-EOS + pp = <<-MANIFEST mysql_user { 'test4@tester': ensure => present, } @@ -169,15 +155,14 @@ privileges => ['SELECT', 'UPDATE', 'ALL'], require => Mysql_user['test4@tester'], } - EOS - - expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/table parameter is required./) + MANIFEST + it 'fails' do + expect(apply_manifest(pp, expect_failures: true).stderr).to match(%r{`table` `parameter` is required.}) end end describe 'adding all privileges' do - it 'should only try to apply ALL' do - pp = <<-EOS + pp = <<-MANIFEST mysql_user { 'test4@tester': ensure => present, } @@ -189,14 +174,18 @@ privileges => ['SELECT', 'UPDATE', 'ALL'], require => Mysql_user['test4@tester'], } - EOS - - apply_manifest(pp, :catch_failures => true) + MANIFEST + it 'onlies try to apply ALL' do + apply_manifest(pp, catch_failures: true) end - it 'should find the user' do - shell("mysql -NBe \"SHOW GRANTS FOR test4@tester\"") do |r| - expect(r.stdout).to match(/GRANT ALL PRIVILEGES ON `test`.* TO 'test4'@'tester' WITH GRANT OPTION/) + it 'finds the user #stdout' do + shell('mysql -NBe "SHOW GRANTS FOR test4@tester"') do |r| + expect(r.stdout).to match(%r{GRANT ALL PRIVILEGES ON `test`.* TO 'test4'@'tester' WITH GRANT OPTION}) + end + end + it 'finds the user #stderr' do + shell('mysql -NBe "SHOW GRANTS FOR test4@tester"') do |r| expect(r.stderr).to be_empty end end @@ -204,8 +193,7 @@ # Test combinations of user@host to ensure all cases work. describe 'short hostname' do - it 'should apply' do - pp = <<-EOS + pp = <<-MANIFEST mysql_user { 'test@short': ensure => present, } @@ -256,46 +244,69 @@ privileges => 'ALL', require => Mysql_user['test@::1/128'], } - EOS - - apply_manifest(pp, :catch_failures => true) + MANIFEST + it 'applies' do + apply_manifest(pp, catch_failures: true) end - it 'finds short hostname' do - shell("mysql -NBe \"SHOW GRANTS FOR test@short\"") do |r| - expect(r.stdout).to match(/GRANT ALL PRIVILEGES ON `test`.* TO 'test'@'short'/) + it 'finds short hostname #stdout' do + shell('mysql -NBe "SHOW GRANTS FOR test@short"') do |r| + expect(r.stdout).to match(%r{GRANT ALL PRIVILEGES ON `test`.* TO 'test'@'short'}) + end + end + it 'finds short hostname #stderr' do + shell('mysql -NBe "SHOW GRANTS FOR test@short"') do |r| expect(r.stderr).to be_empty end end - it 'finds long hostname' do + + it 'finds long hostname #stdout' do + shell("mysql -NBe \"SHOW GRANTS FOR 'test'@'long.hostname.com'\"") do |r| + expect(r.stdout).to match(%r{GRANT ALL PRIVILEGES ON `test`.* TO 'test'@'long.hostname.com'}) + end + end + it 'finds long hostname #stderr' do shell("mysql -NBe \"SHOW GRANTS FOR 'test'@'long.hostname.com'\"") do |r| - expect(r.stdout).to match(/GRANT ALL PRIVILEGES ON `test`.* TO 'test'@'long.hostname.com'/) expect(r.stderr).to be_empty end end - it 'finds ipv4' do + + it 'finds ipv4 #stdout' do + shell("mysql -NBe \"SHOW GRANTS FOR 'test'@'192.168.5.6'\"") do |r| + expect(r.stdout).to match(%r{GRANT ALL PRIVILEGES ON `test`.* TO 'test'@'192.168.5.6'}) + end + end + it 'finds ipv4 #stderr' do shell("mysql -NBe \"SHOW GRANTS FOR 'test'@'192.168.5.6'\"") do |r| - expect(r.stdout).to match(/GRANT ALL PRIVILEGES ON `test`.* TO 'test'@'192.168.5.6'/) expect(r.stderr).to be_empty end end - it 'finds ipv6' do + + it 'finds ipv6 #stdout' do + shell("mysql -NBe \"SHOW GRANTS FOR 'test'@'2607:f0d0:1002:0051:0000:0000:0000:0004'\"") do |r| + expect(r.stdout).to match(%r{GRANT ALL PRIVILEGES ON `test`.* TO 'test'@'2607:f0d0:1002:0051:0000:0000:0000:0004'}) + end + end + it 'finds ipv6 #stderr' do shell("mysql -NBe \"SHOW GRANTS FOR 'test'@'2607:f0d0:1002:0051:0000:0000:0000:0004'\"") do |r| - expect(r.stdout).to match(/GRANT ALL PRIVILEGES ON `test`.* TO 'test'@'2607:f0d0:1002:0051:0000:0000:0000:0004'/) expect(r.stderr).to be_empty end end - it 'finds short ipv6' do + + it 'finds short ipv6 #stdout' do + shell("mysql -NBe \"SHOW GRANTS FOR 'test'@'::1/128'\"") do |r| + expect(r.stdout).to match(%r{GRANT ALL PRIVILEGES ON `test`.* TO 'test'@'::1\/128'}) + end + end + it 'finds short ipv6 @stderr' do shell("mysql -NBe \"SHOW GRANTS FOR 'test'@'::1/128'\"") do |r| - expect(r.stdout).to match(/GRANT ALL PRIVILEGES ON `test`.* TO 'test'@'::1\/128'/) expect(r.stderr).to be_empty end end end describe 'complex test' do - it 'setup mysql::server' do - pp = <<-EOS + pp = <<-MANIFEST $dbSubnet = '10.10.10.%' mysql_database { 'foo': @@ -370,16 +381,15 @@ user => 'web@localhost', require => Mysql_user['web@localhost'], } - EOS - - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) + MANIFEST + it 'setup mysql::server' do + apply_manifest(pp, catch_failures: true) + apply_manifest(pp, catch_changes: true) end end describe 'lower case privileges' do - it 'create ALL privs' do - pp = <<-EOS + pp_one = <<-MANIFEST mysql_user { 'lowercase@localhost': ensure => present, } @@ -389,13 +399,12 @@ table => '*.*', require => Mysql_user['lowercase@localhost'], } - EOS - - apply_manifest(pp, :catch_failures => true) + MANIFEST + it 'create ALL privs' do + apply_manifest(pp_one, catch_failures: true) end - it 'create lowercase all privs' do - pp = <<-EOS + pp_two = <<-MANIFEST mysql_user { 'lowercase@localhost': ensure => present, } @@ -405,21 +414,18 @@ table => '*.*', require => Mysql_user['lowercase@localhost'], } - EOS - - expect(apply_manifest(pp, :catch_failures => true).exit_code).to eq(0) + MANIFEST + it 'create lowercase all privs' do + expect(apply_manifest(pp_two, catch_failures: true).exit_code).to eq(0) end end describe 'adding procedure privileges' do - it 'should work without errors' do - pp = <<-EOS - if $::operatingsystem == 'Ubuntu' and versioncmp($::operatingsystemmajrelease, '16.00') > 0 { - exec { 'simpleproc-create': - command => 'mysql --user="root" --password="password" --database=mysql --delimiter="//" -NBe "CREATE PROCEDURE simpleproc (OUT param1 INT) BEGIN SELECT COUNT(*) INTO param1 FROM t; end//"', - path => '/usr/bin/', - before => Mysql_user['test2@tester'], - } + pp = <<-MANIFEST + exec { 'simpleproc-create': + command => 'mysql --user="root" --password="password" --database=mysql --delimiter="//" -NBe "CREATE PROCEDURE simpleproc (OUT param1 INT) BEGIN SELECT COUNT(*) INTO param1 FROM t; end//"', + path => '/usr/bin/', + before => Mysql_user['test2@tester'], } mysql_user { 'test2@tester': ensure => present, @@ -431,35 +437,198 @@ privileges => ['EXECUTE'], require => Mysql_user['test2@tester'], } - EOS + MANIFEST + it 'works without errors' do + apply_manifest(pp, catch_failures: true) + end - apply_manifest(pp, :catch_failures => true) + it 'finds the user #stdout' do + shell('mysql -NBe "SHOW GRANTS FOR test2@tester"') do |r| + expect(r.stdout).to match(%r{GRANT EXECUTE ON PROCEDURE `mysql`.`simpleproc` TO 'test2'@'tester'}) + end + end + it 'finds the user #stderr' do + shell('mysql -NBe "SHOW GRANTS FOR test2@tester"') do |r| + expect(r.stderr).to be_empty + end end + end - it 'should find the user' do - shell("mysql -NBe \"SHOW GRANTS FOR test2@tester\"") do |r| - expect(r.stdout).to match(/GRANT EXECUTE ON PROCEDURE `mysql`.`simpleproc` TO 'test2'@'tester'/) + describe 'adding function privileges' do + it 'works without errors' do + pp = <<-EOS + exec { 'simplefunc-create': + command => '/usr/bin/mysql --user="root" --password="password" --database=mysql -NBe "CREATE FUNCTION simplefunc (s CHAR(20)) RETURNS CHAR(50) DETERMINISTIC RETURN CONCAT(\\'Hello, \\', s, \\'!\\')"', + before => Mysql_user['test3@tester'], + } + + mysql_user { 'test3@tester': + ensure => 'present', + } + + mysql_grant { 'test3@tester/FUNCTION mysql.simplefunc': + ensure => 'present', + table => 'FUNCTION mysql.simplefunc', + user => 'test3@tester', + privileges => ['EXECUTE'], + require => Mysql_user['test3@tester'], + } + EOS + + apply_manifest(pp, catch_failures: true) + end + # rubocop:enable RSpec/ExampleLength + it 'finds the user' do + shell('mysql -NBe "SHOW GRANTS FOR test3@tester"') do |r| + expect(r.stdout).to match(%r{GRANT EXECUTE ON FUNCTION `mysql`.`simplefunc` TO 'test3'@'tester'}) expect(r.stderr).to be_empty end end + # rubocop:enable RSpec/MultipleExpectations + end + + describe 'proxy privilieges' do + pre_run + + describe 'adding proxy privileges', if: version_is_greater_than('5.5.0') do + pp = <<-MANIFEST + mysql_user { 'proxy1@tester': + ensure => present, + } + mysql_grant { 'proxy1@tester/proxy_user@proxy_host': + ensure => 'present', + table => 'proxy_user@proxy_host', + user => 'proxy1@tester', + privileges => ['PROXY'], + require => Mysql_user['proxy1@tester'], + } + MANIFEST + it 'works without errors when version greater than 5.5.0' do + apply_manifest(pp, catch_failures: true) + end + + it 'finds the user #stdout' do + shell('mysql -NBe "SHOW GRANTS FOR proxy1@tester"') do |r| + expect(r.stdout).to match(%r{GRANT PROXY ON 'proxy_user'@'proxy_host' TO 'proxy1'@'tester'}) + end + end + it 'finds the user #stderr' do + shell('mysql -NBe "SHOW GRANTS FOR proxy1@tester"') do |r| + expect(r.stderr).to be_empty + end + end + end + + describe 'removing proxy privileges', if: version_is_greater_than('5.5.0') do + pp = <<-MANIFEST + mysql_user { 'proxy1@tester': + ensure => present, + } + mysql_grant { 'proxy1@tester/proxy_user@proxy_host': + ensure => 'absent', + table => 'proxy_user@proxy_host', + user => 'proxy1@tester', + privileges => ['PROXY'], + require => Mysql_user['proxy1@tester'], + } + MANIFEST + it 'works without errors' do + apply_manifest(pp, catch_failures: true) + end + + it 'finds the user #stdout' do + shell('mysql -NBe "SHOW GRANTS FOR proxy1@tester"') do |r| + expect(r.stdout).not_to match(%r{GRANT PROXY ON 'proxy_user'@'proxy_host' TO 'proxy1'@'tester'}) + end + end + it 'finds the user #stderr' do + shell('mysql -NBe "SHOW GRANTS FOR proxy1@tester"') do |r| + expect(r.stderr).to be_empty + end + end + end + + describe 'adding proxy privileges with other privileges', if: version_is_greater_than('5.5.0') do + pp = <<-MANIFEST + mysql_user { 'proxy2@tester': + ensure => present, + } + mysql_grant { 'proxy2@tester/proxy_user@proxy_host': + ensure => 'present', + table => 'proxy_user@proxy_host', + user => 'proxy2@tester', + privileges => ['PROXY', 'SELECT'], + require => Mysql_user['proxy2@tester'], + } + MANIFEST + it 'fails' do + expect(apply_manifest(pp, expect_failures: true).stderr).to match(%r{`privileges` `parameter`: PROXY can only be specified by itself}) + end + + it 'does not find the user' do + expect(shell('mysql -NBe "SHOW GRANTS FOR proxy2@tester"', acceptable_exit_codes: 1).stderr).to match(%r{There is no such grant defined for user 'proxy2' on host 'tester'}) + end + end + + describe 'adding proxy privileges with mysql version less than 5.5.0', unless: version_is_greater_than('5.5.0') do + pp = <<-MANIFEST + mysql_user { 'proxy3@tester': + ensure => present, + } + mysql_grant { 'proxy3@tester/proxy_user@proxy_host': + ensure => 'present', + table => 'proxy_user@proxy_host', + user => 'proxy3@tester', + privileges => ['PROXY', 'SELECT'], + require => Mysql_user['proxy3@tester'], + } + MANIFEST + it 'fails' do + expect(apply_manifest(pp, expect_failures: true).stderr).to match(%r{PROXY user not supported on mysql versions < 5\.5\.0}i) + end + + it 'does not find the user' do + expect(shell('mysql -NBe "SHOW GRANTS FOR proxy2@tester"', acceptable_exit_codes: 1).stderr).to match(%r{There is no such grant defined for user 'proxy2' on host 'tester'}) + end + end + + describe 'adding proxy privileges with invalid proxy user', if: version_is_greater_than('5.5.0') do + pp = <<-MANIFEST + mysql_user { 'proxy3@tester': + ensure => present, + } + mysql_grant { 'proxy3@tester/invalid_proxy_user': + ensure => 'present', + table => 'invalid_proxy_user', + user => 'proxy3@tester', + privileges => ['PROXY'], + require => Mysql_user['proxy3@tester'], + } + MANIFEST + it 'fails' do + expect(apply_manifest(pp, expect_failures: true).stderr).to match(%r{`table` `property` for PROXY should be specified as proxy_user@proxy_host.}) + end + + it 'does not find the user' do + expect(shell('mysql -NBe "SHOW GRANTS FOR proxy3@tester"', acceptable_exit_codes: 1).stderr).to match(%r{There is no such grant defined for user 'proxy3' on host 'tester'}) + end + end end describe 'grants with skip-name-resolve specified' do - it 'setup mysql::server' do - pp = <<-EOS + pp_one = <<-MANIFEST class { 'mysql::server': override_options => { 'mysqld' => {'skip-name-resolve' => true} }, restart => true, } - EOS - - apply_manifest(pp, :catch_failures => true) + MANIFEST + it 'setup mysql::server' do + apply_manifest(pp_one, catch_failures: true) end - it 'should apply' do - pp = <<-EOS + pp_two = <<-MANIFEST mysql_user { 'test@fqdn.com': ensure => present, } @@ -480,26 +649,30 @@ privileges => 'ALL', require => Mysql_user['test@192.168.5.7'], } - EOS - - apply_manifest(pp, :catch_failures => true) + MANIFEST + it 'applies' do + apply_manifest(pp_two, catch_failures: true) end - it 'should fail with fqdn' do + it 'fails with fqdn' do pre_run - if ! version_is_greater_than('5.7.0') - expect(shell("mysql -NBe \"SHOW GRANTS FOR test@fqdn.com\"", { :acceptable_exit_codes => 1}).stderr).to match(/There is no such grant defined for user 'test' on host 'fqdn.com'/) + unless version_is_greater_than('5.7.0') + expect(shell('mysql -NBe "SHOW GRANTS FOR test@fqdn.com"', acceptable_exit_codes: 1).stderr).to match(%r{There is no such grant defined for user 'test' on host 'fqdn.com'}) + end + end + + it 'finds ipv4 #stdout' do + shell("mysql -NBe \"SHOW GRANTS FOR 'test'@'192.168.5.7'\"") do |r| + expect(r.stdout).to match(%r{GRANT ALL PRIVILEGES ON `test`.* TO 'test'@'192.168.5.7'}) end end - it 'finds ipv4' do + it 'finds ipv4 #stderr' do shell("mysql -NBe \"SHOW GRANTS FOR 'test'@'192.168.5.7'\"") do |r| - expect(r.stdout).to match(/GRANT ALL PRIVILEGES ON `test`.* TO 'test'@'192.168.5.7'/) expect(r.stderr).to be_empty end end - it 'should fail to execute while applying' do - pp = <<-EOS + pp_three = <<-MANIFEST mysql_user { 'test@fqdn.com': ensure => present, } @@ -510,37 +683,34 @@ privileges => 'ALL', require => Mysql_user['test@fqdn.com'], } - EOS - + MANIFEST + it 'fails to execute while applying' do mysql_cmd = shell('which mysql').stdout.chomp shell("mv #{mysql_cmd} #{mysql_cmd}.bak") - expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/Command mysql is missing/) + expect(apply_manifest(pp_three, expect_failures: true).stderr).to match(%r{Could not find a suitable provider for mysql_grant}) shell("mv #{mysql_cmd}.bak #{mysql_cmd}") end - it 'reset mysql::server config' do - pp = <<-EOS + pp_four = <<-MANIFEST class { 'mysql::server': restart => true, } - EOS - - apply_manifest(pp, :catch_failures => true) + MANIFEST + it 'reset mysql::server config' do + apply_manifest(pp_four, catch_failures: true) end end describe 'adding privileges to specific table' do # Using puppet_apply as a helper - it 'setup mysql server' do - pp = <<-EOS + pp_one = <<-MANIFEST class { 'mysql::server': override_options => { 'root_password' => 'password' } } - EOS - - apply_manifest(pp, :catch_failures => true) + MANIFEST + it 'setup mysql server' do + apply_manifest(pp_one, catch_failures: true) end - it 'creates grant on missing table will fail' do - pp = <<-EOS + pp_two = <<-MANIFEST mysql_user { 'test@localhost': ensure => present, } @@ -550,12 +720,12 @@ table => 'grant_spec_db.grant_spec_table', require => Mysql_user['test@localhost'], } - EOS - expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/Table 'grant_spec_db\.grant_spec_table' doesn't exist/) + MANIFEST + it 'creates grant on missing table will fail' do + expect(apply_manifest(pp_two, expect_failures: true).stderr).to match(%r{Table 'grant_spec_db\.grant_spec_table' doesn't exist}) end - it 'creates table' do - pp = <<-EOS + pp_three = <<-MANIFEST file { '/tmp/grant_spec_table.sql': ensure => file, content => 'CREATE TABLE grant_spec_table (id int);', @@ -566,12 +736,12 @@ password => 'password', sql => '/tmp/grant_spec_table.sql', } - EOS - - apply_manifest(pp, :catch_failures => true) + MANIFEST + it 'creates table' do + apply_manifest(pp_three, catch_failures: true) end - it 'should have the table' do + it 'has the table' do expect(shell("mysql -e 'show tables;' grant_spec_db|grep grant_spec_table").exit_code).to be_zero end end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/spec/acceptance/types/mysql_plugin_spec.rb puppet-module-puppetlabs-mysql-5.3.0/spec/acceptance/types/mysql_plugin_spec.rb --- puppet-module-puppetlabs-mysql-3.10.0/spec/acceptance/types/mysql_plugin_spec.rb 2016-09-06 22:04:13.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/spec/acceptance/types/mysql_plugin_spec.rb 2018-01-19 18:07:36.000000000 +0000 @@ -4,30 +4,30 @@ # of mysql) have varying levels of support for plugins and have # different plugins available. Choose a plugin that works or don't try # to test plugins if not available. -if fact('osfamily') =~ /RedHat/ - if fact('operatingsystemrelease') =~ /^5\./ +if fact('osfamily') =~ %r{RedHat} + if fact('operatingsystemrelease') =~ %r{^5\.} plugin = nil # Plugins not supported on mysql on RHEL 5 - elsif fact('operatingsystemrelease') =~ /^6\./ + elsif fact('operatingsystemrelease') =~ %r{^6\.} plugin = 'example' plugin_lib = 'ha_example.so' - elsif fact('operatingsystemrelease') =~ /^7\./ + elsif fact('operatingsystemrelease') =~ %r{^7\.} plugin = 'pam' plugin_lib = 'auth_pam.so' end -elsif fact('osfamily') =~ /Debian/ - if fact('operatingsystem') =~ /Debian/ - if fact('operatingsystemrelease') =~ /^6\./ +elsif fact('osfamily') =~ %r{Debian} + if fact('operatingsystem') =~ %r{Debian} + if fact('operatingsystemrelease') =~ %r{^6\.} # Only available plugin is innodb which is already loaded and not unload- or reload-able plugin = nil - elsif fact('operatingsystemrelease') =~ /^7\./ + elsif fact('operatingsystemrelease') =~ %r{^7\.} plugin = 'example' plugin_lib = 'ha_example.so' end - elsif fact('operatingsystem') =~ /Ubuntu/ - if fact('operatingsystemrelease') =~ /^10\.04/ + elsif fact('operatingsystem') =~ %r{Ubuntu} + if fact('operatingsystemrelease') =~ %r{^10\.04} # Only available plugin is innodb which is already loaded and not unload- or reload-able plugin = nil - elsif fact('operatingsystemrelease') =~ /^16\.04/ + elsif fact('operatingsystemrelease') =~ %r{^16\.04} # On Xenial running 5.7.12, the example plugin does not appear to be available. plugin = 'validate_password' plugin_lib = 'validate_password.so' @@ -36,41 +36,43 @@ plugin_lib = 'ha_example.so' end end -elsif fact('osfamily') =~ /Suse/ +elsif fact('osfamily') =~ %r{Suse} plugin = nil # Plugin library path is broken on Suse http://lists.opensuse.org/opensuse-bugs/2013-08/msg01123.html end describe 'mysql_plugin' do if plugin # if plugins are supported describe 'setup' do - it 'should work with no errors' do - pp = <<-EOS + it 'works with no errors' do + pp = <<-MANIFEST class { 'mysql::server': } - EOS + MANIFEST - apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, catch_failures: true) end end describe 'load plugin' do - it 'should work without errors' do - pp = <<-EOS + pp = <<-MANIFEST mysql_plugin { #{plugin}: ensure => present, soname => '#{plugin_lib}', } - EOS - - apply_manifest(pp, :catch_failures => true) + MANIFEST + it 'works without errors' do + apply_manifest(pp, catch_failures: true) end - it 'should find the plugin' do + it 'finds the plugin #stdout' do + shell("mysql -NBe \"select plugin_name from information_schema.plugins where plugin_name='#{plugin}'\"") do |r| + expect(r.stdout).to match(%r{^#{plugin}$}i) + end + end + it 'finds the plugin #stderr' do shell("mysql -NBe \"select plugin_name from information_schema.plugins where plugin_name='#{plugin}'\"") do |r| - expect(r.stdout).to match(/^#{plugin}$/i) expect(r.stderr).to be_empty end end end end - end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/spec/acceptance/types/mysql_user_spec.rb puppet-module-puppetlabs-mysql-5.3.0/spec/acceptance/types/mysql_user_spec.rb --- puppet-module-puppetlabs-mysql-3.10.0/spec/acceptance/types/mysql_user_spec.rb 2016-11-07 20:14:07.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/spec/acceptance/types/mysql_user_spec.rb 2018-02-20 14:54:26.000000000 +0000 @@ -1,58 +1,103 @@ require 'spec_helper_acceptance' +require_relative '../mysql_helper.rb' describe 'mysql_user' do describe 'setup' do - it 'should work with no errors' do - pp = <<-EOS + pp_one = <<-MANIFEST class { 'mysql::server': } - EOS - - apply_manifest(pp, :catch_failures => true) + MANIFEST + it 'works with no errors' do + apply_manifest(pp_one, catch_failures: true) end end context 'using ashp@localhost' do describe 'adding user' do - it 'should work without errors' do - pp = <<-EOS + pp_two = <<-MANIFEST mysql_user { 'ashp@localhost': password_hash => '*F9A8E96790775D196D12F53BCC88B8048FF62ED5', } - EOS - - apply_manifest(pp, :catch_failures => true) + MANIFEST + it 'works without errors' do + apply_manifest(pp_two, catch_failures: true) end - it 'should find the user' do + it 'finds the user #stdout' do + shell("mysql -NBe \"select '1' from mysql.user where CONCAT(user, '@', host) = 'ashp@localhost'\"") do |r| + expect(r.stdout).to match(%r{^1$}) + end + end + it 'finds the user #stderr' do shell("mysql -NBe \"select '1' from mysql.user where CONCAT(user, '@', host) = 'ashp@localhost'\"") do |r| - expect(r.stdout).to match(/^1$/) expect(r.stderr).to be_empty end end - it 'has no SSL options' do + + it 'has no SSL options #stdout' do + shell("mysql -NBe \"select SSL_TYPE from mysql.user where CONCAT(user, '@', host) = 'ashp@localhost'\"") do |r| + expect(r.stdout).to match(%r{^\s*$}) + end + end + it 'has no SSL options #stderr' do shell("mysql -NBe \"select SSL_TYPE from mysql.user where CONCAT(user, '@', host) = 'ashp@localhost'\"") do |r| - expect(r.stdout).to match(/^\s*$/) expect(r.stderr).to be_empty end end end + + pre_run + describe 'changing authentication plugin', if: version_is_greater_than('5.5.0') do + it 'works without errors' do + pp = <<-EOS + mysql_user { 'ashp@localhost': + plugin => 'auth_socket', + } + EOS + + apply_manifest(pp, catch_failures: true) + end + + it 'has the correct plugin' do + shell("mysql -NBe \"select plugin from mysql.user where CONCAT(user, '@', host) = 'ashp@localhost'\"") do |r| + expect(r.stdout.rstrip).to eq('auth_socket') + expect(r.stderr).to be_empty + end + end + + it 'does not have a password' do + pre_run + table = if version_is_greater_than('5.7.0') + 'authentication_string' + else + 'password' + end + shell("mysql -NBe \"select #{table} from mysql.user where CONCAT(user, '@', host) = 'ashp@localhost'\"") do |r| + expect(r.stdout.rstrip).to be_empty + expect(r.stderr).to be_empty + end + end + end + # rubocop:enable RSpec/ExampleLength, RSpec/MultipleExpectations end context 'using ashp-dash@localhost' do describe 'adding user' do - it 'should work without errors' do - pp = <<-EOS + pp_three = <<-MANIFEST mysql_user { 'ashp-dash@localhost': password_hash => '*F9A8E96790775D196D12F53BCC88B8048FF62ED5', } - EOS - - apply_manifest(pp, :catch_failures => true) + MANIFEST + it 'works without errors' do + apply_manifest(pp_three, catch_failures: true) end - it 'should find the user' do + it 'finds the user #stdout' do + shell("mysql -NBe \"select '1' from mysql.user where CONCAT(user, '@', host) = 'ashp-dash@localhost'\"") do |r| + expect(r.stdout).to match(%r{^1$}) + end + end + it 'finds the user #stderr' do shell("mysql -NBe \"select '1' from mysql.user where CONCAT(user, '@', host) = 'ashp-dash@localhost'\"") do |r| - expect(r.stdout).to match(/^1$/) expect(r.stderr).to be_empty end end @@ -61,19 +106,22 @@ context 'using ashp@LocalHost' do describe 'adding user' do - it 'should work without errors' do - pp = <<-EOS + pp_four = <<-MANIFEST mysql_user { 'ashp@LocalHost': password_hash => '*F9A8E96790775D196D12F53BCC88B8048FF62ED5', } - EOS - - apply_manifest(pp, :catch_failures => true) + MANIFEST + it 'works without errors' do + apply_manifest(pp_four, catch_failures: true) end - it 'should find the user' do + it 'finds the user #stdout' do + shell("mysql -NBe \"select '1' from mysql.user where CONCAT(user, '@', host) = 'ashp@localhost'\"") do |r| + expect(r.stdout).to match(%r{^1$}) + end + end + it 'finds the user #stderr' do shell("mysql -NBe \"select '1' from mysql.user where CONCAT(user, '@', host) = 'ashp@localhost'\"") do |r| - expect(r.stdout).to match(/^1$/) expect(r.stderr).to be_empty end end @@ -81,36 +129,48 @@ end context 'using resource should throw no errors' do describe 'find users' do - it { - on default, puppet('resource mysql_user'), {:catch_failures => true} do |r| - expect(r.stdout).to_not match(/Error:/) - expect(r.stdout).to_not match(/must be properly quoted, invalid character:/) + it do + on default, puppet('resource mysql_user'), catch_failures: true do |r| + expect(r.stdout).not_to match(%r{Error:}) end - } + end + it do + on default, puppet('resource mysql_user'), catch_failures: true do |r| + expect(r.stdout).not_to match(%r{must be properly quoted, invalid character:}) + end + end end end context 'using user-w-ssl@localhost with SSL' do describe 'adding user' do - it 'should work without errors' do - pp = <<-EOS + pp_five = <<-MANIFEST mysql_user { 'user-w-ssl@localhost': password_hash => '*F9A8E96790775D196D12F53BCC88B8048FF62ED5', tls_options => ['SSL'], } - EOS - - apply_manifest(pp, :catch_failures => true) + MANIFEST + it 'works without errors' do + apply_manifest(pp_five, catch_failures: true) end - it 'should find the user' do + it 'finds the user #stdout' do + shell("mysql -NBe \"select '1' from mysql.user where CONCAT(user, '@', host) = 'user-w-ssl@localhost'\"") do |r| + expect(r.stdout).to match(%r{^1$}) + end + end + it 'finds the user #stderr' do shell("mysql -NBe \"select '1' from mysql.user where CONCAT(user, '@', host) = 'user-w-ssl@localhost'\"") do |r| - expect(r.stdout).to match(/^1$/) expect(r.stderr).to be_empty end end - it 'should show correct ssl_type' do + + it 'shows correct ssl_type #stdout' do + shell("mysql -NBe \"select SSL_TYPE from mysql.user where CONCAT(user, '@', host) = 'user-w-ssl@localhost'\"") do |r| + expect(r.stdout).to match(%r{^ANY$}) + end + end + it 'shows correct ssl_type #stderr' do shell("mysql -NBe \"select SSL_TYPE from mysql.user where CONCAT(user, '@', host) = 'user-w-ssl@localhost'\"") do |r| - expect(r.stdout).to match(/^ANY$/) expect(r.stderr).to be_empty end end @@ -118,26 +178,34 @@ end context 'using user-w-x509@localhost with X509' do describe 'adding user' do - it 'should work without errors' do - pp = <<-EOS + pp_six = <<-MANIFEST mysql_user { 'user-w-x509@localhost': password_hash => '*F9A8E96790775D196D12F53BCC88B8048FF62ED5', tls_options => ['X509'], } - EOS - - apply_manifest(pp, :catch_failures => true) + MANIFEST + it 'works without errors' do + apply_manifest(pp_six, catch_failures: true) end - it 'should find the user' do + it 'finds the user #stdout' do + shell("mysql -NBe \"select '1' from mysql.user where CONCAT(user, '@', host) = 'user-w-x509@localhost'\"") do |r| + expect(r.stdout).to match(%r{^1$}) + end + end + it 'finds the user #stderr' do shell("mysql -NBe \"select '1' from mysql.user where CONCAT(user, '@', host) = 'user-w-x509@localhost'\"") do |r| - expect(r.stdout).to match(/^1$/) expect(r.stderr).to be_empty end end - it 'should show correct ssl_type' do + + it 'shows correct ssl_type #stdout' do + shell("mysql -NBe \"select SSL_TYPE from mysql.user where CONCAT(user, '@', host) = 'user-w-x509@localhost'\"") do |r| + expect(r.stdout).to match(%r{^X509$}) + end + end + it 'shows correct ssl_type #stderr' do shell("mysql -NBe \"select SSL_TYPE from mysql.user where CONCAT(user, '@', host) = 'user-w-x509@localhost'\"") do |r| - expect(r.stdout).to match(/^X509$/) expect(r.stderr).to be_empty end end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/spec/classes/graceful_failures_spec.rb puppet-module-puppetlabs-mysql-5.3.0/spec/classes/graceful_failures_spec.rb --- puppet-module-puppetlabs-mysql-3.10.0/spec/classes/graceful_failures_spec.rb 2016-07-27 17:34:11.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/spec/classes/graceful_failures_spec.rb 2017-10-05 23:11:56.000000000 +0000 @@ -1,19 +1,16 @@ require 'spec_helper' describe 'mysql::server' do - context "on an unsupported OS" do - # fetch any sets of facts to modify them - os, facts = on_supported_os.first - - let(:facts) { - facts.merge({ - :osfamily => 'UNSUPPORTED', - :operatingsystem => 'UNSUPPORTED', - }) - } + context 'on an unsupported OS' do + let(:facts) do + { + osfamily: 'UNSUPPORTED', + operatingsystem: 'UNSUPPORTED', + } + end - it 'should gracefully fail' do - is_expected.to compile.and_raise_error(/Unsupported platform:/) + it 'gracefully fails' do + is_expected.to compile.and_raise_error(%r{Unsupported platform:}) end end end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/spec/classes/mycnf_template_spec.rb puppet-module-puppetlabs-mysql-5.3.0/spec/classes/mycnf_template_spec.rb --- puppet-module-puppetlabs-mysql-3.10.0/spec/classes/mycnf_template_spec.rb 2016-07-27 17:34:11.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/spec/classes/mycnf_template_spec.rb 2018-01-19 18:07:36.000000000 +0000 @@ -1,85 +1,84 @@ require 'spec_helper' describe 'mysql::server' do - context 'my.cnf template' do - on_supported_os.each do |os, facts| - context "on #{os}" do - let(:facts) { - facts.merge({ - :root_home => '/root', - }) - } - - context 'normal entry' do - let(:params) {{ :override_options => { 'mysqld' => { 'socket' => '/var/lib/mysql/mysql.sock' } } }} - it do - is_expected.to contain_file('mysql-config-file').with({ - :mode => '0644', - :selinux_ignore_defaults => true, - }).with_content(/socket = \/var\/lib\/mysql\/mysql.sock/) - end - end + on_supported_os.each do |os, facts| + context "my.cnf template - on #{os}" do + let(:facts) do + facts.merge(root_home: '/root') + end - describe 'array entry' do - let(:params) {{ :override_options => { 'mysqld' => { 'replicate-do-db' => ['base1', 'base2'], } }}} - it do - is_expected.to contain_file('mysql-config-file').with_content( - /.*replicate-do-db = base1\nreplicate-do-db = base2.*/ - ) - end - end + context 'normal entry' do + let(:params) { { override_options: { 'mysqld' => { 'socket' => '/var/lib/mysql/mysql.sock' } } } } - describe 'skip-name-resolve set to an empty string' do - let(:params) {{ :override_options => { 'mysqld' => { 'skip-name-resolve' => '' }}}} - it { is_expected.to contain_file('mysql-config-file').with_content(/^skip-name-resolve$/) } + it do + is_expected.to contain_file('mysql-config-file').with(mode: '0644', + selinux_ignore_defaults: true).with_content(%r{socket = \/var\/lib\/mysql\/mysql.sock}) end + end - describe 'ssl set to true' do - let(:params) {{ :override_options => { 'mysqld' => { 'ssl' => true }}}} - it { is_expected.to contain_file('mysql-config-file').with_content(/ssl/) } - it { is_expected.to contain_file('mysql-config-file').without_content(/ssl = true/) } - end + describe 'array entry' do + let(:params) { { override_options: { 'mysqld' => { 'replicate-do-db' => %w[base1 base2] } } } } - describe 'ssl set to false' do - let(:params) {{ :override_options => { 'mysqld' => { 'ssl' => false }}}} - it { is_expected.to contain_file('mysql-config-file').with_content(/ssl = false/) } + it do + is_expected.to contain_file('mysql-config-file').with_content( + %r{.*replicate-do-db = base1\nreplicate-do-db = base2.*}, + ) end + end - # ssl-disable (and ssl) are special cased within mysql. - describe 'possibility of disabling ssl completely' do - let(:params) {{ :override_options => { 'mysqld' => { 'ssl' => true, 'ssl-disable' => true }}}} - it { is_expected.to contain_file('mysql-config-file').without_content(/ssl = true/) } - end + describe 'skip-name-resolve set to an empty string' do + let(:params) { { override_options: { 'mysqld' => { 'skip-name-resolve' => '' } } } } - describe 'a non ssl option set to true' do - let(:params) {{ :override_options => { 'mysqld' => { 'test' => true }}}} - it { is_expected.to contain_file('mysql-config-file').with_content(/^test$/) } - it { is_expected.to contain_file('mysql-config-file').without_content(/test = true/) } - end + it { is_expected.to contain_file('mysql-config-file').with_content(%r{^skip-name-resolve$}) } + end + + describe 'ssl set to true' do + let(:params) { { override_options: { 'mysqld' => { 'ssl' => true } } } } + + it { is_expected.to contain_file('mysql-config-file').with_content(%r{ssl}) } + it { is_expected.to contain_file('mysql-config-file').without_content(%r{ssl = true}) } + end - context 'with includedir' do - let(:params) {{ :includedir => '/etc/my.cnf.d' }} - it 'makes the directory' do - is_expected.to contain_file('/etc/my.cnf.d').with({ - :ensure => :directory, - :mode => '0755', - }) - end + describe 'ssl set to false' do + let(:params) { { override_options: { 'mysqld' => { 'ssl' => false } } } } - it { is_expected.to contain_file('mysql-config-file').with_content(/!includedir/) } + it { is_expected.to contain_file('mysql-config-file').with_content(%r{ssl = false}) } + end + + # ssl-disable (and ssl) are special cased within mysql. + describe 'possibility of disabling ssl completely' do + let(:params) { { override_options: { 'mysqld' => { 'ssl' => true, 'ssl-disable' => true } } } } + + it { is_expected.to contain_file('mysql-config-file').without_content(%r{ssl = true}) } + end + + describe 'a non ssl option set to true' do + let(:params) { { override_options: { 'mysqld' => { 'test' => true } } } } + + it { is_expected.to contain_file('mysql-config-file').with_content(%r{^test$}) } + it { is_expected.to contain_file('mysql-config-file').without_content(%r{test = true}) } + end + + context 'with includedir' do + let(:params) { { includedir: '/etc/my.cnf.d' } } + + it 'makes the directory' do + is_expected.to contain_file('/etc/my.cnf.d').with(ensure: :directory, + mode: '0755') end - context 'without includedir' do - let(:params) {{ :includedir => '' }} - it 'shouldnt contain the directory' do - is_expected.not_to contain_file('mysql-config-file').with({ - :ensure => :directory, - :mode => '0755', - }) - end + it { is_expected.to contain_file('mysql-config-file').with_content(%r{!includedir}) } + end + + context 'without includedir' do + let(:params) { { includedir: '' } } - it { is_expected.to contain_file('mysql-config-file').without_content(/!includedir/) } + it 'shouldnt contain the directory' do + is_expected.not_to contain_file('mysql-config-file').with(ensure: :directory, + mode: '0755') end + + it { is_expected.to contain_file('mysql-config-file').without_content(%r{!includedir}) } end end end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/spec/classes/mysql_bindings_spec.rb puppet-module-puppetlabs-mysql-5.3.0/spec/classes/mysql_bindings_spec.rb --- puppet-module-puppetlabs-mysql-3.10.0/spec/classes/mysql_bindings_spec.rb 2016-07-27 17:34:11.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/spec/classes/mysql_bindings_spec.rb 2017-10-05 23:11:56.000000000 +0000 @@ -3,23 +3,23 @@ describe 'mysql::bindings' do on_supported_os.each do |os, facts| context "on #{os}" do - let(:facts) { - facts.merge({ - :root_home => '/root', - }) - } + let(:facts) do + facts.merge(root_home: '/root') + end - let(:params) {{ - 'java_enable' => true, - 'perl_enable' => true, - 'php_enable' => true, - 'python_enable' => true, - 'ruby_enable' => true, - 'client_dev' => true, - 'daemon_dev' => true, - 'client_dev_package_name' => 'libmysqlclient-devel', - 'daemon_dev_package_name' => 'mysql-devel', - }} + let(:params) do + { + 'java_enable' => true, + 'perl_enable' => true, + 'php_enable' => true, + 'python_enable' => true, + 'ruby_enable' => true, + 'client_dev' => true, + 'daemon_dev' => true, + 'client_dev_package_name' => 'libmysqlclient-devel', + 'daemon_dev_package_name' => 'mysql-devel', + } + end it { is_expected.to contain_package('mysql-connector-java') } it { is_expected.to contain_package('perl_mysql') } diff -Nru puppet-module-puppetlabs-mysql-3.10.0/spec/classes/mysql_client_spec.rb puppet-module-puppetlabs-mysql-5.3.0/spec/classes/mysql_client_spec.rb --- puppet-module-puppetlabs-mysql-3.10.0/spec/classes/mysql_client_spec.rb 2016-07-27 17:34:11.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/spec/classes/mysql_client_spec.rb 2017-10-05 23:11:56.000000000 +0000 @@ -3,11 +3,9 @@ describe 'mysql::client' do on_supported_os.each do |os, facts| context "on #{os}" do - let(:facts) { - facts.merge({ - :root_home => '/root', - }) - } + let(:facts) do + facts.merge(root_home: '/root') + end context 'with defaults' do it { is_expected.not_to contain_class('mysql::bindings') } @@ -15,24 +13,23 @@ end context 'with bindings enabled' do - let(:params) {{ :bindings_enable => true }} + let(:params) { { bindings_enable: true } } it { is_expected.to contain_class('mysql::bindings') } it { is_expected.to contain_package('mysql_client') } end context 'with package_manage set to true' do - let(:params) {{ :package_manage => true }} + let(:params) { { package_manage: true } } it { is_expected.to contain_package('mysql_client') } end context 'with package_manage set to false' do - let(:params) {{ :package_manage => false }} + let(:params) { { package_manage: false } } it { is_expected.not_to contain_package('mysql_client') } end - end end end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/spec/classes/mysql_server_account_security_spec.rb puppet-module-puppetlabs-mysql-5.3.0/spec/classes/mysql_server_account_security_spec.rb --- puppet-module-puppetlabs-mysql-3.10.0/spec/classes/mysql_server_account_security_spec.rb 2016-07-27 17:34:11.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/spec/classes/mysql_server_account_security_spec.rb 2018-01-19 18:07:36.000000000 +0000 @@ -3,23 +3,26 @@ describe 'mysql::server::account_security' do on_supported_os.each do |os, facts| context "on #{os}" do - context "with fqdn==myhost.mydomain" do - let(:facts) { - facts.merge({ - :root_home => '/root', - :fqdn => 'myhost.mydomain', - :hostname => 'myhost', - }) - } - - [ 'root@myhost.mydomain', - 'root@127.0.0.1', - 'root@::1', - '@myhost.mydomain', - '@localhost', - '@%', - ].each do |user| - it "removes Mysql_User[#{user}]" do + let(:pre_condition) do + <<-EOF + anchor {'mysql::server::end': } + EOF + end + + context 'with fqdn==myhost.mydomain' do + let(:facts) do + facts.merge(root_home: '/root', + fqdn: 'myhost.mydomain', + hostname: 'myhost') + end + + ['root@myhost.mydomain', + 'root@127.0.0.1', + 'root@::1', + '@myhost.mydomain', + '@localhost', + '@%'].each do |user| + it "removes Mysql_User[#{user}]" do # rubocop:disable RSpec/RepeatedExample is_expected.to contain_mysql_user(user).with_ensure('absent') end end @@ -27,56 +30,50 @@ # When the hostname doesn't match the fqdn we also remove these. # We don't need to test the inverse as when they match they are # covered by the above list. - [ 'root@myhost', '@myhost' ].each do |user| - it "removes Mysql_User[#{user}]" do + ['root@myhost', '@myhost'].each do |user| + it "removes Mysql_User[#{user}]" do # rubocop:disable RSpec/RepeatedExample is_expected.to contain_mysql_user(user).with_ensure('absent') end end - it 'should remove Mysql_database[test]' do + it 'removes Mysql_database[test]' do is_expected.to contain_mysql_database('test').with_ensure('absent') end end - context "with fqdn==localhost" do - let(:facts) { - facts.merge({ - :root_home => '/root', - :fqdn => 'localhost', - :hostname => 'localhost', - }) - } - - [ 'root@127.0.0.1', - 'root@::1', - '@localhost', - 'root@localhost.localdomain', - '@localhost.localdomain', - '@%', - ].each do |user| - it "removes Mysql_User[#{user}]" do + context 'with fqdn==localhost' do + let(:facts) do + facts.merge(root_home: '/root', + fqdn: 'localhost', + hostname: 'localhost') + end + + ['root@127.0.0.1', + 'root@::1', + '@localhost', + 'root@localhost.localdomain', + '@localhost.localdomain', + '@%'].each do |user| + it "removes Mysql_User[#{user}] for fqdn==localhost" do is_expected.to contain_mysql_user(user).with_ensure('absent') end end end - context "with fqdn==localhost.localdomain" do - let(:facts) { - facts.merge({ - :root_home => '/root', - :fqdn => 'localhost.localdomain', - :hostname => 'localhost', - }) - } - - [ 'root@127.0.0.1', - 'root@::1', - '@localhost', - 'root@localhost.localdomain', - '@localhost.localdomain', - '@%', - ].each do |user| - it "removes Mysql_User[#{user}]" do + context 'with fqdn==localhost.localdomain' do + let(:facts) do + facts.merge(root_home: '/root', + fqdn: 'localhost.localdomain', + hostname: 'localhost') + end + + ['root@127.0.0.1', + 'root@::1', + '@localhost', + 'root@localhost.localdomain', + '@localhost.localdomain', + '@%'].each do |user| + it "removes Mysql_User[#{user}] for fqdn==localhost.localdomain" do is_expected.to contain_mysql_user(user).with_ensure('absent') end end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/spec/classes/mysql_server_backup_spec.rb puppet-module-puppetlabs-mysql-5.3.0/spec/classes/mysql_server_backup_spec.rb --- puppet-module-puppetlabs-mysql-3.10.0/spec/classes/mysql_server_backup_spec.rb 2016-09-06 22:04:13.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/spec/classes/mysql_server_backup_spec.rb 2018-02-20 14:54:26.000000000 +0000 @@ -3,229 +3,240 @@ describe 'mysql::server::backup' do on_supported_os.each do |os, facts| context "on #{os}" do - let(:facts) { - facts.merge({ - :root_home => '/root', - }) - } + let(:pre_condition) do + <<-EOF + class { 'mysql::server': } + EOF + end + let(:facts) do + facts.merge(root_home: '/root') + end - let(:default_params) { + let(:default_params) do { 'backupuser' => 'testuser', 'backuppassword' => 'testpass', - 'maxallowedpacket' => '1M', 'backupdir' => '/tmp', 'backuprotate' => '25', 'delete_before_dump' => true, 'execpath' => '/usr/bin:/usr/sbin:/bin:/sbin:/opt/zimbra/bin', - 'maxallowedpacket' => '1M', - } - } + 'maxallowedpacket' => '1M' } + end context 'standard conditions' do let(:params) { default_params } # Cannot use that_requires here, doesn't work on classes. - it { is_expected.to contain_mysql_user('testuser@localhost').with( - :require => 'Class[Mysql::Server::Root_password]') } + it { + is_expected.to contain_mysql_user('testuser@localhost').with( + require: 'Class[Mysql::Server::Root_password]', + ) + } - it { is_expected.to contain_mysql_grant('testuser@localhost/*.*').with( - :privileges => ['SELECT', 'RELOAD', 'LOCK TABLES', 'SHOW VIEW', 'PROCESS'] - ).that_requires('Mysql_user[testuser@localhost]') } + it { + is_expected.to contain_mysql_grant('testuser@localhost/*.*').with( + privileges: ['SELECT', 'RELOAD', 'LOCK TABLES', 'SHOW VIEW', 'PROCESS'], + ).that_requires('Mysql_user[testuser@localhost]') + } context 'with triggers included' do let(:params) do - { :include_triggers => true }.merge(default_params) + { include_triggers: true }.merge(default_params) end - it { is_expected.to contain_mysql_grant('testuser@localhost/*.*').with( - :privileges => ['SELECT', 'RELOAD', 'LOCK TABLES', 'SHOW VIEW', 'PROCESS', 'TRIGGER'] - ).that_requires('Mysql_user[testuser@localhost]') } + + it { + is_expected.to contain_mysql_grant('testuser@localhost/*.*').with( + privileges: ['SELECT', 'RELOAD', 'LOCK TABLES', 'SHOW VIEW', 'PROCESS', 'TRIGGER'], + ).that_requires('Mysql_user[testuser@localhost]') + } end - it { is_expected.to contain_cron('mysql-backup').with( - :command => '/usr/local/sbin/mysqlbackup.sh', - :ensure => 'present' - )} + it { + is_expected.to contain_cron('mysql-backup').with( + command: '/usr/local/sbin/mysqlbackup.sh', + ensure: 'present', + ) + } - it { is_expected.to contain_file('mysqlbackup.sh').with( - :path => '/usr/local/sbin/mysqlbackup.sh', - :ensure => 'present' - ) } + it { + is_expected.to contain_file('mysqlbackup.sh').with( + path: '/usr/local/sbin/mysqlbackup.sh', + ensure: 'present', + ) + } - it { is_expected.to contain_file('mysqlbackupdir').with( - :path => '/tmp', - :ensure => 'directory' - )} + it { + is_expected.to contain_file('mysqlbackupdir').with( + path: '/tmp', + ensure: 'directory', + ) + } - it 'should have compression by default' do + it 'has compression by default' do is_expected.to contain_file('mysqlbackup.sh').with_content( - /bzcat -zc/ + %r{bzcat -zc}, ) end - it 'should skip backing up events table by default' do + it 'skips backing up events table by default' do is_expected.to contain_file('mysqlbackup.sh').with_content( - /ADDITIONAL_OPTIONS="--ignore-table=mysql.event"/ + %r{ADDITIONAL_OPTIONS="--ignore-table=mysql.event"}, ) end - it 'should not mention triggers by default because file_per_database is false' do + it 'does not mention triggers by default because file_per_database is false' do is_expected.to contain_file('mysqlbackup.sh').without_content( - /.*triggers.*/ + %r{.*triggers.*}, ) end - it 'should not mention routines by default because file_per_database is false' do + it 'does not mention routines by default because file_per_database is false' do is_expected.to contain_file('mysqlbackup.sh').without_content( - /.*routines.*/ + %r{.*routines.*}, ) end - it 'should have 25 days of rotation' do + it 'has 25 days of rotation' do # MySQL counts from 0 - is_expected.to contain_file('mysqlbackup.sh').with_content(/.*ROTATE=24.*/) + is_expected.to contain_file('mysqlbackup.sh').with_content(%r{.*ROTATE=24.*}) end - it 'should have a standard PATH' do + it 'has a standard PATH' do is_expected.to contain_file('mysqlbackup.sh').with_content(%r{PATH=/usr/bin:/usr/sbin:/bin:/sbin:/opt/zimbra/bin}) end end context 'custom ownership and mode for backupdir' do let(:params) do - { :backupdirmode => '0750', - :backupdirowner => 'testuser', - :backupdirgroup => 'testgrp', - }.merge(default_params) + { backupdirmode: '0750', + backupdirowner: 'testuser', + backupdirgroup: 'testgrp' }.merge(default_params) end - it { is_expected.to contain_file('mysqlbackupdir').with( - :path => '/tmp', - :ensure => 'directory', - :mode => '0750', - :owner => 'testuser', - :group => 'testgrp' - ) } + it { + is_expected.to contain_file('mysqlbackupdir').with( + path: '/tmp', ensure: 'directory', + mode: '0750', owner: 'testuser', + group: 'testgrp' + ) + } end context 'with compression disabled' do let(:params) do - { :backupcompress => false }.merge(default_params) + { backupcompress: false }.merge(default_params) end - it { is_expected.to contain_file('mysqlbackup.sh').with( - :path => '/usr/local/sbin/mysqlbackup.sh', - :ensure => 'present' - ) } + it { + is_expected.to contain_file('mysqlbackup.sh').with( + path: '/usr/local/sbin/mysqlbackup.sh', + ensure: 'present', + ) + } - it 'should be able to disable compression' do + it 'is able to disable compression' do is_expected.to contain_file('mysqlbackup.sh').without_content( - /.*bzcat -zc.*/ + %r{.*bzcat -zc.*}, ) end end context 'with mysql.events backedup' do let(:params) do - { :ignore_events => false }.merge(default_params) + { ignore_events: false }.merge(default_params) end - it { is_expected.to contain_file('mysqlbackup.sh').with( - :path => '/usr/local/sbin/mysqlbackup.sh', - :ensure => 'present' - ) } + it { + is_expected.to contain_file('mysqlbackup.sh').with( + path: '/usr/local/sbin/mysqlbackup.sh', + ensure: 'present', + ) + } - it 'should be able to backup events table' do + it 'is able to backup events table' do is_expected.to contain_file('mysqlbackup.sh').with_content( - /ADDITIONAL_OPTIONS="--events"/ + %r{ADDITIONAL_OPTIONS="--events"}, ) end end context 'with database list specified' do let(:params) do - { :backupdatabases => ['mysql'] }.merge(default_params) + { backupdatabases: ['mysql'] }.merge(default_params) end - it { is_expected.to contain_file('mysqlbackup.sh').with( - :path => '/usr/local/sbin/mysqlbackup.sh', - :ensure => 'present' + it { + is_expected.to contain_file('mysqlbackup.sh').with( + path: '/usr/local/sbin/mysqlbackup.sh', + ensure: 'present', ) } - it 'should have a backup file for each database' do + it 'has a backup file for each database' do is_expected.to contain_file('mysqlbackup.sh').with_content( - /mysql | bzcat -zc \${DIR}\\\${PREFIX}mysql_`date'/ + %r{mysql | bzcat -zc \${DIR}\\\${PREFIX}mysql_`date'}, ) end - it 'should skip backup triggers by default' do + it 'skips backup triggers by default' do is_expected.to contain_file('mysqlbackup.sh').with_content( - /ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --skip-triggers"/ + %r{ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --skip-triggers"}, ) end - it 'should skip backing up routines by default' do + it 'skips backing up routines by default' do is_expected.to contain_file('mysqlbackup.sh').with_content( - /ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --skip-routines"/ + %r{ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --skip-routines"}, ) end context 'with include_triggers set to true' do let(:params) do - default_params.merge({ - :backupdatabases => ['mysql'], - :include_triggers => true - }) + default_params.merge(backupdatabases: ['mysql'], + include_triggers: true) end - it 'should backup triggers when asked' do + it 'backups triggers when asked' do is_expected.to contain_file('mysqlbackup.sh').with_content( - /ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --triggers"/ + %r{ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --triggers"}, ) end end context 'with include_triggers set to false' do let(:params) do - default_params.merge({ - :backupdatabases => ['mysql'], - :include_triggers => false - }) + default_params.merge(backupdatabases: ['mysql'], + include_triggers: false) end - it 'should skip backing up triggers when asked to skip' do + it 'skips backing up triggers when asked to skip' do is_expected.to contain_file('mysqlbackup.sh').with_content( - /ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --skip-triggers"/ + %r{ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --skip-triggers"}, ) end end context 'with include_routines set to true' do let(:params) do - default_params.merge({ - :backupdatabases => ['mysql'], - :include_routines => true - }) + default_params.merge(backupdatabases: ['mysql'], + include_routines: true) end - it 'should backup routines when asked' do + it 'backups routines when asked' do is_expected.to contain_file('mysqlbackup.sh').with_content( - /ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --routines"/ + %r{ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --routines"}, ) end end context 'with include_routines set to false' do let(:params) do - default_params.merge({ - :backupdatabases => ['mysql'], - :include_triggers => true - }) + default_params.merge(backupdatabases: ['mysql'], + include_triggers: true) end - it 'should skip backing up routines when asked to skip' do + it 'skips backing up routines when asked to skip' do is_expected.to contain_file('mysqlbackup.sh').with_content( - /ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --skip-routines"/ + %r{ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --skip-routines"}, ) end end @@ -233,96 +244,86 @@ context 'with file per database' do let(:params) do - default_params.merge({ :file_per_database => true }) + default_params.merge(file_per_database: true) end - it 'should loop through backup all databases' do - is_expected.to contain_file('mysqlbackup.sh').with_content(/.*SHOW DATABASES.*/) + it 'loops through backup all databases' do + is_expected.to contain_file('mysqlbackup.sh').with_content(%r{.*SHOW DATABASES.*}) end context 'with compression disabled' do let(:params) do - default_params.merge({ :file_per_database => true, :backupcompress => false }) + default_params.merge(file_per_database: true, backupcompress: false) end - it 'should loop through backup all databases without compression' do - is_expected.to contain_file('mysqlbackup.sh').with_content( - /.*SHOW DATABASES.*/ - ) - is_expected.to contain_file('mysqlbackup.sh').without_content( - /.*bzcat -zc.*/ - ) + it 'loops through backup all databases without compression #show databases' do + is_expected.to contain_file('mysqlbackup.sh').with_content(%r{.*SHOW DATABASES.*}) + end + it 'loops through backup all databases without compression #bzcat' do + is_expected.to contain_file('mysqlbackup.sh').without_content(%r{.*bzcat -zc.*}) end end - it 'should skip backup triggers by default' do + it 'skips backup triggers by default' do is_expected.to contain_file('mysqlbackup.sh').with_content( - /ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --skip-triggers"/ + %r{ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --skip-triggers"}, ) end - it 'should skip backing up routines by default' do + it 'skips backing up routines by default' do is_expected.to contain_file('mysqlbackup.sh').with_content( - /ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --skip-routines"/ + %r{ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --skip-routines"}, ) end context 'with include_triggers set to true' do let(:params) do - default_params.merge({ - :file_per_database => true, - :include_triggers => true - }) + default_params.merge(file_per_database: true, + include_triggers: true) end - it 'should backup triggers when asked' do + it 'backups triggers when asked' do is_expected.to contain_file('mysqlbackup.sh').with_content( - /ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --triggers"/ + %r{ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --triggers"}, ) end end context 'with include_triggers set to false' do let(:params) do - default_params.merge({ - :file_per_database => true, - :include_triggers => false - }) + default_params.merge(file_per_database: true, + include_triggers: false) end - it 'should skip backing up triggers when asked to skip' do + it 'skips backing up triggers when asked to skip' do is_expected.to contain_file('mysqlbackup.sh').with_content( - /ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --skip-triggers"/ + %r{ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --skip-triggers"}, ) end end context 'with include_routines set to true' do let(:params) do - default_params.merge({ - :file_per_database => true, - :include_routines => true - }) + default_params.merge(file_per_database: true, + include_routines: true) end - it 'should backup routines when asked' do + it 'backups routines when asked' do is_expected.to contain_file('mysqlbackup.sh').with_content( - /ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --routines"/ + %r{ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --routines"}, ) end end context 'with include_routines set to false' do let(:params) do - default_params.merge({ - :file_per_database => true, - :include_triggers => true - }) + default_params.merge(file_per_database: true, + include_triggers: true) end - it 'should skip backing up routines when asked to skip' do + it 'skips backing up routines when asked to skip' do is_expected.to contain_file('mysqlbackup.sh').with_content( - /ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --skip-routines"/ + %r{ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --skip-routines"}, ) end end @@ -330,78 +331,75 @@ context 'with postscript' do let(:params) do - default_params.merge({ :postscript => 'rsync -a /tmp backup01.local-lan:' }) + default_params.merge(postscript: 'rsync -a /tmp backup01.local-lan:') end - it 'should be add postscript' do + it 'is add postscript' do is_expected.to contain_file('mysqlbackup.sh').with_content( - /rsync -a \/tmp backup01.local-lan:/ + %r{rsync -a \/tmp backup01.local-lan:}, ) end end context 'with postscripts' do let(:params) do - default_params.merge({ :postscript => [ - 'rsync -a /tmp backup01.local-lan:', - 'rsync -a /tmp backup02.local-lan:', - ]}) + default_params.merge(postscript: [ + 'rsync -a /tmp backup01.local-lan:', + 'rsync -a /tmp backup02.local-lan:', + ]) end - it 'should be add postscript' do + it 'is add postscript' do is_expected.to contain_file('mysqlbackup.sh').with_content( - /.*rsync -a \/tmp backup01.local-lan:\n\nrsync -a \/tmp backup02.local-lan:.*/ + %r{.*rsync -a \/tmp backup01.local-lan:\n\nrsync -a \/tmp backup02.local-lan:.*}, ) end end context 'with the xtrabackup provider' do let(:params) do - default_params.merge({:provider => 'xtrabackup'}) + default_params.merge(provider: 'xtrabackup') end - it 'should contain the wrapper script' do + it 'contains the wrapper script' do is_expected.to contain_file('xtrabackup.sh').with_content( - /^innobackupex\s+"\$@"/ + %r{^innobackupex\s+.*?"\$@"}, ) end context 'with prescript defined' do let(:params) do - default_params.merge({ - :provider => 'xtrabackup', - :prescript => [ - 'rsync -a /tmp backup01.local-lan:', - 'rsync -a /tmp backup02.local-lan:', - ] - }) + default_params.merge(provider: 'xtrabackup', + prescript: [ + 'rsync -a /tmp backup01.local-lan:', + 'rsync -a /tmp backup02.local-lan:', + ]) end - it 'should contain the prescript' do + it 'contains the prescript' do is_expected.to contain_file('xtrabackup.sh').with_content( - /.*rsync -a \/tmp backup01.local-lan:\n\nrsync -a \/tmp backup02.local-lan:.*/ + %r{.*rsync -a \/tmp backup01.local-lan:\n\nrsync -a \/tmp backup02.local-lan:.*}, ) end end context 'with postscript defined' do let(:params) do - default_params.merge({ - :provider => 'xtrabackup', - :postscript => [ - 'rsync -a /tmp backup01.local-lan:', - 'rsync -a /tmp backup02.local-lan:', - ] - }) + default_params.merge(provider: 'xtrabackup', + postscript: [ + 'rsync -a /tmp backup01.local-lan:', + 'rsync -a /tmp backup02.local-lan:', + ]) end - it 'should contain the prostscript' do + it 'contains the prostscript' do is_expected.to contain_file('xtrabackup.sh').with_content( - /.*rsync -a \/tmp backup01.local-lan:\n\nrsync -a \/tmp backup02.local-lan:.*/ + %r{.*rsync -a \/tmp backup01.local-lan:\n\nrsync -a \/tmp backup02.local-lan:.*}, ) end end end end end + # rubocop:enable RSpec/NestedGroups end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/spec/classes/mysql_server_monitor_spec.rb puppet-module-puppetlabs-mysql-5.3.0/spec/classes/mysql_server_monitor_spec.rb --- puppet-module-puppetlabs-mysql-3.10.0/spec/classes/mysql_server_monitor_spec.rb 2016-07-27 17:34:11.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/spec/classes/mysql_server_monitor_spec.rb 2018-01-19 18:07:36.000000000 +0000 @@ -2,11 +2,9 @@ describe 'mysql::server::monitor' do on_supported_os.each do |os, facts| context "on #{os}" do - let(:facts) { - facts.merge({ - :root_home => '/root', - }) - } + let(:facts) do + facts.merge(root_home: '/root') + end let :pre_condition do "include 'mysql::server'" @@ -14,9 +12,9 @@ let :default_params do { - :mysql_monitor_username => 'monitoruser', - :mysql_monitor_password => 'monitorpass', - :mysql_monitor_hostname => 'monitorhost', + mysql_monitor_username: 'monitoruser', + mysql_monitor_password: 'monitorpass', + mysql_monitor_hostname: 'monitorhost', } end @@ -24,15 +22,15 @@ default_params end - it { is_expected.to contain_mysql_user('monitoruser@monitorhost')} + it { is_expected.to contain_mysql_user('monitoruser@monitorhost') } - it { is_expected.to contain_mysql_grant('monitoruser@monitorhost/*.*').with( - :ensure => 'present', - :user => 'monitoruser@monitorhost', - :table => '*.*', - :privileges => ["PROCESS", "SUPER"], - :require => 'Mysql_user[monitoruser@monitorhost]' - )} + it { + is_expected.to contain_mysql_grant('monitoruser@monitorhost/*.*').with( + ensure: 'present', user: 'monitoruser@monitorhost', + table: '*.*', privileges: %w[PROCESS SUPER], + require: 'Mysql_user[monitoruser@monitorhost]' + ) + } end end end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/spec/classes/mysql_server_mysqltuner_spec.rb puppet-module-puppetlabs-mysql-5.3.0/spec/classes/mysql_server_mysqltuner_spec.rb --- puppet-module-puppetlabs-mysql-3.10.0/spec/classes/mysql_server_mysqltuner_spec.rb 2016-07-27 17:34:11.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/spec/classes/mysql_server_mysqltuner_spec.rb 2017-10-05 23:11:56.000000000 +0000 @@ -3,42 +3,40 @@ describe 'mysql::server::mysqltuner' do on_supported_os.each do |os, facts| context "on #{os}" do - let(:facts) { - facts.merge({ - :staging_http_get => 'curl', - :root_home => '/root', - }) - } + let(:facts) do + facts.merge(staging_http_get: 'curl', + root_home: '/root') + end context 'ensure => present' do it { is_expected.to compile } - it { is_expected.to contain_staging__file('mysqltuner-v1.3.0').with({ - :source => 'https://github.com/major/MySQLTuner-perl/raw/v1.3.0/mysqltuner.pl', - }) + it { + is_expected.to contain_staging__file('mysqltuner-v1.3.0').with(source: 'https://github.com/major/MySQLTuner-perl/raw/v1.3.0/mysqltuner.pl') } end context 'ensure => absent' do - let(:params) {{ :ensure => 'absent' }} + let(:params) { { ensure: 'absent' } } + it { is_expected.to compile } - it { is_expected.to contain_file('/usr/local/bin/mysqltuner').with(:ensure => 'absent') } + it { is_expected.to contain_file('/usr/local/bin/mysqltuner').with(ensure: 'absent') } end context 'custom version' do - let(:params) {{ :version => 'v1.2.0' }} + let(:params) { { version: 'v1.2.0' } } + it { is_expected.to compile } - it { is_expected.to contain_staging__file('mysqltuner-v1.2.0').with({ - :source => 'https://github.com/major/MySQLTuner-perl/raw/v1.2.0/mysqltuner.pl', - }) + it { + is_expected.to contain_staging__file('mysqltuner-v1.2.0').with(source: 'https://github.com/major/MySQLTuner-perl/raw/v1.2.0/mysqltuner.pl') } end context 'custom source' do - let(:params) {{ :source => '/tmp/foo' }} + let(:params) { { source: '/tmp/foo' } } + it { is_expected.to compile } - it { is_expected.to contain_staging__file('mysqltuner-/tmp/foo').with({ - :source => '/tmp/foo', - }) + it { + is_expected.to contain_staging__file('mysqltuner-/tmp/foo').with(source: '/tmp/foo') } end end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/spec/classes/mysql_server_spec.rb puppet-module-puppetlabs-mysql-5.3.0/spec/classes/mysql_server_spec.rb --- puppet-module-puppetlabs-mysql-3.10.0/spec/classes/mysql_server_spec.rb 2016-09-06 22:04:13.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/spec/classes/mysql_server_spec.rb 2018-02-20 14:54:26.000000000 +0000 @@ -3,11 +3,9 @@ describe 'mysql::server' do on_supported_os.each do |os, facts| context "on #{os}" do - let(:facts) { - facts.merge({ - :root_home => '/root', - }) - } + let(:facts) do + facts.merge(root_home: '/root') + end context 'with defaults' do it { is_expected.to contain_class('mysql::server::install') } @@ -18,37 +16,41 @@ end context 'with remove_default_accounts set' do - let(:params) {{ :remove_default_accounts => true }} + let(:params) { { remove_default_accounts: true } } + it { is_expected.to contain_class('mysql::server::account_security') } end context 'when not managing config file' do - let(:params) {{ :manage_config_file => false }} + let(:params) { { manage_config_file: false } } + it { is_expected.to compile.with_all_deps } end context 'when not managing the service' do - let(:params) {{ :service_manage => false }} + let(:params) { { service_manage: false } } + it { is_expected.to compile.with_all_deps } it { is_expected.not_to contain_service('mysqld') } end context 'mysql::server::install' do it 'contains the package by default' do - is_expected.to contain_package('mysql-server').with({ - :ensure => :present, - }) + is_expected.to contain_package('mysql-server').with(ensure: :present) end context 'with package_manage set to true' do - let(:params) {{ :package_manage => true }} + let(:params) { { package_manage: true } } + it { is_expected.to contain_package('mysql-server') } end context 'with package_manage set to false' do - let(:params) {{ :package_manage => false }} + let(:params) { { package_manage: false } } + it { is_expected.not_to contain_package('mysql-server') } end context 'with datadir overridden' do - let(:params) {{ :override_options => { 'mysqld' => { 'datadir' => '/tmp' }} }} + let(:params) { { override_options: { 'mysqld' => { 'datadir' => '/tmp' } } } } + it { is_expected.to contain_mysql_datadir('/tmp') } end end @@ -58,87 +60,109 @@ it { is_expected.to contain_service('mysqld') } end context 'with package_manage set to true' do - let(:params) {{ :package_manage => true }} + let(:params) { { package_manage: true } } + it { is_expected.to contain_service('mysqld').that_requires('Package[mysql-server]') } end context 'with package_manage set to false' do - let(:params) {{ :package_manage => false }} + let(:params) { { package_manage: false } } + it { is_expected.to contain_service('mysqld') } it { is_expected.not_to contain_service('mysqld').that_requires('Package[mysql-server]') } end context 'service_enabled set to false' do - let(:params) {{ :service_enabled => false }} + let(:params) { { service_enabled: false } } it do - is_expected.to contain_service('mysqld').with({ - :ensure => :stopped - }) + is_expected.to contain_service('mysqld').with(ensure: :stopped) end context 'with package_manage set to true' do - let(:params) {{ :package_manage => true }} + let(:params) { { package_manage: true } } + it { is_expected.to contain_package('mysql-server') } end context 'with package_manage set to false' do - let(:params) {{ :package_manage => false }} + let(:params) { { package_manage: false } } + it { is_expected.not_to contain_package('mysql-server') } end context 'with datadir overridden' do - let(:params) {{ :override_options => { 'mysqld' => { 'datadir' => '/tmp' }} }} + let(:params) { { override_options: { 'mysqld' => { 'datadir' => '/tmp' } } } } + it { is_expected.to contain_mysql_datadir('/tmp') } end end context 'with log-error overridden' do - let(:params) {{ :override_options => { 'mysqld' => { 'log-error' => '/tmp/error.log' }} }} + let(:params) { { override_options: { 'mysqld' => { 'log-error' => '/tmp/error.log' } } } } + it { is_expected.to contain_file('/tmp/error.log') } end + context 'default bind-address' do + it { is_expected.to contain_file('mysql-config-file').with_content(%r{^bind-address = 127.0.0.1}) } + end + context 'with defined bind-address' do + let(:params) { { override_options: { 'mysqld' => { 'bind-address' => '1.1.1.1' } } } } + + it { is_expected.to contain_file('mysql-config-file').with_content(%r{^bind-address = 1.1.1.1}) } + end + context 'without bind-address' do + let(:params) { { override_options: { 'mysqld' => { 'bind-address' => :undef } } } } + + it { is_expected.to contain_file('mysql-config-file').without_content(%r{^bind-address}) } + end end context 'mysql::server::root_password' do describe 'when defaults' do it { - is_expected.to contain_exec('remove install pass').with( - :command => 'mysqladmin -u root --password=$(grep -o \'[^ ]\\+$\' /.mysql_secret) password \'\' && rm -f /.mysql_secret', - :onlyif => 'test -f /.mysql_secret', - :path => '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin' - ) - } + is_expected.to contain_exec('remove install pass').with( + command: 'mysqladmin -u root --password=$(grep -o \'[^ ]\\+$\' /.mysql_secret) password \'\' && rm -f /.mysql_secret', + onlyif: 'test -f /.mysql_secret', + path: '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin', + ) + } it { is_expected.not_to contain_mysql_user('root@localhost') } it { is_expected.not_to contain_file('/root/.my.cnf') } end describe 'when root_password set' do - let(:params) {{:root_password => 'SET' }} + let(:params) { { root_password: 'SET' } } + it { is_expected.to contain_mysql_user('root@localhost') } if Puppet.version.to_f >= 3.0 - it { is_expected.to contain_file('/root/.my.cnf').with(:show_diff => false).that_requires('Mysql_user[root@localhost]') } + it { is_expected.to contain_file('/root/.my.cnf').with(show_diff: false).that_requires('Mysql_user[root@localhost]') } else it { is_expected.to contain_file('/root/.my.cnf').that_requires('Mysql_user[root@localhost]') } end end describe 'when root_password set, create_root_user set to false' do - let(:params) {{ :root_password => 'SET', :create_root_user => false }} + let(:params) { { root_password: 'SET', create_root_user: false } } + it { is_expected.not_to contain_mysql_user('root@localhost') } if Puppet.version.to_f >= 3.0 - it { is_expected.to contain_file('/root/.my.cnf').with(:show_diff => false) } + it { is_expected.to contain_file('/root/.my.cnf').with(show_diff: false) } else it { is_expected.to contain_file('/root/.my.cnf') } end end describe 'when root_password set, create_root_my_cnf set to false' do - let(:params) {{ :root_password => 'SET', :create_root_my_cnf => false }} + let(:params) { { root_password: 'SET', create_root_my_cnf: false } } + it { is_expected.to contain_mysql_user('root@localhost') } it { is_expected.not_to contain_file('/root/.my.cnf') } end describe 'when root_password set, create_root_user and create_root_my_cnf set to false' do - let(:params) {{ :root_password => 'SET', :create_root_user => false, :create_root_my_cnf => false }} + let(:params) { { root_password: 'SET', create_root_user: false, create_root_my_cnf: false } } + it { is_expected.not_to contain_mysql_user('root@localhost') } it { is_expected.not_to contain_file('/root/.my.cnf') } end describe 'when install_secret_file set to /root/.mysql_secret' do - let(:params) {{ :install_secret_file => '/root/.mysql_secret' }} + let(:params) { { install_secret_file: '/root/.mysql_secret' } } + it { is_expected.to contain_exec('remove install pass').with( - :command => 'mysqladmin -u root --password=$(grep -o \'[^ ]\\+$\' /root/.mysql_secret) password \'\' && rm -f /root/.mysql_secret', - :onlyif => 'test -f /root/.mysql_secret' + command: 'mysqladmin -u root --password=$(grep -o \'[^ ]\\+$\' /root/.mysql_secret) password \'\' && rm -f /root/.mysql_secret', + onlyif: 'test -f /root/.mysql_secret', ) } end @@ -146,75 +170,87 @@ context 'mysql::server::providers' do describe 'with users' do - let(:params) {{:users => { - 'foo@localhost' => { - 'max_connections_per_hour' => '1', - 'max_queries_per_hour' => '2', - 'max_updates_per_hour' => '3', - 'max_user_connections' => '4', - 'password_hash' => '*F3A2A51A9B0F2BE2468926B4132313728C250DBF' - }, - 'foo2@localhost' => {} - }}} - it { is_expected.to contain_mysql_user('foo@localhost').with( - :max_connections_per_hour => '1', - :max_queries_per_hour => '2', - :max_updates_per_hour => '3', - :max_user_connections => '4', - :password_hash => '*F3A2A51A9B0F2BE2468926B4132313728C250DBF' - )} - it { is_expected.to contain_mysql_user('foo2@localhost').with( - :max_connections_per_hour => nil, - :max_queries_per_hour => nil, - :max_updates_per_hour => nil, - :max_user_connections => nil, - :password_hash => nil - )} + let(:params) do + { users: { + 'foo@localhost' => { + 'max_connections_per_hour' => '1', + 'max_queries_per_hour' => '2', + 'max_updates_per_hour' => '3', + 'max_user_connections' => '4', + 'password_hash' => '*F3A2A51A9B0F2BE2468926B4132313728C250DBF', + }, + 'foo2@localhost' => {}, + } } + end + + it { + is_expected.to contain_mysql_user('foo@localhost').with( + max_connections_per_hour: '1', max_queries_per_hour: '2', + max_updates_per_hour: '3', max_user_connections: '4', + password_hash: '*F3A2A51A9B0F2BE2468926B4132313728C250DBF' + ) + } + it { + is_expected.to contain_mysql_user('foo2@localhost').with( + max_connections_per_hour: nil, max_queries_per_hour: nil, + max_updates_per_hour: nil, max_user_connections: nil, + password_hash: nil + ) + } end describe 'with grants' do - let(:params) {{:grants => { - 'foo@localhost/somedb.*' => { - 'user' => 'foo@localhost', - 'table' => 'somedb.*', - 'privileges' => ["SELECT", "UPDATE"], - 'options' => ["GRANT"], - }, - 'foo2@localhost/*.*' => { - 'user' => 'foo2@localhost', - 'table' => '*.*', - 'privileges' => ["SELECT"], - }, - }}} - it { is_expected.to contain_mysql_grant('foo@localhost/somedb.*').with( - :user => 'foo@localhost', - :table => 'somedb.*', - :privileges => ["SELECT", "UPDATE"], - :options => ["GRANT"] - )} - it { is_expected.to contain_mysql_grant('foo2@localhost/*.*').with( - :user => 'foo2@localhost', - :table => '*.*', - :privileges => ["SELECT"], - :options => nil - )} + let(:params) do + { grants: { + 'foo@localhost/somedb.*' => { + 'user' => 'foo@localhost', + 'table' => 'somedb.*', + 'privileges' => %w[SELECT UPDATE], + 'options' => ['GRANT'], + }, + 'foo2@localhost/*.*' => { + 'user' => 'foo2@localhost', + 'table' => '*.*', + 'privileges' => ['SELECT'], + }, + } } + end + + it { + is_expected.to contain_mysql_grant('foo@localhost/somedb.*').with( + user: 'foo@localhost', table: 'somedb.*', + privileges: %w[SELECT UPDATE], options: ['GRANT'] + ) + } + it { + is_expected.to contain_mysql_grant('foo2@localhost/*.*').with( + user: 'foo2@localhost', table: '*.*', + privileges: ['SELECT'], options: nil + ) + } end describe 'with databases' do - let(:params) {{:databases => { - 'somedb' => { - 'charset' => 'latin1', - 'collate' => 'latin1', - }, - 'somedb2' => {} - }}} - it { is_expected.to contain_mysql_database('somedb').with( - :charset => 'latin1', - :collate => 'latin1' - )} - it { is_expected.to contain_mysql_database('somedb2')} + let(:params) do + { databases: { + 'somedb' => { + 'charset' => 'latin1', + 'collate' => 'latin1', + }, + 'somedb2' => {}, + } } + end + + it { + is_expected.to contain_mysql_database('somedb').with( + charset: 'latin1', + collate: 'latin1', + ) + } + it { is_expected.to contain_mysql_database('somedb2') } end end end end + # rubocop:enable RSpec/NestedGroups end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/spec/default_facts.yml puppet-module-puppetlabs-mysql-5.3.0/spec/default_facts.yml --- puppet-module-puppetlabs-mysql-3.10.0/spec/default_facts.yml 1970-01-01 00:00:00.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/spec/default_facts.yml 2018-02-20 14:54:26.000000000 +0000 @@ -0,0 +1,8 @@ +# Use default_module_facts.yml for module specific facts. +# +# Facts specified here will override the values provided by rspec-puppet-facts. +--- +concat_basedir: "/tmp" +ipaddress: "172.16.254.254" +is_pe: false +macaddress: "AA:AA:AA:AA:AA:AA" diff -Nru puppet-module-puppetlabs-mysql-3.10.0/spec/defines/mysql_db_spec.rb puppet-module-puppetlabs-mysql-5.3.0/spec/defines/mysql_db_spec.rb --- puppet-module-puppetlabs-mysql-3.10.0/spec/defines/mysql_db_spec.rb 2016-11-07 20:14:07.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/spec/defines/mysql_db_spec.rb 2018-01-19 18:07:36.000000000 +0000 @@ -1,81 +1,73 @@ require 'spec_helper' -describe 'mysql::db', :type => :define do +describe 'mysql::db', type: :define do on_supported_os.each do |os, facts| context "on #{os}" do - let(:facts) { - facts.merge({ - :root_home => '/root', - }) - } + let(:facts) do + facts.merge(root_home: '/root') + end let(:title) { 'test_db' } - let(:params) { + let(:params) do { 'user' => 'testuser', - 'password' => 'testpass', - } - } - - it 'should report an error when ensure is not present or absent' do - params.merge!({'ensure' => 'invalid_val'}) - expect { catalogue }.to raise_error(Puppet::Error, - /invalid_val is not supported for ensure\. Allowed values are 'present' and 'absent'\./) + 'password' => 'testpass' } end - it 'should not notify the import sql exec if no sql script was provided' do + it 'does not notify the import sql exec if no sql script was provided' do is_expected.to contain_mysql_database('test_db').without_notify end - it 'should subscribe to database if sql script is given' do - params.merge!({'sql' => 'test_sql'}) + it 'subscribes to database if sql script is given' do + params['sql'] = 'test_sql' is_expected.to contain_exec('test_db-import').with_subscribe('Mysql_database[test_db]') end - it 'should only import sql script on creation if not enforcing' do - params.merge!({'sql' => 'test_sql', 'enforce_sql' => false}) + it 'onlies import sql script on creation if not enforcing' do + params.merge!('sql' => 'test_sql', 'enforce_sql' => false) is_expected.to contain_exec('test_db-import').with_refreshonly(true) end - it 'should import sql script on creation if enforcing' do - params.merge!({'sql' => 'test_sql', 'enforce_sql' => true}) + it 'imports sql script on creation if enforcing #refreshonly' do + params.merge!('sql' => 'test_sql', 'enforce_sql' => true) is_expected.to contain_exec('test_db-import').with_refreshonly(false) + end + it 'imports sql script on creation if enforcing #command' do + params.merge!('sql' => 'test_sql', 'enforce_sql' => true) is_expected.to contain_exec('test_db-import').with_command('cat test_sql | mysql test_db') end - it 'should import sql script with custom command on creation if enforcing' do - params.merge!({'sql' => 'test_sql', 'enforce_sql' => true, 'import_cat_cmd' => 'zcat'}) + it 'imports sql script with custom command on creation if enforcing #refreshonly' do + params.merge!('sql' => 'test_sql', 'enforce_sql' => true, 'import_cat_cmd' => 'zcat') is_expected.to contain_exec('test_db-import').with_refreshonly(false) + end + it 'imports sql script with custom command on creation if enforcing #command' do + params.merge!('sql' => 'test_sql', 'enforce_sql' => true, 'import_cat_cmd' => 'zcat') is_expected.to contain_exec('test_db-import').with_command('zcat test_sql | mysql test_db') end - it 'should import sql scripts when more than one is specified' do - params.merge!({'sql' => ['test_sql', 'test_2_sql']}) + it 'imports sql scripts when more than one is specified' do + params['sql'] = %w[test_sql test_2_sql] is_expected.to contain_exec('test_db-import').with_command('cat test_sql test_2_sql | mysql test_db') end - it 'should report an error if sql isn\'t a string or an array' do - params.merge!({'sql' => {'foo' => 'test_sql', 'bar' => 'test_2_sql'}}) - expect { catalogue }.to raise_error(Puppet::Error, - /\$sql must be either a string or an array\./) - end - - it 'should not create database and database user' do - params.merge!({'ensure' => 'absent', 'host' => 'localhost'}) + it 'does not create database' do + params.merge!('ensure' => 'absent', 'host' => 'localhost') is_expected.to contain_mysql_database('test_db').with_ensure('absent') + end + it 'does not create database user' do + params.merge!('ensure' => 'absent', 'host' => 'localhost') is_expected.to contain_mysql_user('testuser@localhost').with_ensure('absent') end - it 'should create with an appropriate collate and charset' do - params.merge!({'charset' => 'utf8', 'collate' => 'utf8_danish_ci'}) - is_expected.to contain_mysql_database('test_db').with({ - 'charset' => 'utf8', - 'collate' => 'utf8_danish_ci', - }) + it 'creates with an appropriate collate and charset' do + params.merge!('charset' => 'utf8', 'collate' => 'utf8_danish_ci') + is_expected.to contain_mysql_database('test_db').with('charset' => 'utf8', + 'collate' => 'utf8_danish_ci') end - it 'should use dbname parameter as database name instead of name' do - params.merge!({'dbname' => 'real_db'}) + it 'uses dbname parameter as database name instead of name' do + params['dbname'] = 'real_db' is_expected.to contain_mysql_database('real_db') end end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/spec/spec_helper_acceptance.rb puppet-module-puppetlabs-mysql-5.3.0/spec/spec_helper_acceptance.rb --- puppet-module-puppetlabs-mysql-3.10.0/spec/spec_helper_acceptance.rb 2016-07-27 17:34:11.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/spec/spec_helper_acceptance.rb 2018-01-19 18:07:36.000000000 +0000 @@ -1,66 +1,57 @@ +require 'puppet' require 'beaker-rspec' require 'beaker/puppet_install_helper' +require 'beaker/module_install_helper' +require 'beaker/i18n_helper' +require 'beaker/task_helper' run_puppet_install_helper - -UNSUPPORTED_PLATFORMS = [ 'Windows', 'Solaris', 'AIX' ] +install_ca_certs unless pe_install? +install_bolt_on(hosts) unless pe_install? +install_module_on(hosts) +install_module_dependencies_on(hosts) RSpec.configure do |c| - # Project root - proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) - # Readable test descriptions c.formatter = :documentation # detect the situation where PUP-5016 is triggered and skip the idempotency tests in that case # also note how fact('puppetversion') is not available because of PUP-4359 - if fact('osfamily') == 'Debian' && fact('operatingsystemmajrelease') == '8' && shell('puppet --version').stdout =~ /^4\.2/ - c.filter_run_excluding :skip_pup_5016 => true + if fact('osfamily') == 'Debian' && fact('operatingsystemmajrelease') == '8' && shell('puppet --version').stdout =~ %r{^4\.2} + c.filter_run_excluding skip_pup_5016: true end # Configure all nodes in nodeset c.before :suite do - # Install module and dependencies - puppet_module_install(:source => proj_root, :module_name => 'mysql') + run_puppet_access_login(user: 'admin') if pe_install? && puppet_version =~ %r{(5\.\d\.\d)} hosts.each do |host| + # This will be removed, this is temporary to test localisation. + if (fact('osfamily') == 'Debian' || fact('osfamily') == 'RedHat') && (puppet_version >= '4.10.5' && puppet_version < '5.2.0') + on(host, 'mkdir /opt/puppetlabs/puppet/share/locale/ja') + on(host, 'touch /opt/puppetlabs/puppet/share/locale/ja/puppet.po') + end + if fact('osfamily') == 'Debian' + # install language on debian systems + install_language_on(host, 'ja_JP.utf-8') if not_controller(host) + # This will be removed, this is temporary to test localisation. + end # Required for binding tests. if fact('osfamily') == 'RedHat' - version = fact("operatingsystemmajrelease") - if fact('operatingsystemmajrelease') =~ /7/ || fact('operatingsystem') =~ /Fedora/ - shell("yum install -y bzip2") + if fact('operatingsystemmajrelease') =~ %r{7} || fact('operatingsystem') =~ %r{Fedora} + shell('yum install -y bzip2') end end - - # Solaris 11 doesn't ship the SSL CA root for the forgeapi server - # therefore we need to use a different way to deploy the module to - # the host - if host['platform'] =~ /solaris-11/i - apply_manifest_on(host, 'package { "git": }') - # PE 3.x and 2015.2 require different locations to install modules - modulepath = host.puppet['modulepath'] - modulepath = modulepath.split(':').first if modulepath - - environmentpath = host.puppet['environmentpath'] - environmentpath = environmentpath.split(':').first if environmentpath - - destdir = modulepath || "#{environmentpath}/production/modules" - on host, "git clone https://github.com/puppetlabs/puppetlabs-stdlib #{destdir}/stdlib && cd #{destdir}/stdlib && git checkout 3.2.0" - on host, "git clone https://github.com/stahnma/puppet-module-epel.git #{destdir}/epel && cd #{destdir}/epel && git checkout 1.0.2" - else - on host, puppet('module','install','puppetlabs-stdlib','--version','3.2.0') - on host, puppet('module','install','stahnma/epel') - on host, puppet('module','install','puppet/staging') - end + on host, puppet('module', 'install', 'stahnma/epel') end end end -shared_examples "a idempotent resource" do - it 'should apply with no errors' do - apply_manifest(pp, :catch_failures => true) +shared_examples 'a idempotent resource' do + it 'applies with no errors' do + apply_manifest(pp, catch_failures: true) end - it 'should apply a second time without changes', :skip_pup_5016 do - apply_manifest(pp, :catch_changes => true) + it 'applies a second time without changes', :skip_pup_5016 do + apply_manifest(pp, catch_changes: true) end end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/spec/spec_helper_local.rb puppet-module-puppetlabs-mysql-5.3.0/spec/spec_helper_local.rb --- puppet-module-puppetlabs-mysql-3.10.0/spec/spec_helper_local.rb 2016-07-27 17:34:11.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/spec/spec_helper_local.rb 2017-10-05 23:11:56.000000000 +0000 @@ -1,3 +1,2 @@ require 'rspec-puppet-facts' include RspecPuppetFacts - diff -Nru puppet-module-puppetlabs-mysql-3.10.0/spec/spec_helper.rb puppet-module-puppetlabs-mysql-5.3.0/spec/spec_helper.rb --- puppet-module-puppetlabs-mysql-3.10.0/spec/spec_helper.rb 2016-07-27 17:34:11.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/spec/spec_helper.rb 2018-02-20 14:54:26.000000000 +0000 @@ -1,8 +1,24 @@ -#This file is generated by ModuleSync, do not edit. require 'puppetlabs_spec_helper/module_spec_helper' +require 'rspec-puppet-facts' +include RspecPuppetFacts -# put local configuration and setup into spec_helper_local -begin - require 'spec_helper_local' -rescue LoadError +default_facts = { + puppetversion: Puppet.version, + facterversion: Facter.version, +} + +default_facts_path = File.expand_path(File.join(File.dirname(__FILE__), 'default_facts.yml')) +default_module_facts_path = File.expand_path(File.join(File.dirname(__FILE__), 'default_module_facts.yml')) + +if File.exist?(default_facts_path) && File.readable?(default_facts_path) + default_facts.merge!(YAML.safe_load(File.read(default_facts_path))) +end + +if File.exist?(default_module_facts_path) && File.readable?(default_module_facts_path) + default_facts.merge!(YAML.safe_load(File.read(default_module_facts_path))) +end + +RSpec.configure do |c| + c.default_facts = default_facts end +require 'spec_helper_local' diff -Nru puppet-module-puppetlabs-mysql-3.10.0/spec/spec.opts puppet-module-puppetlabs-mysql-5.3.0/spec/spec.opts --- puppet-module-puppetlabs-mysql-3.10.0/spec/spec.opts 2016-07-27 17:34:06.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/spec/spec.opts 1970-01-01 00:00:00.000000000 +0000 @@ -1,6 +0,0 @@ ---format -s ---colour ---loadby -mtime ---backtrace diff -Nru puppet-module-puppetlabs-mysql-3.10.0/spec/unit/facter/mysqld_version_spec.rb puppet-module-puppetlabs-mysql-5.3.0/spec/unit/facter/mysqld_version_spec.rb --- puppet-module-puppetlabs-mysql-3.10.0/spec/unit/facter/mysqld_version_spec.rb 2016-11-07 20:14:07.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/spec/unit/facter/mysqld_version_spec.rb 2018-01-19 18:07:36.000000000 +0000 @@ -1,11 +1,11 @@ -require "spec_helper" +require 'spec_helper' -describe Facter::Util::Fact do - before { +describe Facter::Util::Fact.to_s do + before(:each) do Facter.clear - } + end - describe "mysqld_version" do + describe 'mysqld_version' do context 'with value' do before :each do Facter::Util::Resolution.stubs(:exec).with('mysqld -V 2>/dev/null').returns('mysqld Ver 5.5.49-37.9 for Linux on x86_64 (Percona Server (GPL), Release 37.9, Revision efa0073)') @@ -14,7 +14,5 @@ expect(Facter.fact(:mysqld_version).value).to eq('mysqld Ver 5.5.49-37.9 for Linux on x86_64 (Percona Server (GPL), Release 37.9, Revision efa0073)') } end - end - end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/spec/unit/facter/mysql_server_id_spec.rb puppet-module-puppetlabs-mysql-5.3.0/spec/unit/facter/mysql_server_id_spec.rb --- puppet-module-puppetlabs-mysql-3.10.0/spec/unit/facter/mysql_server_id_spec.rb 2016-09-06 22:04:13.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/spec/unit/facter/mysql_server_id_spec.rb 2018-01-19 18:07:36.000000000 +0000 @@ -1,11 +1,11 @@ -require "spec_helper" +require 'spec_helper' -describe Facter::Util::Fact do - before { +describe Facter::Util::Fact.to_s do + before(:each) do Facter.clear - } + end - describe "mysql_server_id" do + describe 'mysql_server_id' do context "igalic's laptop" do before :each do Facter.fact(:macaddress).stubs(:value).returns('3c:97:0e:69:fb:e1') @@ -15,7 +15,7 @@ end end - context "node with lo only" do + context 'node with lo only' do before :each do Facter.fact(:macaddress).stubs(:value).returns('00:00:00:00:00:00') end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/spec/unit/facter/mysql_version_spec.rb puppet-module-puppetlabs-mysql-5.3.0/spec/unit/facter/mysql_version_spec.rb --- puppet-module-puppetlabs-mysql-3.10.0/spec/unit/facter/mysql_version_spec.rb 2016-07-27 17:34:11.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/spec/unit/facter/mysql_version_spec.rb 2018-01-19 18:07:36.000000000 +0000 @@ -1,11 +1,11 @@ -require "spec_helper" +require 'spec_helper' -describe Facter::Util::Fact do - before { +describe Facter::Util::Fact.to_s do + before(:each) do Facter.clear - } + end - describe "mysql_version" do + describe 'mysql_version' do context 'with value' do before :each do Facter::Util::Resolution.stubs(:exec).with('mysql --version').returns('mysql Ver 14.12 Distrib 5.0.95, for redhat-linux-gnu (x86_64) using readline 5.1') @@ -14,7 +14,5 @@ expect(Facter.fact(:mysql_version).value).to eq('5.0.95') } end - end - end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/spec/unit/puppet/functions/mysql_deepmerge_spec.rb puppet-module-puppetlabs-mysql-5.3.0/spec/unit/puppet/functions/mysql_deepmerge_spec.rb --- puppet-module-puppetlabs-mysql-3.10.0/spec/unit/puppet/functions/mysql_deepmerge_spec.rb 2016-07-27 17:34:11.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/spec/unit/puppet/functions/mysql_deepmerge_spec.rb 2018-01-19 18:07:36.000000000 +0000 @@ -1,4 +1,4 @@ -#! /usr/bin/env ruby -S rspec +#! /usr/bin/env ruby -S rspec # rubocop:disable Lint/ScriptPermission require 'spec_helper' @@ -6,86 +6,97 @@ let(:scope) { PuppetlabsSpec::PuppetInternals.scope } describe 'when calling mysql_deepmerge from puppet' do - it "should not compile when no arguments are passed" do - skip("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./ + it 'does not compile when no arguments are passed' do + skip('Fails on 2.6.x, see bug #15912') if Puppet.version =~ %r{^2\.6\.} Puppet[:code] = '$x = mysql_deepmerge()' expect { scope.compiler.compile - }.to raise_error(Puppet::ParseError, /wrong number of arguments/) + }.to raise_error(Puppet::ParseError, %r{wrong number of arguments}) end - it "should not compile when 1 argument is passed" do - skip("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./ + it 'does not compile when 1 argument is passed' do + skip('Fails on 2.6.x, see bug #15912') if Puppet.version =~ %r{^2\.6\.} Puppet[:code] = "$my_hash={'one' => 1}\n$x = mysql_deepmerge($my_hash)" expect { scope.compiler.compile - }.to raise_error(Puppet::ParseError, /wrong number of arguments/) + }.to raise_error(Puppet::ParseError, %r{wrong number of arguments}) end end describe 'when calling mysql_deepmerge on the scope instance' do - it 'should require all parameters are hashes' do - expect { new_hash = scope.function_mysql_deepmerge([{}, '2'])}.to raise_error(Puppet::ParseError, /unexpected argument type String/) - expect { new_hash = scope.function_mysql_deepmerge([{}, 2])}.to raise_error(Puppet::ParseError, /unexpected argument type Fixnum/) + it 'accepts empty strings as puppet undef' do + expect { scope.function_mysql_deepmerge([{}, '']) }.not_to raise_error end - it 'should accept empty strings as puppet undef' do - expect { new_hash = scope.function_mysql_deepmerge([{}, ''])}.not_to raise_error + index_values = %w[one two three] + expected_values_one = %w[1 2 2] + it 'is able to mysql_deepmerge two hashes' do + new_hash = scope.function_mysql_deepmerge([{ 'one' => '1', 'two' => '1' }, { 'two' => '2', 'three' => '2' }]) + index_values.each_with_index do |index, expected| + expect(new_hash[index]).to eq(expected_values_one[expected]) + end end - it 'should be able to mysql_deepmerge two hashes' do - new_hash = scope.function_mysql_deepmerge([{'one' => '1', 'two' => '1'}, {'two' => '2', 'three' => '2'}]) - expect(new_hash['one']).to eq('1') - expect(new_hash['two']).to eq('2') - expect(new_hash['three']).to eq('2') - end - - it 'should mysql_deepmerge multiple hashes' do - hash = scope.function_mysql_deepmerge([{'one' => 1}, {'one' => '2'}, {'one' => '3'}]) + it 'mysql_deepmerges multiple hashes' do + hash = scope.function_mysql_deepmerge([{ 'one' => 1 }, { 'one' => '2' }, { 'one' => '3' }]) expect(hash['one']).to eq('3') end - it 'should accept empty hashes' do - expect(scope.function_mysql_deepmerge([{},{},{}])).to eq({}) + it 'accepts empty hashes' do + expect(scope.function_mysql_deepmerge([{}, {}, {}])).to eq({}) end - it 'should mysql_deepmerge subhashes' do - hash = scope.function_mysql_deepmerge([{'one' => 1}, {'two' => 2, 'three' => { 'four' => 4 } }]) - expect(hash['one']).to eq(1) - expect(hash['two']).to eq(2) - expect(hash['three']).to eq({ 'four' => 4 }) + expected_values_two = [1, 2, 'four' => 4] + it 'mysql_deepmerges subhashes' do + hash = scope.function_mysql_deepmerge([{ 'one' => 1 }, { 'two' => 2, 'three' => { 'four' => 4 } }]) + index_values.each_with_index do |index, expected| + expect(hash[index]).to eq(expected_values_two[expected]) + end end - it 'should append to subhashes' do - hash = scope.function_mysql_deepmerge([{'one' => { 'two' => 2 } }, { 'one' => { 'three' => 3 } }]) - expect(hash['one']).to eq({ 'two' => 2, 'three' => 3 }) + it 'appends to subhashes' do + hash = scope.function_mysql_deepmerge([{ 'one' => { 'two' => 2 } }, { 'one' => { 'three' => 3 } }]) + expect(hash['one']).to eq('two' => 2, 'three' => 3) end - it 'should append to subhashes 2' do - hash = scope.function_mysql_deepmerge([{'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } }, {'two' => 'dos', 'three' => { 'five' => 5 } }]) - expect(hash['one']).to eq(1) - expect(hash['two']).to eq('dos') - expect(hash['three']).to eq({ 'four' => 4, 'five' => 5 }) + expected_values_three = [1, 'dos', { 'four' => 4, 'five' => 5 }] + it 'appends to subhashes 2' do + hash = scope.function_mysql_deepmerge([{ 'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } }, { 'two' => 'dos', 'three' => { 'five' => 5 } }]) + index_values.each_with_index do |index, expected| + expect(hash[index]).to eq(expected_values_three[expected]) + end end - it 'should append to subhashes 3' do + index_values_two = %w[key1 key2] + expected_values_four = [{ 'a' => 1, 'b' => 99 }, 'c' => 3] + it 'appends to subhashes 3' do hash = scope.function_mysql_deepmerge([{ 'key1' => { 'a' => 1, 'b' => 2 }, 'key2' => { 'c' => 3 } }, { 'key1' => { 'b' => 99 } }]) - expect(hash['key1']).to eq({ 'a' => 1, 'b' => 99 }) - expect(hash['key2']).to eq({ 'c' => 3 }) + index_values_two.each_with_index do |index, expected| + expect(hash[index]).to eq(expected_values_four[expected]) + end end - it 'should equate keys mod dash and underscore' do - hash = scope.function_mysql_deepmerge([{ 'a-b-c' => 1 } , { 'a_b_c' => 10 }]) + it 'equates keys mod dash and underscore #value' do + hash = scope.function_mysql_deepmerge([{ 'a-b-c' => 1 }, { 'a_b_c' => 10 }]) expect(hash['a_b_c']).to eq(10) + end + it 'equates keys mod dash and underscore #not' do + hash = scope.function_mysql_deepmerge([{ 'a-b-c' => 1 }, { 'a_b_c' => 10 }]) expect(hash).not_to have_key('a-b-c') end - it 'should keep style of the last when keys are euqal mod dash and underscore' do - hash = scope.function_mysql_deepmerge([{ 'a-b-c' => 1, 'b_c_d' => { 'c-d-e' => 2, 'e-f-g' => 3 }} , { 'a_b_c' => 10, 'b-c-d' => { 'c_d_e' => 12 } }]) - expect(hash['a_b_c']).to eq(10) - expect(hash).not_to have_key('a-b-c') - expect(hash['b-c-d']).to eq({ 'e-f-g' => 3, 'c_d_e' => 12 }) - expect(hash).not_to have_key('b_c_d') + index_values_three = ['a_b_c', 'b-c-d'] + expected_values_five = [10, { 'e-f-g' => 3, 'c_d_e' => 12 }] + index_values_error = ['a-b-c', 'b_c_d'] + index_values_three.each_with_index do |index, expected| + it 'keeps style of the last when keys are euqal mod dash and underscore #value' do + hash = scope.function_mysql_deepmerge([{ 'a-b-c' => 1, 'b_c_d' => { 'c-d-e' => 2, 'e-f-g' => 3 } }, { 'a_b_c' => 10, 'b-c-d' => { 'c_d_e' => 12 } }]) + expect(hash[index]).to eq(expected_values_five[expected]) + end + it 'keeps style of the last when keys are euqal mod dash and underscore #not' do + hash = scope.function_mysql_deepmerge([{ 'a-b-c' => 1, 'b_c_d' => { 'c-d-e' => 2, 'e-f-g' => 3 } }, { 'a_b_c' => 10, 'b-c-d' => { 'c_d_e' => 12 } }]) + expect(hash).not_to have_key(index_values_error[expected]) + end end end end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/spec/unit/puppet/functions/mysql_password_spec.rb puppet-module-puppetlabs-mysql-5.3.0/spec/unit/puppet/functions/mysql_password_spec.rb --- puppet-module-puppetlabs-mysql-3.10.0/spec/unit/puppet/functions/mysql_password_spec.rb 2016-07-27 17:34:11.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/spec/unit/puppet/functions/mysql_password_spec.rb 2017-10-05 23:11:56.000000000 +0000 @@ -1,37 +1,36 @@ require 'spec_helper' describe 'the mysql_password function' do - before :all do + before :all do # rubocop:disable RSpec/BeforeAfterAll Puppet::Parser::Functions.autoloader.loadall end let(:scope) { PuppetlabsSpec::PuppetInternals.scope } - it 'should exist' do + it 'exists' do expect(Puppet::Parser::Functions.function('mysql_password')).to eq('function_mysql_password') end - it 'should raise a ParseError if there is less than 1 arguments' do - expect { scope.function_mysql_password([]) }.to( raise_error(Puppet::ParseError)) + it 'raises a ParseError if there is less than 1 arguments' do + expect { scope.function_mysql_password([]) }.to(raise_error(Puppet::ParseError)) end - it 'should raise a ParseError if there is more than 1 arguments' do - expect { scope.function_mysql_password(%w(foo bar)) }.to( raise_error(Puppet::ParseError)) + it 'raises a ParseError if there is more than 1 arguments' do + expect { scope.function_mysql_password(%w[foo bar]) }.to(raise_error(Puppet::ParseError)) end - it 'should convert password into a hash' do - result = scope.function_mysql_password(%w(password)) + it 'converts password into a hash' do + result = scope.function_mysql_password(%w[password]) expect(result).to(eq('*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19')) end - - it 'should convert an empty password into a empty string' do - result = scope.function_mysql_password([""]) + + it 'converts an empty password into a empty string' do + result = scope.function_mysql_password(['']) expect(result).to(eq('')) end - it 'should not convert a password that is already a hash' do + it 'does not convert a password that is already a hash' do result = scope.function_mysql_password(['*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19']) expect(result).to(eq('*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19')) end - end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/spec/unit/puppet/provider/mysql_database/mysql_spec.rb puppet-module-puppetlabs-mysql-5.3.0/spec/unit/puppet/provider/mysql_database/mysql_spec.rb --- puppet-module-puppetlabs-mysql-3.10.0/spec/unit/puppet/provider/mysql_database/mysql_spec.rb 2016-07-27 17:34:11.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/spec/unit/puppet/provider/mysql_database/mysql_spec.rb 2018-02-20 14:54:26.000000000 +0000 @@ -1,10 +1,19 @@ require 'spec_helper' describe Puppet::Type.type(:mysql_database).provider(:mysql) do - let(:defaults_file) { '--defaults-extra-file=/root/.my.cnf' } - + let(:parsed_databases) { %w[information_schema mydb mysql performance_schema test] } + let(:provider) { resource.provider } + let(:instance) { provider.class.instances.first } + let(:resource) do + Puppet::Type.type(:mysql_database).new( + ensure: :present, charset: 'latin1', + collate: 'latin1_swedish_ci', name: 'new_database', + provider: described_class.name + ) + end let(:raw_databases) do + # rubocop:disable Layout/IndentHeredoc <<-SQL_OUTPUT information_schema mydb @@ -12,37 +21,24 @@ performance_schema test SQL_OUTPUT + # rubocop:enable Layout/IndentHeredoc end - let(:parsed_databases) { %w(information_schema mydb mysql performance_schema test) } - - let(:resource) { Puppet::Type.type(:mysql_database).new( - { :ensure => :present, - :charset => 'latin1', - :collate => 'latin1_swedish_ci', - :name => 'new_database', - :provider => described_class.name - } - )} - let(:provider) { resource.provider } - before :each do Facter.stubs(:value).with(:root_home).returns('/root') Puppet::Util.stubs(:which).with('mysql').returns('/usr/bin/mysql') File.stubs(:file?).with('/root/.my.cnf').returns(true) - provider.class.stubs(:mysql).with([defaults_file, '-NBe', 'show databases']).returns('new_database') - provider.class.stubs(:mysql).with([defaults_file, '-NBe', "show variables like '%_database'", 'new_database']).returns("character_set_database latin1\ncollation_database latin1_swedish_ci\nskip_show_database OFF") + provider.class.stubs(:mysql_caller).with('show databases', 'regular').returns('new_database') + provider.class.stubs(:mysql_caller).with(["show variables like '%_database'", 'new_database'], 'regular').returns("character_set_database latin1\ncollation_database latin1_swedish_ci\nskip_show_database OFF") # rubocop:disable Metrics/LineLength end - let(:instance) { provider.class.instances.first } - describe 'self.instances' do it 'returns an array of databases' do - provider.class.stubs(:mysql).with([defaults_file, '-NBe', 'show databases']).returns(raw_databases) + provider.class.stubs(:mysql_caller).with('show databases', 'regular').returns(raw_databases) raw_databases.each_line do |db| - provider.class.stubs(:mysql).with([defaults_file, '-NBe', "show variables like '%_database'", db.chomp]).returns("character_set_database latin1\ncollation_database latin1_swedish_ci\nskip_show_database OFF") + provider.class.stubs(:mysql_caller).with(["show variables like '%_database'", db.chomp], 'regular').returns("character_set_database latin1\ncollation_database latin1_swedish_ci\nskip_show_database OFF") # rubocop:disable Metrics/LineLength end - databases = provider.class.instances.collect {|x| x.name } + databases = provider.class.instances.map { |x| x.name } expect(parsed_databases).to match_array(databases) end end @@ -56,7 +52,7 @@ describe 'create' do it 'makes a database' do - provider.expects(:mysql).with([defaults_file, '-NBe', "create database if not exists `#{resource[:name]}` character set `#{resource[:charset]}` collate `#{resource[:collate]}`"]) + provider.class.expects(:mysql_caller).with("create database if not exists `#{resource[:name]}` character set `#{resource[:charset]}` collate `#{resource[:collate]}`", 'regular') provider.expects(:exists?).returns(true) expect(provider.create).to be_truthy end @@ -64,7 +60,7 @@ describe 'destroy' do it 'removes a database if present' do - provider.expects(:mysql).with([defaults_file, '-NBe', "drop database if exists `#{resource[:name]}`"]) + provider.class.expects(:mysql_caller).with("drop database if exists `#{resource[:name]}`", 'regular') provider.expects(:exists?).returns(false) expect(provider.destroy).to be_truthy end @@ -72,7 +68,7 @@ describe 'exists?' do it 'checks if database exists' do - expect(instance.exists?).to be_truthy + expect(instance).to be_exists end end @@ -95,9 +91,9 @@ describe 'charset=' do it 'changes the charset' do - provider.expects(:mysql).with([defaults_file, '-NBe', "alter database `#{resource[:name]}` CHARACTER SET blah"]).returns('0') + provider.class.expects(:mysql_caller).with("alter database `#{resource[:name]}` CHARACTER SET blah", 'regular').returns('0') - provider.charset=('blah') + provider.charset = 'blah' end end @@ -109,10 +105,9 @@ describe 'collate=' do it 'changes the collate' do - provider.expects(:mysql).with([defaults_file, '-NBe', "alter database `#{resource[:name]}` COLLATE blah"]).returns('0') + provider.class.expects(:mysql_caller).with("alter database `#{resource[:name]}` COLLATE blah", 'regular').returns('0') - provider.collate=('blah') + provider.collate = 'blah' end end - end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/spec/unit/puppet/provider/mysql_plugin/mysql_spec.rb puppet-module-puppetlabs-mysql-5.3.0/spec/unit/puppet/provider/mysql_plugin/mysql_spec.rb --- puppet-module-puppetlabs-mysql-3.10.0/spec/unit/puppet/provider/mysql_plugin/mysql_spec.rb 2016-07-27 17:34:11.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/spec/unit/puppet/provider/mysql_plugin/mysql_spec.rb 2018-01-19 18:07:36.000000000 +0000 @@ -1,27 +1,25 @@ require 'spec_helper' describe Puppet::Type.type(:mysql_plugin).provider(:mysql) do - let(:defaults_file) { '--defaults-extra-file=/root/.my.cnf' } - - let(:resource) { Puppet::Type.type(:mysql_plugin).new( - { :ensure => :present, - :soname => 'auth_socket.so', - :name => 'auth_socket', - :provider => described_class.name - } - )} let(:provider) { resource.provider } + let(:instance) { provider.class.instances.first } + let(:resource) do + Puppet::Type.type(:mysql_plugin).new( + ensure: :present, + soname: 'auth_socket.so', + name: 'auth_socket', + provider: described_class.name, + ) + end before :each do Facter.stubs(:value).with(:root_home).returns('/root') Puppet::Util.stubs(:which).with('mysql').returns('/usr/bin/mysql') File.stubs(:file?).with('/root/.my.cnf').returns(true) - provider.class.stubs(:mysql).with([defaults_file, '-NBe', 'show plugins']).returns('auth_socket ACTIVE AUTHENTICATION auth_socket.so GPL') + provider.class.stubs(:mysql_caller).with('show plugins', 'regular').returns('auth_socket ACTIVE AUTHENTICATION auth_socket.so GPL') end - let(:instance) { provider.class.instances.first } - describe 'self.prefetch' do it 'exists' do provider.class.instances @@ -31,7 +29,7 @@ describe 'create' do it 'loads a plugin' do - provider.expects(:mysql).with([defaults_file, '-NBe', "install plugin #{resource[:name]} soname '#{resource[:soname]}'"]) + provider.class.expects(:mysql_caller).with("install plugin #{resource[:name]} soname '#{resource[:soname]}'", 'regular') provider.expects(:exists?).returns(true) expect(provider.create).to be_truthy end @@ -39,7 +37,7 @@ describe 'destroy' do it 'unloads a plugin if present' do - provider.expects(:mysql).with([defaults_file, '-NBe', "uninstall plugin #{resource[:name]}"]) + provider.class.expects(:mysql_caller).with("uninstall plugin #{resource[:name]}", 'regular') provider.expects(:exists?).returns(false) expect(provider.destroy).to be_truthy end @@ -47,7 +45,7 @@ describe 'exists?' do it 'checks if plugin exists' do - expect(instance.exists?).to be_truthy + expect(instance).to be_exists end end @@ -67,5 +65,4 @@ expect(instance.soname).to eq('auth_socket.so') end end - end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/spec/unit/puppet/provider/mysql_user/mysql_spec.rb puppet-module-puppetlabs-mysql-5.3.0/spec/unit/puppet/provider/mysql_user/mysql_spec.rb --- puppet-module-puppetlabs-mysql-3.10.0/spec/unit/puppet/provider/mysql_user/mysql_spec.rb 2016-11-07 20:14:07.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/spec/unit/puppet/provider/mysql_user/mysql_spec.rb 2018-02-20 14:54:26.000000000 +0000 @@ -1,58 +1,58 @@ require 'spec_helper' describe Puppet::Type.type(:mysql_user).provider(:mysql) do - # Output of mysqld -V mysql_version_string_hash = { - 'mysql-5.5' => - { - :version => '5.5.46', - :string => '/usr/sbin/mysqld Ver 5.5.46-log for Linux on x86_64 (MySQL Community Server (GPL))', - :mysql_type => 'mysql', - }, - 'mysql-5.6' => + 'mysql-5.5' => + { + version: '5.5.46', + string: '/usr/sbin/mysqld Ver 5.5.46-log for Linux on x86_64 (MySQL Community Server (GPL))', + mysql_type: 'mysql', + }, + 'mysql-5.6' => { - :version => '5.6.27', - :string => '/usr/sbin/mysqld Ver 5.6.27 for Linux on x86_64 (MySQL Community Server (GPL))', - :mysql_type => 'mysql', + version: '5.6.27', + string: '/usr/sbin/mysqld Ver 5.6.27 for Linux on x86_64 (MySQL Community Server (GPL))', + mysql_type: 'mysql', }, - 'mysql-5.7.1' => + 'mysql-5.7.1' => { - :version => '5.7.1', - :string => '/usr/sbin/mysqld Ver 5.7.1 for Linux on x86_64 (MySQL Community Server (GPL))', - :mysql_type => 'mysql', + version: '5.7.1', + string: '/usr/sbin/mysqld Ver 5.7.1 for Linux on x86_64 (MySQL Community Server (GPL))', + mysql_type: 'mysql', }, - 'mysql-5.7.6' => + 'mysql-5.7.6' => { - :version => '5.7.8', - :string => '/usr/sbin/mysqld Ver 5.7.8-rc for Linux on x86_64 (MySQL Community Server (GPL))', - :mysql_type => 'mysql', + version: '5.7.8', + string: '/usr/sbin/mysqld Ver 5.7.8-rc for Linux on x86_64 (MySQL Community Server (GPL))', + mysql_type: 'mysql', }, - 'mariadb-10.0' => + 'mariadb-10.0' => { - :version => '10.0.21', - :string => '/usr/sbin/mysqld Ver 10.0.21-MariaDB for Linux on x86_64 (MariaDB Server)', - :mysql_type => 'mariadb', + version: '10.0.21', + string: '/usr/sbin/mysqld Ver 10.0.21-MariaDB for Linux on x86_64 (MariaDB Server)', + mysql_type: 'mariadb', }, - 'mariadb-10.0-deb8' => + 'mariadb-10.0-deb8' => { - :version => '10.0.23', - :string => '/usr/sbin/mysqld (mysqld 10.0.23-MariaDB-0+deb8u1)', - :mysql_type => 'mariadb', + version: '10.0.23', + string: '/usr/sbin/mysqld (mysqld 10.0.23-MariaDB-0+deb8u1)', + mysql_type: 'mariadb', }, - 'percona-5.5' => + 'percona-5.5' => { - :version => '5.5.39', - :string => 'mysqld Ver 5.5.39-36.0-55 for Linux on x86_64 (Percona XtraDB Cluster (GPL), Release rel36.0, Revision 824, WSREP version 25.11, wsrep_25.11.r4023)', - :mysql_type => 'percona', + version: '5.5.39', + string: 'mysqld Ver 5.5.39-36.0-55 for Linux on x86_64 (Percona XtraDB Cluster (GPL), Release rel36.0, Revision 824, WSREP version 25.11, wsrep_25.11.r4023)', + mysql_type: 'percona', }, - } + } let(:defaults_file) { '--defaults-extra-file=/root/.my.cnf' } let(:system_database) { '--database=mysql' } let(:newhash) { '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5' } let(:raw_users) do + # rubocop:disable Layout/IndentHeredoc <<-SQL_OUTPUT root@127.0.0.1 root@::1 @@ -62,22 +62,24 @@ usvn_user@localhost @vagrant-ubuntu-raring-64 SQL_OUTPUT + # rubocop:enable Layout/IndentHeredoc end - let(:parsed_users) { %w(root@127.0.0.1 root@::1 @localhost debian-sys-maint@localhost root@localhost usvn_user@localhost @vagrant-ubuntu-raring-64) } - - let(:resource) { Puppet::Type.type(:mysql_user).new( - { :ensure => :present, - :password_hash => '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4', - :name => 'joe@localhost', - :max_user_connections => '10', - :max_connections_per_hour => '10', - :max_queries_per_hour => '10', - :max_updates_per_hour => '10', - :provider => described_class.name - } - )} + let(:parsed_users) { %w[root@127.0.0.1 root@::1 @localhost debian-sys-maint@localhost root@localhost usvn_user@localhost @vagrant-ubuntu-raring-64] } let(:provider) { resource.provider } + let(:instance) { provider.class.instances.first } + let(:resource) do + Puppet::Type.type(:mysql_user).new( + ensure: :present, + password_hash: '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4', + name: 'joe@localhost', + max_user_connections: '10', + max_connections_per_hour: '10', + max_queries_per_hour: '10', + max_updates_per_hour: '10', + provider: described_class.name, + ) + end before :each do # Set up the stubs for an instances call. @@ -87,83 +89,72 @@ Puppet::Util.stubs(:which).with('mysql').returns('/usr/bin/mysql') Puppet::Util.stubs(:which).with('mysqld').returns('/usr/sbin/mysqld') File.stubs(:file?).with('/root/.my.cnf').returns(true) - provider.class.stubs(:mysql).with([defaults_file, '-NBe', "SELECT CONCAT(User, '@',Host) AS User FROM mysql.user"]).returns('joe@localhost') - provider.class.stubs(:mysql).with([defaults_file, '-NBe', "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, SSL_TYPE, SSL_CIPHER, X509_ISSUER, X509_SUBJECT, PASSWORD /*!50508 , PLUGIN */ FROM mysql.user WHERE CONCAT(user, '@', host) = 'joe@localhost'"]).returns('10 10 10 10 *6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4') + provider.class.stubs(:mysql_caller).with("SELECT CONCAT(User, '@',Host) AS User FROM mysql.user", 'regular').returns('joe@localhost') + provider.class.stubs(:mysql_caller).with("SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, SSL_TYPE, SSL_CIPHER, X509_ISSUER, X509_SUBJECT, PASSWORD /*!50508 , PLUGIN */ FROM mysql.user WHERE CONCAT(user, '@', host) = 'joe@localhost'", 'regular').returns('10 10 10 10 *6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4') # rubocop:disable Metrics/LineLength end - let(:instance) { provider.class.instances.first } - describe 'self.instances' do it 'returns an array of users MySQL 5.5' do provider.class.instance_variable_set(:@mysqld_version_string, mysql_version_string_hash['mysql-5.5'][:string]) - provider.class.stubs(:mysql).with([defaults_file, '-NBe', "SELECT CONCAT(User, '@',Host) AS User FROM mysql.user"]).returns(raw_users) - parsed_users.each do |user| - provider.class.stubs(:mysql).with([defaults_file, '-NBe', "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, SSL_TYPE, SSL_CIPHER, X509_ISSUER, X509_SUBJECT, PASSWORD /*!50508 , PLUGIN */ FROM mysql.user WHERE CONCAT(user, '@', host) = '#{user}'"]).returns('10 10 10 10 ') - end + provider.class.stubs(:mysql_caller).with("SELECT CONCAT(User, '@',Host) AS User FROM mysql.user", 'regular').returns(raw_users) + parsed_users.each { |user| provider.class.stubs(:mysql_caller).with("SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, SSL_TYPE, SSL_CIPHER, X509_ISSUER, X509_SUBJECT, PASSWORD /*!50508 , PLUGIN */ FROM mysql.user WHERE CONCAT(user, '@', host) = '#{user}'", 'regular').returns('10 10 10 10 ') } # rubocop:disable Metrics/LineLength - usernames = provider.class.instances.collect {|x| x.name } + usernames = provider.class.instances.map { |x| x.name } expect(parsed_users).to match_array(usernames) end it 'returns an array of users MySQL 5.6' do provider.class.instance_variable_set(:@mysqld_version_string, mysql_version_string_hash['mysql-5.6'][:string]) - provider.class.stubs(:mysql).with([defaults_file, '-NBe', "SELECT CONCAT(User, '@',Host) AS User FROM mysql.user"]).returns(raw_users) - parsed_users.each do |user| - provider.class.stubs(:mysql).with([defaults_file, '-NBe', "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, SSL_TYPE, SSL_CIPHER, X509_ISSUER, X509_SUBJECT, PASSWORD /*!50508 , PLUGIN */ FROM mysql.user WHERE CONCAT(user, '@', host) = '#{user}'"]).returns('10 10 10 10 ') - end + provider.class.stubs(:mysql_caller).with("SELECT CONCAT(User, '@',Host) AS User FROM mysql.user", 'regular').returns(raw_users) + parsed_users.each { |user| provider.class.stubs(:mysql_caller).with("SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, SSL_TYPE, SSL_CIPHER, X509_ISSUER, X509_SUBJECT, PASSWORD /*!50508 , PLUGIN */ FROM mysql.user WHERE CONCAT(user, '@', host) = '#{user}'", 'regular').returns('10 10 10 10 ') } # rubocop:disable Metrics/LineLength - usernames = provider.class.instances.collect {|x| x.name } + usernames = provider.class.instances.map { |x| x.name } expect(parsed_users).to match_array(usernames) end it 'returns an array of users MySQL >= 5.7.0 < 5.7.6' do provider.class.instance_variable_set(:@mysqld_version_string, mysql_version_string_hash['mysql-5.7.1'][:string]) - provider.class.stubs(:mysql).with([defaults_file, '-NBe', "SELECT CONCAT(User, '@',Host) AS User FROM mysql.user"]).returns(raw_users) - parsed_users.each do |user| - provider.class.stubs(:mysql).with([defaults_file, '-NBe', "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, SSL_TYPE, SSL_CIPHER, X509_ISSUER, X509_SUBJECT, PASSWORD /*!50508 , PLUGIN */ FROM mysql.user WHERE CONCAT(user, '@', host) = '#{user}'"]).returns('10 10 10 10 ') - end + provider.class.stubs(:mysql_caller).with("SELECT CONCAT(User, '@',Host) AS User FROM mysql.user", 'regular').returns(raw_users) + parsed_users.each { |user| provider.class.stubs(:mysql_caller).with("SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, SSL_TYPE, SSL_CIPHER, X509_ISSUER, X509_SUBJECT, PASSWORD /*!50508 , PLUGIN */ FROM mysql.user WHERE CONCAT(user, '@', host) = '#{user}'", 'regular').returns('10 10 10 10 ') } # rubocop:disable Metrics/LineLength - usernames = provider.class.instances.collect {|x| x.name } + usernames = provider.class.instances.map { |x| x.name } expect(parsed_users).to match_array(usernames) end it 'returns an array of users MySQL >= 5.7.6' do provider.class.instance_variable_set(:@mysqld_version_string, mysql_version_string_hash['mysql-5.7.6'][:string]) - provider.class.stubs(:mysql).with([defaults_file, '-NBe', "SELECT CONCAT(User, '@',Host) AS User FROM mysql.user"]).returns(raw_users) - parsed_users.each do |user| - provider.class.stubs(:mysql).with([defaults_file, '-NBe', "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, SSL_TYPE, SSL_CIPHER, X509_ISSUER, X509_SUBJECT, AUTHENTICATION_STRING, PLUGIN FROM mysql.user WHERE CONCAT(user, '@', host) = '#{user}'"]).returns('10 10 10 10 ') - end + provider.class.stubs(:mysql_caller).with("SELECT CONCAT(User, '@',Host) AS User FROM mysql.user", 'regular').returns(raw_users) + parsed_users.each { |user| provider.class.stubs(:mysql_caller).with("SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, SSL_TYPE, SSL_CIPHER, X509_ISSUER, X509_SUBJECT, AUTHENTICATION_STRING, PLUGIN FROM mysql.user WHERE CONCAT(user, '@', host) = '#{user}'", 'regular').returns('10 10 10 10 ') } # rubocop:disable Metrics/LineLength - usernames = provider.class.instances.collect {|x| x.name } + usernames = provider.class.instances.map { |x| x.name } expect(parsed_users).to match_array(usernames) end it 'returns an array of users mariadb 10.0' do provider.class.instance_variable_set(:@mysqld_version_string, mysql_version_string_hash['mariadb-10.0'][:string]) - provider.class.stubs(:mysql).with([defaults_file, '-NBe', "SELECT CONCAT(User, '@',Host) AS User FROM mysql.user"]).returns(raw_users) - parsed_users.each do |user| - provider.class.stubs(:mysql).with([defaults_file, '-NBe', "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, SSL_TYPE, SSL_CIPHER, X509_ISSUER, X509_SUBJECT, PASSWORD /*!50508 , PLUGIN */ FROM mysql.user WHERE CONCAT(user, '@', host) = '#{user}'"]).returns('10 10 10 10 ') - end + provider.class.stubs(:mysql_caller).with("SELECT CONCAT(User, '@',Host) AS User FROM mysql.user", 'regular').returns(raw_users) + parsed_users.each { |user| provider.class.stubs(:mysql_caller).with("SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, SSL_TYPE, SSL_CIPHER, X509_ISSUER, X509_SUBJECT, PASSWORD /*!50508 , PLUGIN */ FROM mysql.user WHERE CONCAT(user, '@', host) = '#{user}'", 'regular').returns('10 10 10 10 ') } # rubocop:disable Metrics/LineLength - usernames = provider.class.instances.collect {|x| x.name } + usernames = provider.class.instances.map { |x| x.name } expect(parsed_users).to match_array(usernames) end it 'returns an array of users percona 5.5' do provider.class.instance_variable_set(:@mysqld_version_string, mysql_version_string_hash['percona-5.5'][:string]) - provider.class.stubs(:mysql).with([defaults_file, '-NBe', "SELECT CONCAT(User, '@',Host) AS User FROM mysql.user"]).returns(raw_users) - parsed_users.each do |user| - provider.class.stubs(:mysql).with([defaults_file, '-NBe', "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, SSL_TYPE, SSL_CIPHER, X509_ISSUER, X509_SUBJECT, PASSWORD /*!50508 , PLUGIN */ FROM mysql.user WHERE CONCAT(user, '@', host) = '#{user}'"]).returns('10 10 10 10 ') - end + provider.class.stubs(:mysql_caller).with("SELECT CONCAT(User, '@',Host) AS User FROM mysql.user", 'regular').returns(raw_users) + parsed_users.each { |user| provider.class.stubs(:mysql_caller).with("SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, SSL_TYPE, SSL_CIPHER, X509_ISSUER, X509_SUBJECT, PASSWORD /*!50508 , PLUGIN */ FROM mysql.user WHERE CONCAT(user, '@', host) = '#{user}'", 'regular').returns('10 10 10 10 ') } # rubocop:disable Metrics/LineLength - usernames = provider.class.instances.collect {|x| x.name } + usernames = provider.class.instances.map { |x| x.name } expect(parsed_users).to match_array(usernames) end end describe 'mysql version and type detection' do - mysql_version_string_hash.each do |name,line| - version=line[:version] - string=line[:string] - mysql_type=line[:mysql_type] - it "detects type '#{mysql_type}' with version '#{version}'" do + mysql_version_string_hash.each do |_name, line| + version = line[:version] + string = line[:string] + mysql_type = line[:mysql_type] + it "detects version '#{version}'" do provider.class.instance_variable_set(:@mysqld_version_string, string) expect(provider.mysqld_version).to eq(version) + end + it "detects type '#{mysql_type}'" do + provider.class.instance_variable_set(:@mysqld_version_string, string) expect(provider.mysqld_type).to eq(mysql_type) end end @@ -178,9 +169,9 @@ describe 'create' do it 'makes a user' do - provider.expects(:mysql).with([defaults_file, system_database, '-e', "CREATE USER 'joe'@'localhost' IDENTIFIED BY PASSWORD '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4'"]) - provider.expects(:mysql).with([defaults_file, system_database, '-e', "GRANT USAGE ON *.* TO 'joe'@'localhost' WITH MAX_USER_CONNECTIONS 10 MAX_CONNECTIONS_PER_HOUR 10 MAX_QUERIES_PER_HOUR 10 MAX_UPDATES_PER_HOUR 10"]) - provider.expects(:mysql).with([defaults_file, system_database, '-e', "GRANT USAGE ON *.* TO 'joe'@'localhost' REQUIRE NONE"]) + provider.class.expects(:mysql_caller).with("CREATE USER 'joe'@'localhost' IDENTIFIED BY PASSWORD '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4'", 'system') + provider.class.expects(:mysql_caller).with("GRANT USAGE ON *.* TO 'joe'@'localhost' WITH MAX_USER_CONNECTIONS 10 MAX_CONNECTIONS_PER_HOUR 10 MAX_QUERIES_PER_HOUR 10 MAX_UPDATES_PER_HOUR 10", 'system') # rubocop:disable Metrics/LineLength + provider.class.expects(:mysql_caller).with("GRANT USAGE ON *.* TO 'joe'@'localhost' REQUIRE NONE", 'system') provider.expects(:exists?).returns(true) expect(provider.create).to be_truthy end @@ -188,7 +179,7 @@ describe 'destroy' do it 'removes a user if present' do - provider.expects(:mysql).with([defaults_file, system_database, '-e', "DROP USER 'joe'@'localhost'"]) + provider.class.expects(:mysql_caller).with("DROP USER 'joe'@'localhost'", 'system') provider.expects(:exists?).returns(false) expect(provider.destroy).to be_truthy end @@ -196,31 +187,31 @@ describe 'exists?' do it 'checks if user exists' do - expect(instance.exists?).to be_truthy + expect(instance).to be_exists end end describe 'self.mysqld_version' do it 'uses the mysqld_version fact if unset' do - provider.class.instance_variable_set(:@mysqld_version_string, nil) - Facter.stubs(:value).with(:mysqld_version).returns('5.6.24') - expect(provider.mysqld_version).to eq '5.6.24' + provider.class.instance_variable_set(:@mysqld_version_string, nil) + Facter.stubs(:value).with(:mysqld_version).returns('5.6.24') + expect(provider.mysqld_version).to eq '5.6.24' end it 'returns 5.7.6 for "mysqld Ver 5.7.6 for Linux on x86_64 (MySQL Community Server (GPL))"' do - provider.class.instance_variable_set(:@mysqld_version_string, 'mysqld Ver 5.7.6 for Linux on x86_64 (MySQL Community Server (GPL))') - expect(provider.mysqld_version).to eq '5.7.6' + provider.class.instance_variable_set(:@mysqld_version_string, 'mysqld Ver 5.7.6 for Linux on x86_64 (MySQL Community Server (GPL))') + expect(provider.mysqld_version).to eq '5.7.6' end it 'returns 5.7.6 for "mysqld Ver 5.7.6-rc for Linux on x86_64 (MySQL Community Server (GPL))"' do - provider.class.instance_variable_set(:@mysqld_version_string, 'mysqld Ver 5.7.6-rc for Linux on x86_64 (MySQL Community Server (GPL))') - expect(provider.mysqld_version).to eq '5.7.6' + provider.class.instance_variable_set(:@mysqld_version_string, 'mysqld Ver 5.7.6-rc for Linux on x86_64 (MySQL Community Server (GPL))') + expect(provider.mysqld_version).to eq '5.7.6' end it 'detects >= 5.7.6 for 5.7.7-log' do - provider.class.instance_variable_set(:@mysqld_version_string, 'mysqld Ver 5.7.7-log for Linux on x86_64 (MySQL Community Server (GPL))') - expect(Puppet::Util::Package.versioncmp(provider.mysqld_version, '5.7.6')).to be >= 0 + provider.class.instance_variable_set(:@mysqld_version_string, 'mysqld Ver 5.7.7-log for Linux on x86_64 (MySQL Community Server (GPL))') + expect(Puppet::Util::Package.versioncmp(provider.mysqld_version, '5.7.6')).to be >= 0 end it 'detects < 5.7.6 for 5.7.5-log' do - provider.class.instance_variable_set(:@mysqld_version_string, 'mysqld Ver 5.7.5-log for Linux on x86_64 (MySQL Community Server (GPL))') - expect(Puppet::Util::Package.versioncmp(provider.mysqld_version, '5.7.6')).to be < 0 + provider.class.instance_variable_set(:@mysqld_version_string, 'mysqld Ver 5.7.5-log for Linux on x86_64 (MySQL Community Server (GPL))') + expect(Puppet::Util::Package.versioncmp(provider.mysqld_version, '5.7.6')).to be < 0 end end @@ -244,102 +235,148 @@ describe 'password_hash=' do it 'changes the hash mysql 5.5' do provider.class.instance_variable_set(:@mysqld_version_string, mysql_version_string_hash['mysql-5.5'][:string]) - provider.expects(:mysql).with([defaults_file, system_database, '-e', "SET PASSWORD FOR 'joe'@'localhost' = '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5'"]).returns('0') + provider.class.expects(:mysql_caller).with("SET PASSWORD FOR 'joe'@'localhost' = '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5'", 'system').returns('0') provider.expects(:password_hash).returns('*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5') - provider.password_hash=('*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5') + provider.password_hash = '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5' end it 'changes the hash mysql 5.6' do provider.class.instance_variable_set(:@mysqld_version_string, mysql_version_string_hash['mysql-5.6'][:string]) - provider.expects(:mysql).with([defaults_file, system_database, '-e', "SET PASSWORD FOR 'joe'@'localhost' = '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5'"]).returns('0') + provider.class.expects(:mysql_caller).with("SET PASSWORD FOR 'joe'@'localhost' = '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5'", 'system').returns('0') provider.expects(:password_hash).returns('*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5') - provider.password_hash=('*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5') + provider.password_hash = '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5' end it 'changes the hash mysql < 5.7.6' do provider.class.instance_variable_set(:@mysqld_version_string, mysql_version_string_hash['mysql-5.7.1'][:string]) - provider.expects(:mysql).with([defaults_file, system_database, '-e', "SET PASSWORD FOR 'joe'@'localhost' = '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5'"]).returns('0') + provider.class.expects(:mysql_caller).with("SET PASSWORD FOR 'joe'@'localhost' = '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5'", 'system').returns('0') provider.expects(:password_hash).returns('*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5') - provider.password_hash=('*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5') + provider.password_hash = '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5' end it 'changes the hash MySQL >= 5.7.6' do provider.class.instance_variable_set(:@mysqld_version_string, mysql_version_string_hash['mysql-5.7.6'][:string]) - provider.expects(:mysql).with([defaults_file, system_database, '-e', "ALTER USER 'joe'@'localhost' IDENTIFIED WITH mysql_native_password AS '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5'"]).returns('0') + provider.class.expects(:mysql_caller).with("ALTER USER 'joe'@'localhost' IDENTIFIED WITH mysql_native_password AS '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5'", 'system').returns('0') # rubocop:disable Metrics/LineLength provider.expects(:password_hash).returns('*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5') - provider.password_hash=('*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5') + provider.password_hash = '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5' end it 'changes the hash mariadb-10.0' do provider.class.instance_variable_set(:@mysqld_version_string, mysql_version_string_hash['mariadb-10.0'][:string]) - provider.expects(:mysql).with([defaults_file, system_database, '-e', "SET PASSWORD FOR 'joe'@'localhost' = '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5'"]).returns('0') + provider.class.expects(:mysql_caller).with("SET PASSWORD FOR 'joe'@'localhost' = '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5'", 'system').returns('0') provider.expects(:password_hash).returns('*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5') - provider.password_hash=('*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5') + provider.password_hash = '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5' end it 'changes the hash percona-5.5' do provider.class.instance_variable_set(:@mysqld_version_string, mysql_version_string_hash['percona-5.5'][:string]) - provider.expects(:mysql).with([defaults_file, system_database, '-e', "SET PASSWORD FOR 'joe'@'localhost' = '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5'"]).returns('0') + provider.class.expects(:mysql_caller).with("SET PASSWORD FOR 'joe'@'localhost' = '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5'", 'system').returns('0') provider.expects(:password_hash).returns('*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5') - provider.password_hash=('*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5') + provider.password_hash = '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5' + end + end + + describe 'plugin=' do + context 'auth_socket' do + context 'MySQL < 5.7.6' do + it 'changes the authentication plugin' do + provider.class.instance_variable_set(:@mysqld_version_string, mysql_version_string_hash['mysql-5.7.1'][:string]) + provider.class.expects(:mysql_caller).with("UPDATE mysql.user SET plugin = 'auth_socket', password = '' WHERE CONCAT(user, '@', host) = 'joe@localhost'", 'system').returns('0') + + provider.expects(:plugin).returns('auth_socket') + provider.plugin = 'auth_socket' + end + end + + context 'MySQL >= 5.7.6' do + it 'changes the authentication plugin' do + provider.class.instance_variable_set(:@mysqld_version_string, mysql_version_string_hash['mysql-5.7.6'][:string]) + provider.class.expects(:mysql_caller).with("ALTER USER 'joe'@'localhost' IDENTIFIED WITH 'auth_socket'", 'system').returns('0') + + provider.expects(:plugin).returns('auth_socket') + provider.plugin = 'auth_socket' + end + end end + + context 'mysql_native_password' do + context 'MySQL < 5.7.6' do + it 'changes the authentication plugin' do + provider.class.instance_variable_set(:@mysqld_version_string, mysql_version_string_hash['mysql-5.7.1'][:string]) + provider.class.expects(:mysql_caller).with("UPDATE mysql.user SET plugin = 'mysql_native_password', password = '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4' WHERE CONCAT(user, '@', host) = 'joe@localhost'", 'system').returns('0') # rubocop:disable Metrics/LineLength + + provider.expects(:plugin).returns('mysql_native_password') + provider.plugin = 'mysql_native_password' + end + end + + context 'MySQL >= 5.7.6' do + it 'changes the authentication plugin' do + provider.class.instance_variable_set(:@mysqld_version_string, mysql_version_string_hash['mysql-5.7.6'][:string]) + provider.class.expects(:mysql_caller).with("ALTER USER 'joe'@'localhost' IDENTIFIED WITH 'mysql_native_password' AS '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4'", 'system').returns('0') # rubocop:disable Metrics/LineLength + + provider.expects(:plugin).returns('mysql_native_password') + provider.plugin = 'mysql_native_password' + end + end + end + # rubocop:enable RSpec/NestedGroups end describe 'tls_options=' do it 'adds SSL option grant in mysql 5.5' do provider.class.instance_variable_set(:@mysqld_version_string, mysql_version_string_hash['mysql-5.5'][:string]) - provider.expects(:mysql).with([defaults_file, system_database, '-e', "GRANT USAGE ON *.* TO 'joe'@'localhost' REQUIRE NONE"]).returns('0') + provider.class.expects(:mysql_caller).with("GRANT USAGE ON *.* TO 'joe'@'localhost' REQUIRE NONE", 'system').returns('0') provider.expects(:tls_options).returns(['NONE']) - provider.tls_options=(['NONE']) + provider.tls_options = ['NONE'] end it 'adds SSL option grant in mysql 5.6' do provider.class.instance_variable_set(:@mysqld_version_string, mysql_version_string_hash['mysql-5.6'][:string]) - provider.expects(:mysql).with([defaults_file, system_database, '-e', "GRANT USAGE ON *.* TO 'joe'@'localhost' REQUIRE NONE"]).returns('0') + provider.class.expects(:mysql_caller).with("GRANT USAGE ON *.* TO 'joe'@'localhost' REQUIRE NONE", 'system').returns('0') provider.expects(:tls_options).returns(['NONE']) - provider.tls_options=(['NONE']) + provider.tls_options = ['NONE'] end it 'adds SSL option grant in mysql < 5.7.6' do provider.class.instance_variable_set(:@mysqld_version_string, mysql_version_string_hash['mysql-5.7.1'][:string]) - provider.expects(:mysql).with([defaults_file, system_database, '-e', "GRANT USAGE ON *.* TO 'joe'@'localhost' REQUIRE NONE"]).returns('0') + provider.class.expects(:mysql_caller).with("GRANT USAGE ON *.* TO 'joe'@'localhost' REQUIRE NONE", 'system').returns('0') provider.expects(:tls_options).returns(['NONE']) - provider.tls_options=(['NONE']) + provider.tls_options = ['NONE'] end it 'adds SSL option grant in mysql >= 5.7.6' do provider.class.instance_variable_set(:@mysqld_version_string, mysql_version_string_hash['mysql-5.7.6'][:string]) - provider.expects(:mysql).with([defaults_file, system_database, '-e', "ALTER USER 'joe'@'localhost' REQUIRE NONE"]).returns('0') + provider.class.expects(:mysql_caller).with("ALTER USER 'joe'@'localhost' REQUIRE NONE", 'system').returns('0') provider.expects(:tls_options).returns(['NONE']) - provider.tls_options=(['NONE']) + provider.tls_options = ['NONE'] end it 'adds SSL option grant in mariadb-10.0' do provider.class.instance_variable_set(:@mysqld_version_string, mysql_version_string_hash['mariadb-10.0'][:string]) - provider.expects(:mysql).with([defaults_file, system_database, '-e', "GRANT USAGE ON *.* TO 'joe'@'localhost' REQUIRE NONE"]).returns('0') + provider.class.expects(:mysql_caller).with("GRANT USAGE ON *.* TO 'joe'@'localhost' REQUIRE NONE", 'system').returns('0') provider.expects(:tls_options).returns(['NONE']) - provider.tls_options=(['NONE']) + provider.tls_options = ['NONE'] end end - ['max_user_connections', 'max_connections_per_hour', 'max_queries_per_hour', - 'max_updates_per_hour'].each do |property| + %w[max_user_connections max_connections_per_hour max_queries_per_hour + max_updates_per_hour].each do |property| describe property do it "returns #{property}" do - expect(instance.send("#{property}".to_sym)).to eq('10') + expect(instance.send(property.to_s.to_sym)).to eq('10') end end describe "#{property}=" do it "changes #{property}" do - provider.expects(:mysql).with([defaults_file, system_database, '-e', "GRANT USAGE ON *.* TO 'joe'@'localhost' WITH #{property.upcase} 42"]).returns('0') + provider.class.expects(:mysql_caller).with("GRANT USAGE ON *.* TO 'joe'@'localhost' WITH #{property.upcase} 42", 'system').returns('0') provider.expects(property.to_sym).returns('42') provider.send("#{property}=".to_sym, '42') end end end - end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/spec/unit/puppet/type/mysql_database_spec.rb puppet-module-puppetlabs-mysql-5.3.0/spec/unit/puppet/type/mysql_database_spec.rb --- puppet-module-puppetlabs-mysql-3.10.0/spec/unit/puppet/type/mysql_database_spec.rb 2016-07-27 17:34:11.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/spec/unit/puppet/type/mysql_database_spec.rb 2018-01-19 18:07:36.000000000 +0000 @@ -1,29 +1,25 @@ require 'puppet' require 'puppet/type/mysql_database' describe Puppet::Type.type(:mysql_database) do + let(:user) { Puppet::Type.type(:mysql_database).new(name: 'test', charset: 'utf8', collate: 'utf8_blah_ci') } - before :each do - @user = Puppet::Type.type(:mysql_database).new(:name => 'test', :charset => 'utf8', :collate => 'utf8_blah_ci') + it 'accepts a database name' do + expect(user[:name]).to eq('test') end - it 'should accept a database name' do - expect(@user[:name]).to eq('test') + it 'accepts a charset' do + user[:charset] = 'latin1' + expect(user[:charset]).to eq('latin1') end - it 'should accept a charset' do - @user[:charset] = 'latin1' - expect(@user[:charset]).to eq('latin1') + it 'accepts a collate' do + user[:collate] = 'latin1_swedish_ci' + expect(user[:collate]).to eq('latin1_swedish_ci') end - it 'should accept a collate' do - @user[:collate] = 'latin1_swedish_ci' - expect(@user[:collate]).to eq('latin1_swedish_ci') - end - - it 'should require a name' do + it 'requires a name' do expect { Puppet::Type.type(:mysql_database).new({}) }.to raise_error(Puppet::Error, 'Title or name must be provided') end - end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/spec/unit/puppet/type/mysql_grant_spec.rb puppet-module-puppetlabs-mysql-5.3.0/spec/unit/puppet/type/mysql_grant_spec.rb --- puppet-module-puppetlabs-mysql-3.10.0/spec/unit/puppet/type/mysql_grant_spec.rb 2016-07-27 17:34:11.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/spec/unit/puppet/type/mysql_grant_spec.rb 2018-01-19 18:07:36.000000000 +0000 @@ -1,74 +1,102 @@ require 'puppet' require 'puppet/type/mysql_grant' +require 'spec_helper' describe Puppet::Type.type(:mysql_grant) do + let(:user) { Puppet::Type.type(:mysql_grant).new(name: 'foo@localhost/*.*', privileges: ['ALL'], table: ['*.*'], user: 'foo@localhost') } - before :each do - @user = Puppet::Type.type(:mysql_grant).new(:name => 'foo@localhost/*.*', :privileges => ['ALL', 'PROXY'], :table => ['*.*','@'], :user => 'foo@localhost') + it 'accepts a grant name' do + expect(user[:name]).to eq('foo@localhost/*.*') end - it 'should accept a grant name' do - expect(@user[:name]).to eq('foo@localhost/*.*') + it 'accepts ALL privileges' do + user[:privileges] = 'ALL' + expect(user[:privileges]).to eq(['ALL']) end - - it 'should accept ALL privileges' do - @user[:privileges] = 'ALL' - expect(@user[:privileges]).to eq(['ALL']) + + context 'PROXY privilege with mysql greater than or equal to 5.5.0' do + before :each do + Facter.stubs(:value).with(:mysql_version).returns('5.5.0') + end + + it 'does not raise error' do + user[:privileges] = 'PROXY' + user[:table] = 'proxy_user@proxy_host' + expect(user[:privileges]).to eq(['PROXY']) + end end - it 'should accept PROXY privilege' do - @user[:privileges] = 'PROXY' - expect(@user[:privileges]).to eq(['PROXY']) + context 'PROXY privilege with mysql greater than or equal to 5.4.0' do + before :each do + Facter.stubs(:value).with(:mysql_version).returns('5.4.0') + end + + it 'raises error' do + expect { + user[:privileges] = 'PROXY' + }.to raise_error(Puppet::ResourceError, %r{PROXY user not supported on mysql versions < 5.5.0}) + end end - - it 'should accept a table' do - @user[:table] = '*.*' - expect(@user[:table]).to eq('*.*') + + it 'accepts a table' do + user[:table] = '*.*' + expect(user[:table]).to eq('*.*') end - - it 'should accept @ for table' do - @user[:table] = '@' - expect(@user[:table]).to eq('@') + + it 'accepts @ for table' do + user[:table] = '@' + expect(user[:table]).to eq('@') end - - it 'should accept a user' do - @user[:user] = 'foo@localhost' - expect(@user[:user]).to eq('foo@localhost') + + it 'accepts proxy user for table' do + user[:table] = 'proxy_user@proxy_host' + expect(user[:table]).to eq('proxy_user@proxy_host') + end + + it 'accepts a user' do + user[:user] = 'foo@localhost' + expect(user[:user]).to eq('foo@localhost') end - - it 'should require a name' do + + it 'requires a name' do expect { Puppet::Type.type(:mysql_grant).new({}) }.to raise_error(Puppet::Error, 'Title or name must be provided') end - it 'should require the name to match the user and table' do + it 'requires the name to match the user and table #general' do expect { - Puppet::Type.type(:mysql_grant).new(:name => 'foo', :privileges => ['ALL', 'PROXY'], :table => ['*.*','@'], :user => 'foo@localhost') - }.to raise_error /name must match user and table parameters/ + Puppet::Type.type(:mysql_grant).new(name: 'foo@localhost/*.*', privileges: ['ALL'], table: ['*.*'], user: 'foo@localhost') + }.not_to raise_error + end + it 'requires the name to match the user and table #specific' do + expect { + Puppet::Type.type(:mysql_grant).new(name: 'foo', privileges: ['ALL'], table: ['*.*'], user: 'foo@localhost') + }.to raise_error %r{`name` `parameter` must match user@host\/table format} end describe 'it should munge privileges' do - it 'to just ALL' do - @user = Puppet::Type.type(:mysql_grant).new( - :name => 'foo@localhost/*.*', :table => ['*.*','@'], :user => 'foo@localhost', - :privileges => ['ALL', 'PROXY'] ) - expect(@user[:privileges]).to eq(['ALL']) + user = Puppet::Type.type(:mysql_grant).new( + name: 'foo@localhost/*.*', table: ['*.*'], user: 'foo@localhost', + privileges: ['ALL'] + ) + expect(user[:privileges]).to eq(['ALL']) end it 'to upcase and ordered' do - @user = Puppet::Type.type(:mysql_grant).new( - :name => 'foo@localhost/*.*', :table => ['*.*','@'], :user => 'foo@localhost', - :privileges => ['select', 'Insert'] ) - expect(@user[:privileges]).to eq(['INSERT', 'SELECT']) + user = Puppet::Type.type(:mysql_grant).new( + name: 'foo@localhost/*.*', table: ['*.*'], user: 'foo@localhost', + privileges: %w[select Insert] + ) + expect(user[:privileges]).to eq(%w[INSERT SELECT]) end it 'ordered including column privileges' do - @user = Puppet::Type.type(:mysql_grant).new( - :name => 'foo@localhost/*.*', :table => ['*.*','@'], :user => 'foo@localhost', - :privileges => ['SELECT(Host,Address)', 'Insert'] ) - expect(@user[:privileges]).to eq(['INSERT', 'SELECT (Address, Host)']) + user = Puppet::Type.type(:mysql_grant).new( + name: 'foo@localhost/*.*', table: ['*.*'], user: 'foo@localhost', + privileges: ['SELECT(Host,Address)', 'Insert'] + ) + expect(user[:privileges]).to eq(['INSERT', 'SELECT (Address, Host)']) end end - end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/spec/unit/puppet/type/mysql_plugin_spec.rb puppet-module-puppetlabs-mysql-5.3.0/spec/unit/puppet/type/mysql_plugin_spec.rb --- puppet-module-puppetlabs-mysql-3.10.0/spec/unit/puppet/type/mysql_plugin_spec.rb 2016-07-27 17:34:11.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/spec/unit/puppet/type/mysql_plugin_spec.rb 2018-01-19 18:07:36.000000000 +0000 @@ -1,24 +1,20 @@ require 'puppet' require 'puppet/type/mysql_plugin' describe Puppet::Type.type(:mysql_plugin) do + let(:plugin) { Puppet::Type.type(:mysql_plugin).new(name: 'test', soname: 'test.so') } - before :each do - @plugin = Puppet::Type.type(:mysql_plugin).new(:name => 'test', :soname => 'test.so') + it 'accepts a plugin name' do + expect(plugin[:name]).to eq('test') end - it 'should accept a plugin name' do - expect(@plugin[:name]).to eq('test') + it 'accepts a library name' do + plugin[:soname] = 'test.so' + expect(plugin[:soname]).to eq('test.so') end - it 'should accept a library name' do - @plugin[:soname] = 'test.so' - expect(@plugin[:soname]).to eq('test.so') - end - - it 'should require a name' do + it 'requires a name' do expect { Puppet::Type.type(:mysql_plugin).new({}) }.to raise_error(Puppet::Error, 'Title or name must be provided') end - end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/spec/unit/puppet/type/mysql_user_spec.rb puppet-module-puppetlabs-mysql-5.3.0/spec/unit/puppet/type/mysql_user_spec.rb --- puppet-module-puppetlabs-mysql-3.10.0/spec/unit/puppet/type/mysql_user_spec.rb 2016-09-06 22:04:13.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/spec/unit/puppet/type/mysql_user_spec.rb 2018-01-19 18:07:36.000000000 +0000 @@ -1,136 +1,123 @@ require 'puppet' require 'puppet/type/mysql_user' +require 'spec_helper' describe Puppet::Type.type(:mysql_user) do - - context "On MySQL 5.x" do + context 'On MySQL 5.x' do before :each do - Facter.stubs(:value).with(:mysql_version).returns("5.6.24") + Facter.stubs(:value).with(:mysql_version).returns('5.6.24') end - it 'should fail with a long user name' do + + it 'fails with a long user name' do expect { - Puppet::Type.type(:mysql_user).new({:name => '12345678901234567@localhost', :password_hash => 'pass'}) - }.to raise_error /MySQL usernames are limited to a maximum of 16 characters/ + Puppet::Type.type(:mysql_user).new(name: '12345678901234567@localhost', password_hash: 'pass') + }.to raise_error %r{MySQL usernames are limited to a maximum of 16 characters} end end - context "On MariaDB 10.0.0+" do + context 'On MariaDB 10.0.0+' do + let(:user) { Puppet::Type.type(:mysql_user).new(name: '12345678901234567@localhost', password_hash: 'pass') } + before :each do - Facter.stubs(:value).with(:mysql_version).returns("10.0.19") - @user = Puppet::Type.type(:mysql_user).new(:name => '12345678901234567@localhost', :password_hash => 'pass') + Facter.stubs(:value).with(:mysql_version).returns('10.0.19') end - it 'should succeed with a long user name on MariaDB' do - expect(@user[:name]).to eq('12345678901234567@localhost') + + it 'succeeds with a long user name on MariaDB' do + expect(user[:name]).to eq('12345678901234567@localhost') end end - it 'should require a name' do + it 'requires a name' do expect { Puppet::Type.type(:mysql_user).new({}) }.to raise_error(Puppet::Error, 'Title or name must be provided') end context 'using foo@localhost' do - before :each do - @user = Puppet::Type.type(:mysql_user).new(:name => 'foo@localhost', :password_hash => 'pass') - end + let(:user) { Puppet::Type.type(:mysql_user).new(name: 'foo@localhost', password_hash: 'pass') } - it 'should accept a user name' do - expect(@user[:name]).to eq('foo@localhost') + it 'accepts a user name' do + expect(user[:name]).to eq('foo@localhost') end - it 'should accept a password' do - @user[:password_hash] = 'foo' - expect(@user[:password_hash]).to eq('foo') + it 'accepts a password' do + user[:password_hash] = 'foo' + expect(user[:password_hash]).to eq('foo') end end context 'using foo@LocalHost' do - before :each do - @user = Puppet::Type.type(:mysql_user).new(:name => 'foo@LocalHost', :password_hash => 'pass') - end + let(:user) { Puppet::Type.type(:mysql_user).new(name: 'foo@LocalHost', password_hash: 'pass') } - it 'should lowercase the user name' do - expect(@user[:name]).to eq('foo@localhost') + it 'lowercases the user name' do + expect(user[:name]).to eq('foo@localhost') end end context 'using foo@192.168.1.0/255.255.255.0' do - before :each do - @user = Puppet::Type.type(:mysql_user).new(:name => 'foo@192.168.1.0/255.255.255.0', :password_hash => 'pass') - end + let(:user) { Puppet::Type.type(:mysql_user).new(name: 'foo@192.168.1.0/255.255.255.0', password_hash: 'pass') } - it 'should create the user with the netmask' do - expect(@user[:name]).to eq('foo@192.168.1.0/255.255.255.0') + it 'creates the user with the netmask' do + expect(user[:name]).to eq('foo@192.168.1.0/255.255.255.0') end end context 'using allo_wed$char@localhost' do - before :each do - @user = Puppet::Type.type(:mysql_user).new(:name => 'allo_wed$char@localhost', :password_hash => 'pass') - end + let(:user) { Puppet::Type.type(:mysql_user).new(name: 'allo_wed$char@localhost', password_hash: 'pass') } - it 'should accept a user name' do - expect(@user[:name]).to eq('allo_wed$char@localhost') + it 'accepts a user name' do + expect(user[:name]).to eq('allo_wed$char@localhost') end end context 'ensure the default \'debian-sys-main\'@localhost user can be parsed' do - before :each do - @user = Puppet::Type.type(:mysql_user).new(:name => '\'debian-sys-maint\'@localhost', :password_hash => 'pass') - end + let(:user) { Puppet::Type.type(:mysql_user).new(name: '\'debian-sys-maint\'@localhost', password_hash: 'pass') } - it 'should accept a user name' do - expect(@user[:name]).to eq('\'debian-sys-maint\'@localhost') + it 'accepts a user name' do + expect(user[:name]).to eq('\'debian-sys-maint\'@localhost') end end context 'using a quoted 16 char username' do - before :each do - @user = Puppet::Type.type(:mysql_user).new(:name => '"debian-sys-maint"@localhost', :password_hash => 'pass') - end + let(:user) { Puppet::Type.type(:mysql_user).new(name: '"debian-sys-maint"@localhost', password_hash: 'pass') } - it 'should accept a user name' do - expect(@user[:name]).to eq('"debian-sys-maint"@localhost') + it 'accepts a user name' do + expect(user[:name]).to eq('"debian-sys-maint"@localhost') end end context 'using a quoted username that is too long ' do before :each do - Facter.stubs(:value).with(:mysql_version).returns("5.6.24") + Facter.stubs(:value).with(:mysql_version).returns('5.6.24') end - it 'should fail with a size error' do + it 'fails with a size error' do expect { - Puppet::Type.type(:mysql_user).new(:name => '"debian-sys-maint2"@localhost', :password_hash => 'pass') - }.to raise_error /MySQL usernames are limited to a maximum of 16 characters/ + Puppet::Type.type(:mysql_user).new(name: '"debian-sys-maint2"@localhost', password_hash: 'pass') + }.to raise_error %r{MySQL usernames are limited to a maximum of 16 characters} end end context 'using `speci!al#`@localhost' do - before :each do - @user = Puppet::Type.type(:mysql_user).new(:name => '`speci!al#`@localhost', :password_hash => 'pass') - end + let(:user) { Puppet::Type.type(:mysql_user).new(name: '`speci!al#`@localhost', password_hash: 'pass') } - it 'should accept a quoted user name with special chatracters' do - expect(@user[:name]).to eq('`speci!al#`@localhost') + it 'accepts a quoted user name with special chatracters' do + expect(user[:name]).to eq('`speci!al#`@localhost') end end context 'using in-valid@localhost' do - before :each do - @user = Puppet::Type.type(:mysql_user).new(:name => 'in-valid@localhost', :password_hash => 'pass') - end + let(:user) { Puppet::Type.type(:mysql_user).new(name: 'in-valid@localhost', password_hash: 'pass') } - it 'should accept a user name with special chatracters' do - expect(@user[:name]).to eq('in-valid@localhost') + it 'accepts a user name with special chatracters' do + expect(user[:name]).to eq('in-valid@localhost') end end context 'using "misquoted@localhost' do - it 'should fail with a misquoted username is used' do + it 'fails with a misquoted username is used' do expect { - Puppet::Type.type(:mysql_user).new(:name => '"misquoted@localhost', :password_hash => 'pass') - }.to raise_error /Invalid database user "misquoted@localhost/ + Puppet::Type.type(:mysql_user).new(name: '"misquoted@localhost', password_hash: 'pass') + }.to raise_error %r{Invalid database user "misquoted@localhost} end end end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/tasks/export.json puppet-module-puppetlabs-mysql-5.3.0/tasks/export.json --- puppet-module-puppetlabs-mysql-3.10.0/tasks/export.json 1970-01-01 00:00:00.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/tasks/export.json 2018-02-20 14:54:26.000000000 +0000 @@ -0,0 +1,22 @@ +{ + "description": "Allows you to backup your database to local file.", + "input_method": "stdin", + "parameters": { + "database": { + "description": "Database to connect to", + "type": "Optional[String[1]]" + }, + "user": { + "description": "The user", + "type": "Optional[String[1]]" + }, + "password": { + "description": "The password", + "type": "Optional[String[1]]" + }, + "sql": { + "description": "Path to file you want backup to", + "type": "String[1]" + } + } +} diff -Nru puppet-module-puppetlabs-mysql-3.10.0/tasks/export.rb puppet-module-puppetlabs-mysql-5.3.0/tasks/export.rb --- puppet-module-puppetlabs-mysql-3.10.0/tasks/export.rb 1970-01-01 00:00:00.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/tasks/export.rb 2018-02-20 14:54:26.000000000 +0000 @@ -0,0 +1,30 @@ +#!/opt/puppetlabs/puppet/bin/ruby +require 'json' +require 'open3' +require 'puppet' + +def get(file, database, user, password) + cmd_string = 'mysqldump' + cmd_string << " --databases #{database}" unless database.nil? + cmd_string << " --user=#{user}" unless user.nil? + cmd_string << " --password=#{password}" unless password.nil? + cmd_string << " > #{file}" unless file.nil? + stdout, _stderr, status = Open3.capture3(cmd_string) + raise Puppet::Error, _("stderr: ' %{stderr}') % { stderr: stderr }") if status != 0 + { status: stdout.strip } +end + +params = JSON.parse(STDIN.read) +database = params['database'] +user = params['user'] +password = params['password'] +file = params['file'] + +begin + result = get(file, database, user, password) + puts result.to_json + exit 0 +rescue Puppet::Error => e + puts({ status: 'failure', error: e.message }.to_json) + exit 1 +end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/tasks/sql.json puppet-module-puppetlabs-mysql-5.3.0/tasks/sql.json --- puppet-module-puppetlabs-mysql-3.10.0/tasks/sql.json 1970-01-01 00:00:00.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/tasks/sql.json 2017-10-11 12:16:43.000000000 +0000 @@ -0,0 +1,22 @@ +{ + "description": "Allows you to execute arbitary SQL", + "input_method": "stdin", + "parameters": { + "database": { + "description": "Database to connect to", + "type": "Optional[String[1]]" + }, + "user": { + "description": "The user", + "type": "Optional[String[1]]" + }, + "password": { + "description": "The password", + "type": "Optional[String[1]]" + }, + "sql": { + "description": "The SQL you want to execute", + "type": "String[1]" + } + } +} diff -Nru puppet-module-puppetlabs-mysql-3.10.0/tasks/sql.rb puppet-module-puppetlabs-mysql-5.3.0/tasks/sql.rb --- puppet-module-puppetlabs-mysql-3.10.0/tasks/sql.rb 1970-01-01 00:00:00.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/tasks/sql.rb 2018-02-20 14:54:26.000000000 +0000 @@ -0,0 +1,29 @@ +#!/opt/puppetlabs/puppet/bin/ruby +require 'json' +require 'open3' +require 'puppet' + +def get(sql, database, user, password) + cmd = ['mysql', '-e', "#{sql} "] + cmd << "--database=#{database}" unless database.nil? + cmd << "--user=#{user}" unless user.nil? + cmd << "--password=#{password}" unless password.nil? + stdout, stderr, status = Open3.capture3(*cmd) # rubocop:disable Lint/UselessAssignment + raise Puppet::Error, _("stderr: ' %{stderr}') % { stderr: stderr }") if status != 0 + { status: stdout.strip } +end + +params = JSON.parse(STDIN.read) +database = params['database'] +user = params['user'] +password = params['password'] +sql = params['sql'] + +begin + result = get(sql, database, user, password) + puts result.to_json + exit 0 +rescue Puppet::Error => e + puts({ status: 'failure', error: e.message }.to_json) + exit 1 +end diff -Nru puppet-module-puppetlabs-mysql-3.10.0/templates/mysqlbackup.sh.erb puppet-module-puppetlabs-mysql-5.3.0/templates/mysqlbackup.sh.erb --- puppet-module-puppetlabs-mysql-3.10.0/templates/mysqlbackup.sh.erb 2016-09-06 22:04:13.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/templates/mysqlbackup.sh.erb 2017-05-08 20:52:37.000000000 +0000 @@ -22,7 +22,12 @@ # Create temporary mysql cnf file. TMPFILE=`mktemp /tmp/backup.XXXXXX` || exit 1 +<%- if @kernel == 'SunOS' -%> +echo "[client]\npassword=$PASS\nuser=$USER\nmax_allowed_packet=$MAX_ALLOWED_PACKET" > $TMPFILE +<%- else -%> echo -e "[client]\npassword=$PASS\nuser=$USER\nmax_allowed_packet=$MAX_ALLOWED_PACKET" > $TMPFILE +<%- end -%> + # Ensure backup directory exist. mkdir -p $DIR @@ -60,7 +65,11 @@ cleanup() { - find "${DIR}/" -maxdepth 1 -type f -name "${PREFIX}*.sql*" -mtime +${ROTATE} -print0 | xargs -0 -r rm -f +<%- if @kernel == 'SunOS' -%> + gfind "${DIR}/" -maxdepth 1 -type f -name "${PREFIX}*.sql*" -mtime +${ROTATE} -print0 | gxargs -0 -r rm -f +<%- else -%> + find "${DIR}/" -maxdepth 1 -type f -name "${PREFIX}*.sql*" -mtime +${ROTATE} -print0 | xargs -0 -r rm -f +<%- end -%> } <% if @delete_before_dump -%> @@ -91,6 +100,7 @@ <% unless @delete_before_dump -%> if [ $? -eq 0 ] ; then cleanup + touch /tmp/mysqlbackup_success fi <% end -%> diff -Nru puppet-module-puppetlabs-mysql-3.10.0/templates/xtrabackup.sh.erb puppet-module-puppetlabs-mysql-5.3.0/templates/xtrabackup.sh.erb --- puppet-module-puppetlabs-mysql-3.10.0/templates/xtrabackup.sh.erb 2016-07-27 17:34:11.000000000 +0000 +++ puppet-module-puppetlabs-mysql-5.3.0/templates/xtrabackup.sh.erb 2017-05-08 20:52:37.000000000 +0000 @@ -12,7 +12,23 @@ <%- end -%> <% end -%> -innobackupex "$@" +<%- _innobackupex_args = '' -%> + +<%- if @backupuser and @backuppassword -%> + <%- _innobackupex_args = '--user="' + @backupuser + '" --password="' + @backuppassword + '"' -%> +<%- end -%> + +<%- if @backupdatabases and @backupdatabases.is_a?(Array) and !@backupdatabases.empty? -%> + <%- _innobackupex_args = _innobackupex_args + ' --databases="' + @backupdatabases.join(' ') + '"' -%> +<%- end -%> + +<%- if @optional_args and @optional_args.is_a?(Array) -%> + <%- @optional_args.each do |arg| -%> + <%- _innobackupex_args = _innobackupex_args + ' ' + arg -%> + <%- end -%> +<%- end -%> + +innobackupex <%= _innobackupex_args %> "$@" <% if @postscript -%> <%- [@postscript].flatten.compact.each do |script| %>