puppetlabs-mysql-3.6.1/000755 000765 000024 00000000000 12600353524 015471 5ustar00morganstaff000000 000000 puppetlabs-mysql-3.6.1/CHANGELOG.md000644 000765 000024 00000057450 12600353471 017316 0ustar00morganstaff000000 000000 ## 2015-09-22 - Supported Release 3.6.1 ### Summary This is a security and bugfix release that fixes incorrect username truncation in the munge for the mysql_user type, incorrect function used in `mysql::server::backup` and fixes compatibility issues with PE 3.3.x. #### Bugfixes - Loosen the regex in mysql_user munging so the username is not unintentionally truncated. - Use `warning()` not `warn()` - Metadata had inadvertantly dropped 3.3.x support - Some 3.3.x compatibility issues in `mysqltuner` were corrected ## 2015-08-10 - Supported Release 3.6.0 ### Summary This release adds the ability to use mysql::db and `mysql_*` types against unmanaged or external mysql instances. #### Features - Add ability to use mysql::db WITHOUT mysql::server (ie, externally) - Add prescript attribute to mysql::server::backup for xtrabackup - Add postscript ability to xtrabackup provider. #### Bugfixes - Fix default root passwords blocking puppet on mysql 5.8 - Fix service dependency when package_manage is false - Fix selinux permissions on my.cnf ##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 - Start running tests against puppet 4 - Support longer usernames on newer MariaDB versions - Add parameters for Solaris 11 and 12 ####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 This release includes the addition of extra facts, OpenBSD compatibility, and a number of other features, improvements and bug fixes. ####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. - Updated tests for rspec-puppet 2 and future parser - Further acceptance testing improvements - MODULES-1928 - allow log-error to be undef - Split package installation and database install - README wording improvements - Added options for including/excluding triggers and routines - Made the 'TRIGGER' privilege of mysqldump backups depend on whether or not we are actually backing up triggers - Cleaned up the privilege assignment in the mysqldump backup script - Add a fact for capturing the mysql version installed ####Bugfixes - mysql backup: fix regression in mysql_user call - Set service_ensure to undef, in the case of an unmanaged service - README Typos fixed - Bugfix on Xtrabackup crons - Fixed a permission problem that was preventing triggers from being backed up - MODULES-1981: Revoke and grant difference of old and new privileges - Fix an issue were we assume triggers work - Change default for mysql::server::backup to ignore_triggers = false ####Deprecations mysql::server::old_root_password property ##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 - Add package_manage parameters to `mysql::server` and `mysql::client` (MODULES-1143) - README improvements - Add `mysqldump`, `mysqlbackup`, and `xtrabackup` backup providers. ####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 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 - 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 - Remove dependency on stdlib >= 4.1.0 (MODULES-1759) - Make grant autorequire user - Remove invalid parameter 'provider' from mysql_user instance (MODULES-1731) - Return empty string for empty input in mysql_password - Fix `mysql::account_security` when fqdn==localhost - Update username validation (MODULES-1520) - Future parser fix in params.pp - Fix package name for debian 8 - Don't start the service until the server package is installed and the config file is in place - Test fixes - Lint fixes ##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 `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 - 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) - SLES12 support - 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 - 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 Added several new features including MariaDB support and future parser ####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 * 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 * Pass the backup credentials to 'SHOW DATABASES' * Ability to specify the Includedir for `mysql::server` * `mysql::db` now has an import\_timeout feature that defaults to 300 * The `mysql` class has been removed * `mysql::server` now takes an `override_options` hash that will affect the installation * Ability to install both dev and client dev ####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 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 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 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. Added support for Ubuntu 14.04. Create a warning for if you disable SSL. Ensure the error logfile is owned by MySQL. Disable ssl on FreeBSD. Add PROCESS privilege for backups. ####Bugfixes ####Known Bugs * No known bugs ##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 * No known bugs ##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 - PHP bindings on Suse - Test fixes ####Known Bugs * No known bugs ##2014-02-19 - Version 2.2.1 ###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 actual database and constantly setting it over and over since January 22nd). Also fixes a bunch of tests on various platforms. ##2014-02-13 - Version 2.2.0 ###Summary ####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 - 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/@. - mysql_grant fixed for WITH MAX_QUERIES_PER_HOUR - mysql_grant fixed so revoking all privileges accounts for GRANT OPTION - mysql_grant fixed to remove duplicate privileges. - mysql_grant fixed to handle PROCEDURES when removing privileges. - mysql_database won't try to create existing databases, breaking replication. - bind_address renamed bind-address in 'mysqld' options. - 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 - 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 ###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 key name itself, which is required for some options. The provider updates fix a number of bugs, from lowercase privileges to deprecation warnings. Last, the new hiera integration functionality should make it easier to externalize all your grants, users, and, databases. Another great set of community submissions helped to make this release. ####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 - 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. - database_user deprecation warning was incorrect. - Add anchor pattern for client.pp - Documentation improvements. - Various test fixes. ##2013-10-21 - Version 2.0.1 ###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 - 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 ###Summary (Previously detailed in the changelog for 2.0.0-rc1) This module has been completely refactored and works significantly different. The changes are broad and touch almost every piece of the module. See the README.md for full details of all changes and syntax. Please remain on 1.0.0 if you don't have time to fully test this in dev. * mysql::server, mysql::client, and mysql::bindings are the primary interface classes. * mysql::server takes an `override_options` parameter to set my.cnf options, with the hash format: { 'section' => { 'thing' => 'value' }} * mysql attempts backwards compatibility by forwarding all parameters to mysql::server. ##2013-10-09 - Version 2.0.0-rc5 ###Summary Hopefully the final rc! Further fixes to mysql_grant (stripping out the cleverness so we match a much wider range of input.) ####Bugfixes - Make mysql_grant accept '.*'@'.*' in terms of input for user@host. ##2013-10-09 - Version 2.0.0-rc4 ###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 - 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 ###Summary Fix mysql::server::monitor's use of mysql_user{}. ####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 ###Summary Bugfixes ####Bugfixes - Fix a duplicate parameter in mysql::server ##2013-10-03 - Version 2.0.0-rc1 ###Summary This module has been completely refactored and works significantly different. The changes are broad and touch almost every piece of the module. See the README.md for full details of all changes and syntax. Please remain on 1.0.0 if you don't have time to fully test this in dev. * mysql::server, mysql::client, and mysql::bindings are the primary interface classes. * mysql::server takes an `override_options` parameter to set my.cnf options, with the hash format: { 'section' => { 'thing' => 'value' }} * mysql attempts backwards compatibility by forwarding all parameters to mysql::server. --- ##2013-09-23 - Version 1.0.0 ###Summary This release introduces a number of new type/providers, to eventually replace the database_ ones. The module has been converted to call the new providers rather than the previous ones as they have a number of fixes, additional options, and work with puppet resource. This 1.0.0 release precedes a large refactoring that will be released almost immediately after as 2.0.0. ####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 - 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 - Add `mysql::backup::backuprotate` parameter - Add `mysql::backup::delete_before_dump` parameter - Add `max_user_connections` attribute to `database_user` type ####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 - Fix a typo in the Fedora 19 support. ##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. - Add new `mysql` class parameters: - `max_connections`: The maximum number of allowed connections. - `manage_config_file`: Opt out of puppetized control of my.cnf. - `ft_min_word_len`: Fine tune the full text search. - `ft_max_word_len`: Fine tune the full text search. - Add new `mysql` class performance tuning parameters: - `key_buffer` - `thread_stack` - `thread_cache_size` - `myisam-recover` - `query_cache_limit` - `query_cache_size` - `max_connections` - `tmp_table_size` - `table_open_cache` - `long_query_time` - Add new `mysql` class replication parameters: - `server_id` - `sql_log_bin` - `log_bin` - `max_binlog_size` - `binlog_do_db` - `expire_logs_days` - `log_bin_trust_function_creators` - `replicate_ignore_table` - `replicate_wild_do_table` - `replicate_wild_ignore_table` - `expire_logs_days` - `max_binlog_size` ####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 - 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 This is a maintenance release for community bugfixes and exposing configuration variables. * Add new `mysql` class parameters: - `basedir`: The base directory mysql uses - `bind_address`: The IP mysql binds to - `client_package_name`: The name of the mysql client package - `config_file`: The location of the server config file - `config_template`: The template to use to generate my.cnf - `datadir`: The directory MySQL's datafiles are stored - `default_engine`: The default engine to use for tables - `etc_root_password`: Whether or not to add the mysql root password to /etc/my.cnf - `java_package_name`: The name of the java package containing the java connector - `log_error`: Where to log errors - `manage_service`: Boolean dictating if mysql::server should manage the service - `max_allowed_packet`: Maximum network packet size mysqld will accept - `old_root_password`: Previous root user password - `php_package_name`: The name of the phpmysql package to install - `pidfile`: The location mysql will expect the pidfile to be - `port`: The port mysql listens on - `purge_conf_dir`: Value fed to recurse and purge parameters of the /etc/mysql/conf.d resource - `python_package_name`: The name of the python mysql package to install - `restart`: Whether to restart mysqld - `root_group`: Use specified group for root-owned files - `root_password`: The root MySQL password to use - `ruby_package_name`: The name of the ruby mysql package to install - `ruby_package_provider`: The installation suite to use when installing the ruby package - `server_package_name`: The name of the server package to install - `service_name`: The name of the service to start - `service_provider`: The name of the service provider - `socket`: The location of the MySQL server socket file - `ssl_ca`: The location of the SSL CA Cert - `ssl_cert`: The location of the SSL Certificate to use - `ssl_key`: The SSL key to use - `ssl`: Whether or not to enable ssl - `tmpdir`: The directory MySQL's tmpfiles are stored * Deprecate `mysql::package_name` parameter in favor of `mysql::client_package_name` * Fix local variable template deprecation * Fix dependency ordering in `mysql::db` * Fix ANSI quoting in queries * Fix travis support (but still messy) * Fix typos ##2013-01-11 - Version 0.6.1 * Fix providers when /root/.my.cnf is absent ##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` * Add `restart` parameter to `mysql::config` * Add `purge_conf_dir` parameter to `mysql::config` * Add `manage_service` parameter to `mysql::server` * Add syslog logging support via the `log_error` parameter * Add initial SuSE support * Fix remove non-localhost root user when fqdn != hostname * Fix dependency in `mysql::server::monitor` * Fix .my.cnf path for root user and root password * Fix ipv6 support for users * Fix / update various spec tests * Fix typos * Fix lint warnings ##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 * Add `ensure` parameter to mysql::db * Add Amazon linux support * Change `bind_address` parameter to be optional in my.cnf template * Fix quoting root passwords ##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 * 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-03-19 - William Van Hevelingen * (#13203) Add ssl support (f7e0ea5) ##2012-03-18 - Nan Liu * Travis ci before script needs success exit code. (0ea463b) ##2012-03-18 - Nan Liu * Fix Puppet 2.6 compilation issues. (9ebbbc4) ##2012-03-16 - Nan Liu * Add travis.ci for testing multiple puppet versions. (33c72ef) ##2012-03-15 - William Van Hevelingen * (#13163) Datadir should be configurable (f353fc6) ##2012-03-16 - Nan Liu * Document create_resources dependency. (558a59c) ##2012-03-16 - Nan Liu * Fix spec test issues related to error message. (eff79b5) ##2012-03-16 - Nan Liu * Fix mysql service on Ubuntu. (72da2c5) ##2012-03-16 - Dan Bode * Add more spec test coverage (55e399d) ##2012-03-16 - Nan Liu * (#11963) Fix spec test due to path changes. (1700349) ##2012-03-07 - François Charlier * Add a test to check path for 'mysqld-restart' (b14c7d1) ##2012-03-07 - François Charlier * Fix path for 'mysqld-restart' (1a9ae6b) ##2012-03-15 - Dan Bode * Add rspec-puppet tests for mysql::config (907331a) ##2012-03-15 - Dan Bode * Moved class dependency between sever and config to server (da62ad6) ##2012-03-14 - Dan Bode * Notify mysql restart from set_mysql_rootpw exec (0832a2c) ##2012-03-15 - Nan Liu * Add documentation related to osfamily fact. (8265d28) ##2012-03-14 - Dan Bode * Mention osfamily value in failure message (e472d3b) ##2012-03-14 - Dan Bode * Fix bug when querying for all database users (015490c) ##2012-02-09 - Nan Liu * Major refactor of mysql module. (b1f90fd) ##2012-01-11 - Justin Ellison * Ruby and Python's MySQL libraries are named differently on different distros. (1e926b4) ##2012-01-11 - Justin Ellison * Per @ghoneycutt, we should fail explicitly and explain why. (09af083) ##2012-01-11 - Justin Ellison * Removing duplicate declaration (7513d03) ##2012-01-10 - Justin Ellison * Use socket value from params class instead of hardcoding. (663e97c) ##2012-01-10 - Justin Ellison * Instead of hardcoding the config file target, pull it from mysql::params (031a47d) ##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 * 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 * Changed the README to use markdown (3b7dfeb) ##2012-02-04 - Daniel Black * (#12412) mysqltuner.pl update (b809e6f) ##2011-11-17 - Matthias Pigulla * (#11363) Add two missing privileges to grant: event_priv, trigger_priv (d15c9d1) ##2011-12-20 - Jeff McCune * (minor) Fixup typos in Modulefile metadata (a0ed6a1) ##2011-12-19 - Carl Caum * Only notify Exec to import sql if sql is given (0783c74) ##2011-12-19 - Carl Caum * (#11508) Only load sql_scripts on DB creation (e3b9fd9) ##2011-12-13 - Justin Ellison * Require not needed due to implicit dependencies (3058feb) ##2011-12-13 - Justin Ellison * Bug #11375: puppetlabs-mysql fails on CentOS/RHEL (a557b8d) ##2011-06-03 - Dan Bode - 0.0.1 * initial commit puppetlabs-mysql-3.6.1/checksums.json000644 000765 000024 00000017451 12600353524 020361 0ustar00morganstaff000000 000000 { "CHANGELOG.md": "8cb84c954e5333229cdafae4fbdbac50", "CONTRIBUTING.md": "ad65d271f183b5adb9fdd58207939f5f", "Gemfile": "88232482e212d61ac1130f3754ceea71", "LICENSE": "6089b6bd1f0d807edb8bdfd76da0b038", "README.md": "ee38a93d87f069295e16ad5665912c3d", "Rakefile": "d953eb985f82600dc3b9ac6e1f2cfe64", "TODO": "88ca4024a37992b46c34cb46e4ac39e6", "examples/backup.pp": "a61c6f34f153a323209faf25948737f5", "examples/bindings.pp": "35a8387f5c55fa2e479c513a67918674", "examples/java.pp": "0ad9de4f9f2c049642bcf08124757085", "examples/mysql_database.pp": "107ee8793f7b4a12cfca32eddccc6bbd", "examples/mysql_db.pp": "55d2d603f9fb8ab3c8a781d08119aa69", "examples/mysql_grant.pp": "cd42336a6c7b2d27f5d5d6d0e310ee1a", "examples/mysql_plugin.pp": "4f86c988a99b131e736501a309604e94", "examples/mysql_user.pp": "0b76964aebb01714745548e0f2f32fd3", "examples/perl.pp": "454f14dc4492fcf04afbe81b2776917e", "examples/python.pp": "355a7e1ea3978a8fd290b5bc28b63808", "examples/ruby.pp": "a6ae0381aacc5a8d2c403e606c6df0f0", "examples/server/account_security.pp": "375442b7886c01b42fbf75a1fcb31822", "examples/server/config.pp": "659b7c40e9b55634721b3c33a8c6da98", "examples/server.pp": "72e22552a95b9a5e4a349dbfc13639dc", "lib/facter/mysql_server_id.rb": "2102724316f84a45906880d9551ef125", "lib/facter/mysql_version.rb": "e30648f3d394a1cbdd4e54eb5c28d28c", "lib/puppet/parser/functions/mysql_deepmerge.rb": "2b5040ee8cd75a81cf881851e922833a", "lib/puppet/parser/functions/mysql_dirname.rb": "820ba09a6a0df639da560b41cb31242f", "lib/puppet/parser/functions/mysql_password.rb": "100a3fa5ccb4f50c96d7f5167d43737f", "lib/puppet/parser/functions/mysql_strip_hash.rb": "3efe69f1eb189b2913e178b8472aaede", "lib/puppet/provider/mysql.rb": "881f4f76b084054f7299fe2de596e4c9", "lib/puppet/provider/mysql_database/mysql.rb": "5cf9b8044df4ec72a726b5f781c84f8f", "lib/puppet/provider/mysql_grant/mysql.rb": "211b6fb362e340f60a8ce32006349730", "lib/puppet/provider/mysql_plugin/mysql.rb": "49128d2a9a547c4945735bfd75fd6d6c", "lib/puppet/provider/mysql_user/mysql.rb": "3af9f573524a516e2ecd6d0830a92c62", "lib/puppet/type/mysql_database.rb": "438eafbfecc30605462a220d92cf9603", "lib/puppet/type/mysql_grant.rb": "2c04c9df671fc9c91d85cb2487d14ece", "lib/puppet/type/mysql_plugin.rb": "0a52cead6c9283c9aa14ea71bdfa80bd", "lib/puppet/type/mysql_user.rb": "e8dc61e4d81244d58a71b0d8aa01ac76", "manifests/backup/mysqlbackup.pp": "3e97fe877ff4b151eb634ea83a84419c", "manifests/backup/mysqldump.pp": "9883500deb8829cd70cf9a60120b80aa", "manifests/backup/xtrabackup.pp": "6c809f8ba7973b4faaf29badfcbe8469", "manifests/bindings/client_dev.pp": "80753f1bf48de71d2ca1a6cfda4830be", "manifests/bindings/daemon_dev.pp": "94d2d74afc2b247593877cebd548ed76", "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/client/install.pp": "7b5810404cc9411ec38de404749f1266", "manifests/client.pp": "c350bd6d108acb03a87b860b14d225ef", "manifests/db.pp": "109ea3b19c342c645383df511e6a2782", "manifests/params.pp": "c505d22c458faafbb4767adb1a0df5af", "manifests/server/account_security.pp": "407e8c4bd6f2467927b23f241fc556e3", "manifests/server/backup.pp": "c982860f7e8ac525e3ede3045fdda516", "manifests/server/config.pp": "38610a61d097080a655aad5ee1489159", "manifests/server/install.pp": "3cbbf313b940b582e73c229f4a8c0720", "manifests/server/installdb.pp": "639834afb24583aa6685b9b2b4749f69", "manifests/server/monitor.pp": "3810b5d756a3661e92d709115982cd59", "manifests/server/mysqltuner.pp": "c966679bff1296e875a9ec1462a022f4", "manifests/server/providers.pp": "87a019dce5bbb6b18c9aa61b5f99134c", "manifests/server/root_password.pp": "956b7c181b1e14517811fa94b151eceb", "manifests/server/service.pp": "1278f5cb267024760e1299c99dc1bf80", "manifests/server.pp": "a3fe8f65e57466af28b7581847cef8b4", "metadata.json": "effbf2f5768d08a7bc8152c0d2f43eea", "spec/acceptance/mysql_backup_spec.rb": "57cb101519fce1ad588fd60f3435d57c", "spec/acceptance/mysql_db_spec.rb": "a7d0d87f1d51d9914b00c849fc694083", "spec/acceptance/mysql_server_spec.rb": "0d7abdd7699fac5acc76ec6b4f9ebb46", "spec/acceptance/nodesets/centos-510-x64.yml": "5698f7e61292730c603e03f64fe19359", "spec/acceptance/nodesets/centos-59-x64.yml": "57eb3e471b9042a8ea40978c467f8151", "spec/acceptance/nodesets/centos-64-x64-pe.yml": "ec075d95760df3d4702abea1ce0a829b", "spec/acceptance/nodesets/centos-65-x64.yml": "3e5c36e6aa5a690229e720f4048bb8af", "spec/acceptance/nodesets/default.yml": "76d6d770f3daf53ef1b9a17cd0163290", "spec/acceptance/nodesets/fedora-18-x64.yml": "80e41b1ee16ea489f53164bfdae58855", "spec/acceptance/nodesets/sles-11-x64.yml": "44e4c6c15c018333bfa9840a5e702f66", "spec/acceptance/nodesets/ubuntu-server-10044-x64.yml": "75e86400b7889888dc0781c0ae1a1297", "spec/acceptance/nodesets/ubuntu-server-12042-x64.yml": "d30d73e34cd50b043c7d14e305955269", "spec/acceptance/nodesets/ubuntu-server-1404-x64.yml": "5f0aed10098ac5b78e4217bb27c7aaf0", "spec/acceptance/types/mysql_database_spec.rb": "047db055103fa9782bc6714297eb2a09", "spec/acceptance/types/mysql_grant_spec.rb": "f9217261e7bae6b63ea46aaa880ebfba", "spec/acceptance/types/mysql_plugin_spec.rb": "e41e1df4997f57d70db4aaff8b0a1549", "spec/acceptance/types/mysql_user_spec.rb": "7ae65d682141d2b6005adeafc4ce4698", "spec/classes/graceful_failures_spec.rb": "47acbf0ef4b19ba26055b927b24d8a95", "spec/classes/mycnf_template_spec.rb": "c37c8eb3dce1c4e913b5b3a60c80d5cb", "spec/classes/mysql_bindings_spec.rb": "fd66517c1c61afdf5a4a13c096fb7288", "spec/classes/mysql_client_spec.rb": "7373be9edd90c54769a66e8af914b852", "spec/classes/mysql_server_account_security_spec.rb": "22e2b1cb11bd284e02b35e86ff6704cf", "spec/classes/mysql_server_backup_spec.rb": "5f049e1581345c6afbfb2b46aea07e17", "spec/classes/mysql_server_monitor_spec.rb": "99e2b530a11e48b31b35f1a50099b8b5", "spec/classes/mysql_server_mysqltuner_spec.rb": "4d5f354c4eae5a096166df1099b93f6b", "spec/classes/mysql_server_spec.rb": "b12a8e7723ca1aff415ba269bfe9d29d", "spec/defines/mysql_db_spec.rb": "a69768ea38014520866bda65948c15c1", "spec/spec.opts": "a600ded995d948e393fbe2320ba8e51c", "spec/spec_helper.rb": "70cdee91641a840b7397d6ef34e5946e", "spec/spec_helper_acceptance.rb": "100dc861896453159dcdc1577126b599", "spec/unit/facter/mysql_server_id_spec.rb": "3b5aeea6d264064032454ed60bc3f60f", "spec/unit/facter/mysql_version_spec.rb": "f593c725b83a7bbf1f0fdc13bf1531df", "spec/unit/puppet/functions/mysql_deepmerge_spec.rb": "f6102e1f82fb9f4aa38cbf3955ee5973", "spec/unit/puppet/functions/mysql_password_spec.rb": "388c74f0a3b46ecc008e84ec6eda70f4", "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": "b72cedb4003c6591b9b4eec62ef89c11", "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": "ededed596db6661ea769aa333decc785", "templates/meb.cnf.erb": "b6422b19ee97b8a2883bfac44fdc0292", "templates/my.cnf.erb": "701e3cd51d99fbd3ec60a68aaa1c8417", "templates/my.cnf.pass.erb": "75e3d0aaa6bf2d92cdaae387a3da65a7", "templates/mysqlbackup.sh.erb": "52a4ce563dd3f2dd9c5b1fc1397a3a79", "templates/xtrabackup.sh.erb": "219b487c4faad80a897cda6973b81741" }puppetlabs-mysql-3.6.1/CONTRIBUTING.md000644 000765 000024 00000017501 12600353444 017727 0ustar00morganstaff000000 000000 Checklist (and a short version for the impatient) ================================================= * Commits: - Make commits of logical units. - Check for unnecessary whitespace with "git diff --check" before committing. - Commit using Unix line endings (check the settings around "crlf" in git-config(1)). - Do not check in commented out code or unneeded files. - 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. - Associate the issue in the message. The first line should include the issue number in the form "(#XXXX) Rest of message". - The body should provide a meaningful commit message, which: - uses the imperative, present tense: "change", not "changed" or "changes". - includes motivation for the change, and contrasts its implementation with the previous behavior. - Make sure that you have tests for the bug you are fixing, or feature you are adding. - Make sure the test suites passes after your commit: `bundle exec rspec spec/acceptance` More information on [testing](#Testing) below - When introducing a new feature, make sure it is properly documented in the README.md * Submission: * Pre-requisites: - Make sure you have a [GitHub account](https://github.com/join) - [Create a ticket](https://tickets.puppetlabs.com/secure/CreateIssue!default.jspa), or [watch the ticket](https://tickets.puppetlabs.com/browse/) you are patching for. * Preferred method: - Fork the repository on GitHub. - 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). - Submit a pull request to the repository in the puppetlabs organization. The long version ================ 1. Make separate commits for logically separate changes. Please break your commits down into logically consistent units which include new or changed tests relevant to the rest of the change. The goal of doing this is to make the diff easier to read for whoever is reviewing your code. In general, the easier your diff is to read, the more likely someone will be happy to review it and get it into the code base. If you are going to refactor a piece of code, please do so as a separate commit from your feature or bug fix changes. We also really appreciate changes that include tests to make sure the bug is not re-introduced, and that the feature is not accidentally broken. Describe the technical detail of the change(s). If your description starts to get too long, that is a good sign that you probably need to split up your commit into more finely grained pieces. Commits which plainly describe the things which help reviewers check the patch and future developers understand the code are much more likely to be merged in with a minimum of bike-shedding or requested changes. Ideally, the commit message would include information, and be in a form suitable for inclusion in the release notes for the version of Puppet that includes them. Please also check that you are not introducing any trailing whitespace or other "whitespace errors". You can do this by running "git diff --check" on your changes before you commit. 2. Sending your patches To submit your changes via a GitHub pull request, we _highly_ recommend that you have them on a topic branch, instead of directly on "master". It makes things much easier to keep track of, especially if you decide to work on another thing before your first change is merged in. 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/). 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 GitHub issue. If there is a GitHub 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 ======= 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, 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 ```shell % bundle install Fetching gem metadata from https://rubygems.org/........ Fetching gem metadata from https://rubygems.org/.. Using rake (10.1.0) Using builder (3.2.2) -- 8><-- many more --><8 -- Using rspec-system-puppet (2.2.0) Using serverspec (0.6.3) Using rspec-system-serverspec (1.0.0) Using bundler (1.3.5) Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed. ``` 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: ```shell % bundle update ``` With all dependencies in place and up-to-date we can now run the 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), 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. You can run them by issuing the following command ```shell % bundle exec rake spec_clean % bundle exec rspec spec/acceptance ``` 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) and then run all the tests under [spec/acceptance](./spec/acceptance). Writing Tests ------------- XXX getting started writing tests. If you have commit access to the repository =========================================== 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. Having someone other than the author of the topic branch recorded as performing the merge is the record that they performed the code review. Additional Resources ==================== * [Getting additional help](http://puppetlabs.com/community/get-help) * [Writing tests](http://projects.puppetlabs.com/projects/puppet/wiki/Development_Writing_Tests) * [Patchwork](https://patchwork.puppetlabs.com) * [General GitHub documentation](http://help.github.com/) * [GitHub pull request documentation](http://help.github.com/send-pull-requests/) puppetlabs-mysql-3.6.1/examples/000755 000765 000024 00000000000 12600353524 017307 5ustar00morganstaff000000 000000 puppetlabs-mysql-3.6.1/Gemfile000644 000765 000024 00000002606 12600353444 016771 0ustar00morganstaff000000 000000 source ENV['GEM_SOURCE'] || "https://rubygems.org" def location_for(place, fake_version = nil) if place =~ /^(git[:@][^#]*)#(.*)/ [fake_version, { :git => $1, :branch => $2, :require => false }].compact elsif place =~ /^file:\/\/(.*)/ ['>= 0', { :path => File.expand_path($1), :require => false }] else [place, { :require => false }] end end group :development, :unit_tests do gem 'rspec-core', '3.1.7', :require => false gem 'puppetlabs_spec_helper', :require => false gem 'simplecov', :require => false gem 'puppet_facts', :require => false gem 'json', :require => false gem 'metadata-json-lint', :require => false end group :system_tests do if beaker_version = ENV['BEAKER_VERSION'] gem 'beaker', *location_for(beaker_version) end if beaker_rspec_version = ENV['BEAKER_RSPEC_VERSION'] gem 'beaker-rspec', *location_for(beaker_rspec_version) else gem 'beaker-rspec', :require => false end gem 'serverspec', :require => false gem 'beaker-puppet_install_helper', :require => false end if facterversion = ENV['FACTER_GEM_VERSION'] gem 'facter', facterversion, :require => false else gem 'facter', :require => false end if puppetversion = ENV['PUPPET_GEM_VERSION'] gem 'puppet', puppetversion, :require => false else gem 'puppet', :require => false end # vim:ft=ruby puppetlabs-mysql-3.6.1/lib/000755 000765 000024 00000000000 12600353524 016237 5ustar00morganstaff000000 000000 puppetlabs-mysql-3.6.1/LICENSE000644 000765 000024 00000026114 12600353444 016503 0ustar00morganstaff000000 000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright 2013 Puppet Labs Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software 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. puppetlabs-mysql-3.6.1/manifests/000755 000765 000024 00000000000 12600353524 017462 5ustar00morganstaff000000 000000 puppetlabs-mysql-3.6.1/metadata.json000644 000765 000024 00000003457 12600353524 020155 0ustar00morganstaff000000 000000 { "name": "puppetlabs-mysql", "version": "3.6.1", "author": "Puppet Labs", "summary": "Installs, configures, and manages the MySQL service.", "license": "Apache-2.0", "source": "git://github.com/puppetlabs/puppetlabs-mysql.git", "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":"nanliu/staging","version_requirement":">= 1.0.1 < 2.0.0"} ], "operatingsystem_support": [ { "operatingsystem": "RedHat", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "CentOS", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "OracleLinux", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "Scientific", "operatingsystemrelease": [ "5", "6", "7" ] }, { "operatingsystem": "SLES", "operatingsystemrelease": [ "11 SP1", "12" ] }, { "operatingsystem": "Debian", "operatingsystemrelease": [ "6", "7" ] }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "10.04", "12.04", "14.04" ] }, { "operatingsystem": "Solaris", "operatingsystemrelease": [ "11.2", "11.3", "12.0" ] } ], "requirements": [ { "name": "pe", "version_requirement": ">= 3.0.0 < 2015.3.0" }, { "name": "puppet", "version_requirement": ">= 3.0.0 < 5.0.0" } ], "description": "Mysql module" } puppetlabs-mysql-3.6.1/Rakefile000644 000765 000024 00000000766 12600353444 017150 0ustar00morganstaff000000 000000 require 'puppetlabs_spec_helper/rake_tasks' require 'puppet-lint/tasks/puppet-lint' PuppetLint.configuration.fail_on_warnings = true PuppetLint.configuration.send('relative') PuppetLint.configuration.send('disable_80chars') PuppetLint.configuration.send('disable_class_inherits_from_params_class') PuppetLint.configuration.send('disable_documentation') PuppetLint.configuration.send('disable_single_quote_string_with_variables') PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"] puppetlabs-mysql-3.6.1/README.md000644 000765 000024 00000062347 12600353444 016765 0ustar00morganstaff000000 000000 # mysql #### Table of Contents 1. [Module Description - What the module does and why it is useful](#module-description) 2. [Backwards compatibility information](#backwards-compatibility) 3. [Setup - The basics of getting started with mysql](#setup) * [Beginning with mysql](#beginning-with-mysql) 4. [Usage - Configuration options and additional functionality](#usage) * [Customizing Server Options](#customizing-server-options) * [Creating a Database](#creating-a-database) * [Custom Configuration](#custom-configuration) 5. [Reference - An under-the-hood peek at what the module is doing and how](#reference) 6. [Limitations - OS compatibility, etc.](#limitations) 7. [Development - Guide for contributing to the module](#development) ## Module Description The MySQL module installs, configures, and manages the MySQL service. The MySQL module manages both the installation and configuration of MySQL, as well as extending Puppet to allow management of MySQL resources, such as databases, users, and grants. ## Setup ### Beginning with MySQL If you want a server installed with the default options you can run `include '::mysql::server'`. If you need to customize options, such as the root password or `/etc/my.cnf` settings, then you must also pass in an override hash: ~~~ class { '::mysql::server': root_password => 'strongpassword', remove_default_accounts => true, override_options => $override_options } ~~~ See [**Customizing Server Options**](#customizing-server-options) below for examples of the hash structure for $override_options`. ## Usage All interaction for the server is done via `mysql::server`. To install the client, use `mysql::client`. To install bindings, use `mysql::bindings`. ### Customizing Server Options The hash structure for overrides in `mysql::server` can be structured like a hash in the my.cnf file, so: ~~~ $override_options = { 'section' => { 'item' => 'thing', } } ~~~ For items that you would traditionally represent as ~~~ [section] 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. MySQL doesn't care if 'thing' is alone or set to a value; it happily accepts both. To keep an option out of the my.cnf file --- e.g., when using `override_options` to revert to a default value --- you can pass `thing => undef`. If an option needs multiple instances, you can pass an array. For example, ~~~ $override_options = { 'mysqld' => { 'replicate-do-db' => ['base1', 'base2'], } } ~~~ produces ~~~ [mysqld] replicate-do-db = base1 replicate-do-db = base2 ~~~ ### Creating a database To use `mysql::db` to create a database with a user and assign some privileges: ~~~ mysql::db { 'mydb': user => 'myuser', password => 'mypass', host => 'localhost', grant => ['SELECT', 'UPDATE'], } ~~~ Or to use a different resource name with exported resources: ~~~ @@mysql::db { "mydb_${fqdn}": user => 'myuser', password => 'mypass', dbname => 'mydb', host => ${fqdn}, grant => ['SELECT', 'UPDATE'], tag => $domain, } ~~~ Then you can collect it on the remote DB server: ~~~ Mysql::Db <<| tag == $domain |>> ~~~ If you set the sql param to a file when creating a database, the file gets imported into the new database. For large sql files, you should raise the $import_timeout parameter, set by default to 300 seconds. ~~~ mysql::db { 'mydb': user => 'myuser', password => 'mypass', host => 'localhost', grant => ['SELECT', 'UPDATE'], sql => '/path/to/sqlfile', import_timeout => 900, } ~~~ ### Custom Configuration To add custom MySQL configuration, drop additional files into `includedir`. Dropping files into `includedir` allows you to override settings or add additional ones, which is helpful if you choose not to use `override_options` in `mysql::server`. The `includedir` location is by default set to /etc/mysql/conf.d. ### Working with an existing server You can use the MySQL module to instantiate databases and users on an existing MySQL server. For this to work, you need an appropriate `.my.cnf` in `root`'s home directory containing the remote server address and credentials. For example: [client] user=root host=localhost password=secret When working with a remote server, do *not* use the `mysql::server` class in your Puppet manifests. ## Reference ### Classes #### Public classes * [`mysql::server`](#mysqlserver): Installs and configures MySQL. * [`mysql::server::monitor`](#mysqlservermonitor): Sets up a monitoring user. * [`mysql::server::mysqltuner`](#mysqlservermysqltuner): Installs MySQL tuner script. * [`mysql::server::backup`](#mysqlserverbackup): Sets up MySQL backups via cron. * [`mysql::bindings`](#mysqlbindings): Installs various MySQL language bindings. * [`mysql::client`](#mysqlclient): Installs MySQL client (for non-servers). #### Private classes * `mysql::server::install`: Installs packages. * `mysql::server::config`: Configures MYSQL. * `mysql::server::service`: Manages service. * `mysql::server::account_security`: Deletes default MySQL accounts. * `mysql::server::root_password`: Sets MySQL root password. * `mysql::server::providers`: Creates users, grants, and databases. * `mysql::bindings::client_dev`: Installs MySQL client development package. * `mysql::bindings::daemon_dev`: Installs MySQL daemon development package. * `mysql::bindings::java`: Installs Java bindings. * `mysql::bindings::perl`: Installs Perl bindings. * `mysql::bindings::php`: Installs PHP bindings. * `mysql::bindings::python`: Installs Python bindings. * `mysql::bindings::ruby`: Installs Ruby bindings. * `mysql::client::install`: Installs MySQL client. * `mysql::backup::mysqldump`: Implements mysqldump backups. * `mysql::backup::mysqlbackup`: Implements backups with Oracle MySQL Enterprise Backup. * `mysql::backup::xtrabackup`: Implements backups with XtraBackup from Percona. ### Parameters #### mysql::server ##### `create_root_user` Specify 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. `create_root_user` can be set to 'true' on one node while it is set to 'false' on the remaining nodes. ##### `create_root_my_cnf` If set to 'true', creates `/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`. This can be used for a cluster setup with Galera where you want `/root/.my.cnf` to exist on all nodes. ##### `root_password` The MySQL root password. Puppet attempts to set the root password and update `/root/.my.cnf` with it. 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. ##### `old_root_password` This parameter no longer does anything. It exists only for backwards compatibility. See the `root_password` parameter above for details on changing the root password. ##### `override_options` The hash of override options to pass into MySQL. Structured like a hash in the my.cnf file: ~~~ $override_options = { 'section' => { 'item' => 'thing', } } ~~~ See [**Customizing Server Options**](#customizing-server-options) above for usage details. ##### `config_file` The location, as a path, of the MySQL configuration file. ##### `manage_config_file` 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` Pass [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'. ##### `restart` Whether the service should be restarted when things change. Valid values are 'true', 'false'. Defaults to 'false'. ##### `root_group` The name of the group used for root. Can be a group name or a group ID. See more about the [`group` file attribute](https://docs.puppetlabs.com/references/latest/type.html#file-attribute-group). ##### `mysql_group` The name of the group of the MySQL daemon user. Can be a group name or a group ID. See more about the [`group` file attribute](https://docs.puppetlabs.com/references/latest/type.html#file-attribute-group). ##### `package_ensure` 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. ##### `package_name` The name of the MySQL server package to install. ##### `remove_default_accounts` Specify whether to automatically include `mysql::server::account_security`. Valid values are 'true', 'false'. Defaults to 'false'. ##### `service_enabled` Specify whether the service should be enabled. Valid values are 'true', 'false'. Defaults to 'true'. ##### `service_manage` Specify 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. ##### `service_provider` 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). ~~~ 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', }, } ~~~ ##### `grants` Optional hash of grants, which are passed to [mysql_grant](#mysql_grant). ~~~ grants => { 'someuser@localhost/somedb.*' => { ensure => 'present', options => ['GRANT'], privileges => ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], table => 'somedb.*', user => 'someuser@localhost', }, } ~~~ ##### `databases` Optional hash of databases to create, which are passed to [mysql_database](#mysql_database). ~~~ databases => { 'somedb' => { ensure => 'present', charset => 'utf8', }, } ~~~ #### mysql::server::backup ##### `backupuser` MySQL user to create for backups. ##### `backuppassword` MySQL user password for backups. ##### `backupdir` Directory in which to store backups. ##### `backupdirmode` 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. ##### `backupdirgroup` 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'. ##### `backuprotate` 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'. ##### `backupdatabases` Specify an array of databases to back up. ##### `file_per_database` 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`. ##### `include_triggers` 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'. ##### `execpath` Allows you to set a custom PATH should your MySQL installation be non-standard places. Defaults to `/usr/bin:/usr/sbin:/bin:/sbin`. ##### `time` 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. ##### `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. ##### `prescript` A script that is executed before the backup begins. ##### `provider` Sets the server backup implementation. Valid values are: * `mysqldump`: Implements backups with mysqldump. Backup type: Logical. This is the default value. * `mysqlbackup`: Implements backups with MySQL Enterprise Backup from Oracle. Backup type: Physical. To use this type of backup, you'll need the `meb` package, which is available in RPM and TAR formats from Oracle. For Ubuntu, you can use [meb-deb](https://github.com/dveeden/meb-deb) to create a package from an official tarball. * `xtrabackup`: Implements backups with XtraBackup from Percona. Backup type: Physical. #### mysql::server::monitor ##### `mysql_monitor_username` The username to create for MySQL monitoring. ##### `mysql_monitor_password` The password to create for MySQL monitoring. ##### `mysql_monitor_hostname` The hostname from which the monitoring user requests are allowed access. #### mysql::server::mysqltuner **Note**: If you're using this class on a non-network-connected system, you must download the mysqltuner.pl script and have it hosted somewhere accessible via `http(s)://`, `puppet://`, `ftp://`, or a fully qualified file path. ##### `ensure` 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'. ##### `source` Parameter to optionally specify the source. If not specified, defaults to `https://github.com/major/MySQLTuner-perl/raw/${version}/mysqltuner.pl` #### mysql::bindings ##### `client_dev` Specify whether `::mysql::bindings::client_dev` should be included. Valid values are true', 'false'. Defaults to 'false'. ##### `daemon_dev` Specify whether `::mysql::bindings::daemon_dev` should be included. Valid values are 'true', 'false'. Defaults to 'false'. ##### `java_enable` Specify whether `::mysql::bindings::java` should be included. Valid values are 'true', 'false'. Defaults to 'false'. ##### `perl_enable` Specify whether `mysql::bindings::perl` should be included. Valid values are 'true', 'false'. Defaults to 'false'. ##### `php_enable` Specify whether `mysql::bindings::php` should be included. Valid values are 'true', 'false'. Defaults to 'false'. ##### `python_enable` Specify whether `mysql::bindings::python` should be included. Valid values are 'true', 'false'. Defaults to 'false'. ##### `ruby_enable` Specify whether `mysql::bindings::ruby` should be included. Valid values are 'true', 'false'. Defaults to 'false'. ##### `install_options` Pass `install_options` array to managed package resources. You must pass the [appropriate options](https://docs.puppetlabs.com/references/latest/type.html#package-attribute-install_options) for the package manager(s). ##### `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`. ##### `client_dev_package_name` 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`. ##### `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`. ##### `daemon_dev_package_name` 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`. ##### `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`. ##### `java_package_name` 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`. ##### `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`. ##### `perl_package_name` 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`. ##### `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`. ##### `php_package_name` 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`. ##### `python_package_name` 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`. ##### `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`. ##### `ruby_package_name` The name of the Ruby package to install. Only applies if `ruby_enable => true`. ##### `ruby_package_provider` What provider should be used to install the package. #### mysql::client ##### `bindings_enable` 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'. ##### `package_manage` Whether to manage the MySQL client package. Defaults to true. ##### `package_name` The name of the MySQL client package to install. ### Defines #### mysql::db ~~~ mysql_database { 'information_schema': ensure => 'present', charset => 'utf8', collate => 'utf8_swedish_ci', } mysql_database { 'mysql': ensure => 'present', charset => 'latin1', collate => 'latin1_swedish_ci', } ~~~ ##### `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. ##### `charset` The character set for the database. Defaults to 'utf8'. ##### `collate` 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'. ##### `grant` 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. ##### `enforce_sql` Specify 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` Specify 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'. ### Types #### mysql_database `mysql_database` creates and manages databases within MySQL. ##### `ensure` Whether the resource is present. Valid values are 'present', 'absent'. Defaults to 'present'. ##### `name` The name of the MySQL database to manage. ##### `charset` The CHARACTER SET setting for the database. Defaults to ':utf8'. ##### `collate` The COLLATE setting for the database. Defaults to ':utf8_general_ci'. #### mysql_user Creates and manages user grants within MySQL. ~~~ 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', } ~~~ You can also specify an authentication plugin. ~~~ mysql_user{ 'myuser'@'localhost': ensure => 'present', plugin => 'unix_socket', } ~~~ ##### `name` The name of the user, as 'username@hostname' or username@hostname. ##### `password_hash` The user's password hash of the user. Use mysql_password() for creating such a hash. ##### `max_user_connections` 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. ##### `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. ##### `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. #### mysql_grant `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`: ~~~ mysql_grant { 'root@localhost/*.*': ensure => 'present', options => ['GRANT'], privileges => ['ALL'], table => '*.*', user => 'root@localhost', } ~~~ It is possible to specify privileges down to the column level: ~~~ mysql_grant { 'root@localhost/mysql.user': ensure => 'present', privileges => ['SELECT (Host, User)'], table => 'mysql.user', user => 'root@localhost', } ~~~ ##### `ensure` 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. ##### `privileges` Privileges to grant the user. ##### `table` The table to which privileges are applied. ##### `user` User to whom privileges are granted. ##### `options` MySQL options to grant. Optional. #### mysql_plugin `mysql_plugin` can be used to load plugins into the MySQL Server. ~~~ mysql_plugin { 'auth_socket': ensure => 'present', soname => 'auth_socket.so', } ~~~ ##### `ensure` Whether the resource is present. Valid values are 'present', 'absent'. Defaults to 'present'. ##### `name` The name of the MySQL plugin to manage. ##### `soname` The library file name. ### Facts #### `mysql_version` Determines the MySQL version by parsing the output from `mysql --version` #### `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. ## Limitations This module has been tested on: * RedHat Enterprise Linux 5, 6, 7 * Debian 6, 7 * CentOS 5, 6, 7 * Ubuntu 10.04, 12.04, 14.04 * Scientific Linux 5, 6 * SLES 11 Testing on other platforms has been minimal and cannot be guaranteed. ## 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. Check out our the complete [module contribution guide](https://docs.puppetlabs.com/forge/contributing.html). ### Authors This module is based on work by David Schmitt. The following contributors have contributed to this module (beyond 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 puppetlabs-mysql-3.6.1/spec/000755 000765 000024 00000000000 12600353524 016423 5ustar00morganstaff000000 000000 puppetlabs-mysql-3.6.1/templates/000755 000765 000024 00000000000 12600353524 017467 5ustar00morganstaff000000 000000 puppetlabs-mysql-3.6.1/TODO000644 000765 000024 00000000716 12600353444 016166 0ustar00morganstaff000000 000000 The best that I can tell is that this code traces back to David Schmitt. It has been forked many times since then :) 1. you cannot add databases to an instance that has a root password 2. you have to specify username as USER@BLAH or it cannot be found 3. mysql_grant does not complain if user does not exist 4. Needs support for pre-seeding on debian 5. the types may need to take user/password 6. rather or not to configure /etc/.my.cnf should be configurable puppetlabs-mysql-3.6.1/templates/meb.cnf.erb000644 000765 000024 00000000672 12600353444 021477 0ustar00morganstaff000000 000000 ### MANAGED BY PUPPET ### <% @options.sort.map do |k,v| -%> <% if v.is_a?(Hash) -%> [<%= k %>] <% v.sort.map do |ki, vi| -%> <% if vi == true or v == '' -%> <%= ki %> <% elsif vi.is_a?(Array) -%> <% vi.each do |vii| -%> <%= ki %> = <%= vii %> <% end -%> <% elsif ![nil, '', :undef].include?(vi) -%> <%= ki %> = <%= vi %> <% end -%> <% end -%> <% end %> <% end -%> puppetlabs-mysql-3.6.1/templates/my.cnf.erb000644 000765 000024 00000001170 12600353444 021353 0ustar00morganstaff000000 000000 ### MANAGED BY PUPPET ### <% @options.sort.map do |k,v| -%> <% if v.is_a?(Hash) -%> [<%= k %>] <% v.sort.map do |ki, vi| -%> <% if ki == 'ssl-disable' or (ki =~ /^ssl/ and v['ssl-disable'] == true) -%> <% next %> <% elsif vi == true or v == '' -%> <%= ki %> <% elsif vi.is_a?(Array) -%> <% vi.each do |vii| -%> <%= ki %> = <%= vii %> <% end -%> <% elsif ![nil, '', :undef].include?(vi) -%> <%= ki %> = <%= vi %> <% end -%> <% end -%> <% end %> <% end -%> <% if @includedir and @includedir != '' %> !includedir <%= @includedir %> <% end %> puppetlabs-mysql-3.6.1/templates/my.cnf.pass.erb000644 000765 000024 00000000377 12600353444 022330 0ustar00morganstaff000000 000000 ### MANAGED BY PUPPET ### [client] user=root host=localhost <% unless scope.lookupvar('mysql::server::root_password') == 'UNSET' -%> password='<%= scope.lookupvar('mysql::server::root_password') %>' <% end -%> socket=<%= @options['client']['socket'] -%> puppetlabs-mysql-3.6.1/templates/mysqlbackup.sh.erb000755 000765 000024 00000005254 12600353444 023137 0ustar00morganstaff000000 000000 <%- if @kernel == 'Linux' -%> #!/bin/bash <%- else -%> #!/bin/sh <%- end -%> # # MySQL Backup Script # Dumps mysql databases to a file for another backup tool to pick up. # # MySQL code: # GRANT SELECT, RELOAD, LOCK TABLES ON *.* TO 'user'@'localhost' # IDENTIFIED BY 'password'; # FLUSH PRIVILEGES; # ##### START CONFIG ################################################### USER=<%= @backupuser %> PASS='<%= @backuppassword %>' DIR=<%= @backupdir %> ROTATE=<%= [ Integer(@backuprotate) - 1, 0 ].max %> PREFIX=mysql_backup_ <% if @ignore_events %> ADDITIONAL_OPTIONS="--ignore-table=mysql.event" <% else %> ADDITIONAL_OPTIONS="--events" <% end %> <%# Only include routines or triggers if we're doing a file per database -%> <%# backup. This happens if we named databases, or if we explicitly set -%> <%# file per database mode -%> <% if !@backupdatabases.empty? || @file_per_database -%> <% if @include_triggers -%> ADDITIONAL_OPTIONS="$ADDITIONAL_OPTIONS --triggers" <% else -%> ADDITIONAL_OPTIONS="$ADDITIONAL_OPTIONS --skip-triggers" <% end -%> <% if @include_routines -%> ADDITIONAL_OPTIONS="$ADDITIONAL_OPTIONS --routines" <% else -%> ADDITIONAL_OPTIONS="$ADDITIONAL_OPTIONS --skip-routines" <% end -%> <% end -%> ##### STOP CONFIG #################################################### PATH=<%= @execpath %> <%- if @kernel == 'Linux' -%> set -o pipefail <%- end -%> cleanup() { find "${DIR}/" -maxdepth 1 -type f -name "${PREFIX}*.sql*" -mtime +${ROTATE} -print0 | xargs -0 -r rm -f } <% if @delete_before_dump -%> cleanup <% end -%> <% if @backupdatabases.empty? -%> <% if @file_per_database -%> mysql -u${USER} -p${PASS} -s -r -N -e 'SHOW DATABASES' | while read dbname do mysqldump -u${USER} -p${PASS} --opt --flush-logs --single-transaction \ ${ADDITIONAL_OPTIONS} \ ${dbname} <% if @backupcompress %>| bzcat -zc <% end %>> ${DIR}/${PREFIX}${dbname}_`date +%Y%m%d-%H%M%S`.sql<% if @backupcompress %>.bz2<% end %> done <% else -%> mysqldump -u${USER} -p${PASS} --opt --flush-logs --single-transaction \ ${ADDITIONAL_OPTIONS} \ --all-databases <% if @backupcompress %>| bzcat -zc <% end %>> ${DIR}/${PREFIX}`date +%Y%m%d-%H%M%S`.sql<% if @backupcompress %>.bz2<% end %> <% end -%> <% else -%> <% @backupdatabases.each do |db| -%> mysqldump -u${USER} -p${PASS} --opt --flush-logs --single-transaction \ ${ADDITIONAL_OPTIONS} \ <%= db %><% if @backupcompress %>| bzcat -zc <% end %>> ${DIR}/${PREFIX}<%= db %>_`date +%Y%m%d-%H%M%S`.sql<% if @backupcompress %>.bz2<% end %> <% end -%> <% end -%> <% unless @delete_before_dump -%> if [ $? -eq 0 ] ; then cleanup fi <% end -%> <% if @postscript -%> <%- [@postscript].flatten.compact.each do |script|%> <%= script %> <%- end -%> <% end -%> puppetlabs-mysql-3.6.1/templates/xtrabackup.sh.erb000644 000765 000024 00000000550 12600353444 022737 0ustar00morganstaff000000 000000 <%- if @kernel == 'Linux' -%> #!/bin/bash <%- else -%> #!/bin/sh <%- end -%> # # A wrapper for Xtrabackup # <% if @prescript -%> <%- [@prescript].flatten.compact.each do |script| %> <%= script %> <%- end -%> <% end -%> innobackupex "$@" <% if @postscript -%> <%- [@postscript].flatten.compact.each do |script| %> <%= script %> <%- end -%> <% end -%> puppetlabs-mysql-3.6.1/spec/acceptance/000755 000765 000024 00000000000 12600353524 020511 5ustar00morganstaff000000 000000 puppetlabs-mysql-3.6.1/spec/classes/000755 000765 000024 00000000000 12600353524 020060 5ustar00morganstaff000000 000000 puppetlabs-mysql-3.6.1/spec/defines/000755 000765 000024 00000000000 12600353524 020040 5ustar00morganstaff000000 000000 puppetlabs-mysql-3.6.1/spec/spec.opts000644 000765 000024 00000000057 12600353444 020267 0ustar00morganstaff000000 000000 --format s --colour --loadby mtime --backtrace puppetlabs-mysql-3.6.1/spec/spec_helper.rb000644 000765 000024 00000000402 12600353444 021236 0ustar00morganstaff000000 000000 require 'puppetlabs_spec_helper/module_spec_helper' require 'puppet_facts' include PuppetFacts # The default set of platforms to test again. ENV['UNIT_TEST_PLATFORMS'] = 'centos-6-x86_64 ubuntu-1404-x86_64' PLATFORMS = ENV['UNIT_TEST_PLATFORMS'].split(' ') puppetlabs-mysql-3.6.1/spec/spec_helper_acceptance.rb000644 000765 000024 00000003566 12600353444 023422 0ustar00morganstaff000000 000000 require 'beaker-rspec' require 'beaker/puppet_install_helper' run_puppet_install_helper UNSUPPORTED_PLATFORMS = [ 'Windows', 'Solaris', 'AIX' ] RSpec.configure do |c| # Project root proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) # Readable test descriptions c.formatter = :documentation # Configure all nodes in nodeset c.before :suite do # Install module and dependencies puppet_module_install(:source => proj_root, :module_name => 'mysql') hosts.each do |host| # Required for binding tests. if fact('osfamily') == 'RedHat' version = fact("operatingsystemmajrelease") if fact('operatingsystemmajrelease') =~ /7/ || fact('operatingsystem') =~ /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') end end end end puppetlabs-mysql-3.6.1/spec/unit/000755 000765 000024 00000000000 12600353524 017402 5ustar00morganstaff000000 000000 puppetlabs-mysql-3.6.1/spec/unit/facter/000755 000765 000024 00000000000 12600353524 020646 5ustar00morganstaff000000 000000 puppetlabs-mysql-3.6.1/spec/unit/puppet/000755 000765 000024 00000000000 12600353524 020717 5ustar00morganstaff000000 000000 puppetlabs-mysql-3.6.1/spec/unit/puppet/functions/000755 000765 000024 00000000000 12600353524 022727 5ustar00morganstaff000000 000000 puppetlabs-mysql-3.6.1/spec/unit/puppet/provider/000755 000765 000024 00000000000 12600353524 022551 5ustar00morganstaff000000 000000 puppetlabs-mysql-3.6.1/spec/unit/puppet/type/000755 000765 000024 00000000000 12600353524 021700 5ustar00morganstaff000000 000000 puppetlabs-mysql-3.6.1/spec/unit/puppet/type/mysql_database_spec.rb000644 000765 000024 00000001366 12600353444 026237 0ustar00morganstaff000000 000000 require 'puppet' require 'puppet/type/mysql_database' describe Puppet::Type.type(:mysql_database) do before :each do @user = Puppet::Type.type(:mysql_database).new(:name => 'test', :charset => 'utf8', :collate => 'utf8_blah_ci') end it 'should accept a database name' do expect(@user[:name]).to eq('test') end it 'should accept a charset' do @user[:charset] = 'latin1' expect(@user[:charset]).to eq('latin1') 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 expect { Puppet::Type.type(:mysql_database).new({}) }.to raise_error(Puppet::Error, 'Title or name must be provided') end end puppetlabs-mysql-3.6.1/spec/unit/puppet/type/mysql_grant_spec.rb000644 000765 000024 00000004470 12600353444 025605 0ustar00morganstaff000000 000000 require 'puppet' require 'puppet/type/mysql_grant' describe Puppet::Type.type(:mysql_grant) do before :each do @user = Puppet::Type.type(:mysql_grant).new(:name => 'foo@localhost/*.*', :privileges => ['ALL', 'PROXY'], :table => ['*.*','@'], :user => 'foo@localhost') end it 'should accept a grant name' do expect(@user[:name]).to eq('foo@localhost/*.*') end it 'should accept ALL privileges' do @user[:privileges] = 'ALL' expect(@user[:privileges]).to eq(['ALL']) end it 'should accept PROXY privilege' do @user[:privileges] = 'PROXY' expect(@user[:privileges]).to eq(['PROXY']) end it 'should accept a table' do @user[:table] = '*.*' expect(@user[:table]).to eq('*.*') end it 'should accept @ 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') end it 'should require 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 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/ 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']) 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']) 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)']) end end end puppetlabs-mysql-3.6.1/spec/unit/puppet/type/mysql_plugin_spec.rb000644 000765 000024 00000001125 12600353444 025762 0ustar00morganstaff000000 000000 require 'puppet' require 'puppet/type/mysql_plugin' describe Puppet::Type.type(:mysql_plugin) do before :each do @plugin = Puppet::Type.type(:mysql_plugin).new(:name => 'test', :soname => 'test.so') end it 'should accept a plugin name' do expect(@plugin[:name]).to eq('test') 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 expect { Puppet::Type.type(:mysql_plugin).new({}) }.to raise_error(Puppet::Error, 'Title or name must be provided') end end puppetlabs-mysql-3.6.1/spec/unit/puppet/type/mysql_user_spec.rb000644 000765 000024 00000010304 12600353471 025441 0ustar00morganstaff000000 000000 require 'puppet' require 'puppet/type/mysql_user' describe Puppet::Type.type(:mysql_user) do context "On MySQL 5.x" do let(:facts) {{ :mysql_version => '5.6.24' }} it 'should fail 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/ end end context "On MariaDB 10.0.0+" do let(:facts) {{ :mysql_version => '10.0.19' }} it 'should succeed with a long user name on MariaDB' 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/ end end it 'should require 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 it 'should accept 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') end end context 'using foo@LocalHost' do before :each do @user = Puppet::Type.type(:mysql_user).new(:name => 'foo@LocalHost', :password_hash => 'pass') end it 'should lowercase 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 it 'should create 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 it 'should accept 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 it 'should accept a user name' do expect(@user[:name]).to eq('\'debian-sys-maint\'@localhost') end end context 'using a quoted 16 char username' do let(:facts) {{ :mysql_version => '5.6.24' }} before :each do @user = Puppet::Type.type(:mysql_user).new(:name => '"debian-sys-maint"@localhost', :password_hash => 'pass') end it 'should accept 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 let(:facts) {{ :mysql_version => '5.6.24' }} it 'should fail 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/ 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 it 'should accept 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 it 'should accept 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 expect { Puppet::Type.type(:mysql_user).new(:name => '"misquoted@localhost', :password_hash => 'pass') }.to raise_error /Invalid database user "misquoted@localhost/ end end end puppetlabs-mysql-3.6.1/spec/unit/puppet/provider/mysql_database/000755 000765 000024 00000000000 12600353524 025542 5ustar00morganstaff000000 000000 puppetlabs-mysql-3.6.1/spec/unit/puppet/provider/mysql_plugin/000755 000765 000024 00000000000 12600353524 025274 5ustar00morganstaff000000 000000 puppetlabs-mysql-3.6.1/spec/unit/puppet/provider/mysql_user/000755 000765 000024 00000000000 12600353524 024754 5ustar00morganstaff000000 000000 puppetlabs-mysql-3.6.1/spec/unit/puppet/provider/mysql_user/mysql_spec.rb000644 000765 000024 00000011773 12600353444 027472 0ustar00morganstaff000000 000000 require 'spec_helper' describe Puppet::Type.type(:mysql_user).provider(:mysql) do let(:defaults_file) { '--defaults-extra-file=/root/.my.cnf' } let(:newhash) { '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5' } let(:raw_users) do <<-SQL_OUTPUT root@127.0.0.1 root@::1 @localhost debian-sys-maint@localhost root@localhost usvn_user@localhost @vagrant-ubuntu-raring-64 SQL_OUTPUT 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(:provider) { resource.provider } before :each do # Set up the stubs for an instances call. Facter.stubs(:value).with(:root_home).returns('/root') Facter.stubs(:value).with(:mysql_version).returns('5.6.24') 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', "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, PASSWORD /*!50508 , PLUGIN */ FROM mysql.user WHERE CONCAT(user, '@', host) = 'joe@localhost'"]).returns('10 10 10 10 *6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4') end let(:instance) { provider.class.instances.first } describe 'self.instances' do it 'returns an array of users' do 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, PASSWORD /*!50508 , PLUGIN */ FROM mysql.user WHERE CONCAT(user, '@', host) = '#{user}'"]).returns('10 10 10 10 ') end usernames = provider.class.instances.collect {|x| x.name } expect(parsed_users).to match_array(usernames) end end describe 'self.prefetch' do it 'exists' do provider.class.instances provider.class.prefetch({}) end end describe 'create' do it 'makes a user' do provider.expects(:mysql).with([defaults_file, '-e', "CREATE USER 'joe'@'localhost' IDENTIFIED BY PASSWORD '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4'"]) provider.expects(:mysql).with([defaults_file, '-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(:exists?).returns(true) expect(provider.create).to be_truthy end end describe 'destroy' do it 'removes a user if present' do provider.expects(:mysql).with([defaults_file, '-e', "DROP USER 'joe'@'localhost'"]) provider.expects(:exists?).returns(false) expect(provider.destroy).to be_truthy end end describe 'exists?' do it 'checks if user exists' do expect(instance.exists?).to be_truthy end end describe 'self.defaults_file' do it 'sets --defaults-extra-file' do File.stubs(:file?).with('/root/.my.cnf').returns(true) expect(provider.defaults_file).to eq '--defaults-extra-file=/root/.my.cnf' end it 'fails if file missing' do File.expects(:file?).with('/root/.my.cnf').returns(false) expect(provider.defaults_file).to be_nil end end describe 'password_hash' do it 'returns a hash' do expect(instance.password_hash).to eq('*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4') end end describe 'password_hash=' do it 'changes the hash' do provider.expects(:mysql).with([defaults_file, '-e', "SET PASSWORD FOR 'joe'@'localhost' = '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5'"]).returns('0') provider.expects(:password_hash).returns('*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5') provider.password_hash=('*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5') end end ['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') end end describe "#{property}=" do it "changes #{property}" do provider.expects(:mysql).with([defaults_file, '-e', "GRANT USAGE ON *.* TO 'joe'@'localhost' WITH #{property.upcase} 42"]).returns('0') provider.expects(property.to_sym).returns('42') provider.send("#{property}=".to_sym, '42') end end end end puppetlabs-mysql-3.6.1/spec/unit/puppet/provider/mysql_plugin/mysql_spec.rb000644 000765 000024 00000004106 12600353444 030002 0ustar00morganstaff000000 000000 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 } 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') end let(:instance) { provider.class.instances.first } describe 'self.prefetch' do it 'exists' do provider.class.instances provider.class.prefetch({}) end end describe 'create' do it 'loads a plugin' do provider.expects(:mysql).with([defaults_file, '-NBe', "install plugin #{resource[:name]} soname '#{resource[:soname]}'"]) provider.expects(:exists?).returns(true) expect(provider.create).to be_truthy end end describe 'destroy' do it 'unloads a plugin if present' do provider.expects(:mysql).with([defaults_file, '-NBe', "uninstall plugin #{resource[:name]}"]) provider.expects(:exists?).returns(false) expect(provider.destroy).to be_truthy end end describe 'exists?' do it 'checks if plugin exists' do expect(instance.exists?).to be_truthy end end describe 'self.defaults_file' do it 'sets --defaults-extra-file' do File.stubs(:file?).with('/root/.my.cnf').returns(true) expect(provider.defaults_file).to eq '--defaults-extra-file=/root/.my.cnf' end it 'fails if file missing' do File.stubs(:file?).with('/root/.my.cnf').returns(false) expect(provider.defaults_file).to be_nil end end describe 'soname' do it 'returns a soname' do expect(instance.soname).to eq('auth_socket.so') end end end puppetlabs-mysql-3.6.1/spec/unit/puppet/provider/mysql_database/mysql_spec.rb000644 000765 000024 00000007312 12600353444 030252 0ustar00morganstaff000000 000000 require 'spec_helper' describe Puppet::Type.type(:mysql_database).provider(:mysql) do let(:defaults_file) { '--defaults-extra-file=/root/.my.cnf' } let(:raw_databases) do <<-SQL_OUTPUT information_schema mydb mysql performance_schema test SQL_OUTPUT 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") 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) 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") end databases = provider.class.instances.collect {|x| x.name } expect(parsed_databases).to match_array(databases) end end describe 'self.prefetch' do it 'exists' do provider.class.instances provider.class.prefetch({}) end end 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.expects(:exists?).returns(true) expect(provider.create).to be_truthy end end describe 'destroy' do it 'removes a database if present' do provider.expects(:mysql).with([defaults_file, '-NBe', "drop database if exists `#{resource[:name]}`"]) provider.expects(:exists?).returns(false) expect(provider.destroy).to be_truthy end end describe 'exists?' do it 'checks if database exists' do expect(instance.exists?).to be_truthy end end describe 'self.defaults_file' do it 'sets --defaults-extra-file' do File.stubs(:file?).with('/root/.my.cnf').returns(true) expect(provider.defaults_file).to eq '--defaults-extra-file=/root/.my.cnf' end it 'fails if file missing' do File.stubs(:file?).with('/root/.my.cnf').returns(false) expect(provider.defaults_file).to be_nil end end describe 'charset' do it 'returns a charset' do expect(instance.charset).to eq('latin1') end end 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.charset=('blah') end end describe 'collate' do it 'returns a collate' do expect(instance.collate).to eq('latin1_swedish_ci') end end describe 'collate=' do it 'changes the collate' do provider.expects(:mysql).with([defaults_file, '-NBe', "alter database `#{resource[:name]}` COLLATE blah"]).returns('0') provider.collate=('blah') end end end puppetlabs-mysql-3.6.1/spec/unit/puppet/functions/mysql_deepmerge_spec.rb000644 000765 000024 00000007426 12600353444 027462 0ustar00morganstaff000000 000000 #! /usr/bin/env ruby -S rspec require 'spec_helper' describe Puppet::Parser::Functions.function(:mysql_deepmerge) do 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\./ Puppet[:code] = '$x = mysql_deepmerge()' expect { scope.compiler.compile }.to raise_error(Puppet::ParseError, /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\./ 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/) 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/) end it 'should accept empty strings as puppet undef' do expect { new_hash = scope.function_mysql_deepmerge([{}, ''])}.not_to raise_error 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'}]) expect(hash['one']).to eq('3') end it 'should accept 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 }) 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 }) 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 }) end it 'should append 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 }) end it 'should equate keys mod dash and underscore' do hash = scope.function_mysql_deepmerge([{ 'a-b-c' => 1 } , { 'a_b_c' => 10 }]) expect(hash['a_b_c']).to eq(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') end end end puppetlabs-mysql-3.6.1/spec/unit/puppet/functions/mysql_password_spec.rb000644 000765 000024 00000001742 12600353444 027362 0ustar00morganstaff000000 000000 require 'spec_helper' describe 'the mysql_password function' do before :all do Puppet::Parser::Functions.autoloader.loadall end let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it 'should exist' 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)) 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)) end it 'should convert 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([""]) expect(result).to(eq('')) end end puppetlabs-mysql-3.6.1/spec/unit/facter/mysql_server_id_spec.rb000644 000765 000024 00000001137 12600353444 025417 0ustar00morganstaff000000 000000 require "spec_helper" describe Facter::Util::Fact do before { Facter.clear } 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') end it do Facter.fact(:mysql_server_id).value.to_s.should == '72898961' end end context "node with lo only" do before :each do Facter.fact(:macaddress).stubs(:value).returns('00:00:00:00:00:00') end it do Facter.fact(:mysql_server_id).value.to_s.should == '0' end end end end puppetlabs-mysql-3.6.1/spec/unit/facter/mysql_version_spec.rb000644 000765 000024 00000000675 12600353444 025130 0ustar00morganstaff000000 000000 require "spec_helper" describe Facter::Util::Fact do before { Facter.clear } 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') end it { expect(Facter.fact(:mysql_version).value).to eq('5.0.95') } end end end puppetlabs-mysql-3.6.1/spec/defines/mysql_db_spec.rb000644 000765 000024 00000006131 12600353444 023213 0ustar00morganstaff000000 000000 require 'spec_helper' describe 'mysql::db', :type => :define do on_pe_supported_platforms(PLATFORMS).each do |pe_version,pe_platforms| pe_platforms.each do |pe_platform,facts| describe "on #{pe_version} #{pe_platform}" do let(:facts) { facts } let(:title) { 'test_db' } let(:params) { { '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'\./) end it 'should 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'}) 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}) 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}) is_expected.to contain_exec('test_db-import').with_refreshonly(false) is_expected.to contain_exec('test_db-import').with_command("cat 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']}) 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'}) is_expected.to contain_mysql_database('test_db').with_ensure('absent') 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', }) end it 'should use dbname parameter as database name instead of name' do params.merge!({'dbname' => 'real_db'}) is_expected.to contain_mysql_database('real_db') end end end end end puppetlabs-mysql-3.6.1/spec/classes/graceful_failures_spec.rb000644 000765 000024 00000000660 12600353444 025104 0ustar00morganstaff000000 000000 require 'spec_helper' describe 'mysql::server' do on_pe_unsupported_platforms.each do |pe_version,pe_platforms| pe_platforms.each do |pe_platform,facts| describe "on #{pe_version} #{pe_platform}" do let(:facts) { facts } context 'should gracefully fail' do it { expect { is_expected.to compile}.to raise_error(Puppet::Error, /Unsupported platform:/) } end end end end end puppetlabs-mysql-3.6.1/spec/classes/mycnf_template_spec.rb000644 000765 000024 00000006263 12600353444 024436 0ustar00morganstaff000000 000000 require 'spec_helper' describe 'mysql::server' do context 'my.cnf template' do on_pe_supported_platforms(PLATFORMS).each do |pe_version,pe_platforms| pe_platforms.each do |pe_platform,facts| describe "on #{pe_version} #{pe_platform}" do let(:facts) { facts } 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 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 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 '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/) } 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 '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 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 it { is_expected.to contain_file('mysql-config-file').with_content(/!includedir/) } 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').without_content(/!includedir/) } end end end end end end puppetlabs-mysql-3.6.1/spec/classes/mysql_bindings_spec.rb000644 000765 000024 00000002160 12600353444 024441 0ustar00morganstaff000000 000000 require 'spec_helper' describe 'mysql::bindings' do on_pe_supported_platforms(PLATFORMS).each do |pe_version,pe_platforms| pe_platforms.each do |pe_platform,facts| describe "on #{pe_version} #{pe_platform}" do let(:facts) { facts } 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', }} it { is_expected.to contain_package('mysql-connector-java') } it { is_expected.to contain_package('perl_mysql') } it { is_expected.to contain_package('python-mysqldb') } it { is_expected.to contain_package('ruby_mysql') } it { is_expected.to contain_package('mysql-client_dev') } it { is_expected.to contain_package('mysql-daemon_dev') } end end end end puppetlabs-mysql-3.6.1/spec/classes/mysql_client_spec.rb000644 000765 000024 00000002063 12600353444 024124 0ustar00morganstaff000000 000000 require 'spec_helper' describe 'mysql::client' do on_pe_supported_platforms(PLATFORMS).each do |pe_version,pe_platforms| pe_platforms.each do |pe_platform,facts| describe "on #{pe_version} #{pe_platform}" do let(:facts) { facts } context 'with defaults' do it { is_expected.not_to contain_class('mysql::bindings') } it { is_expected.to contain_package('mysql_client') } end context 'with bindings enabled' do 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 }} it { is_expected.to contain_package('mysql_client') } end context 'with package_manage set to false' do let(:params) {{ :package_manage => false }} it { is_expected.not_to contain_package('mysql_client') } end end end end end puppetlabs-mysql-3.6.1/spec/classes/mysql_server_account_security_spec.rb000644 000765 000024 00000004305 12600353444 027620 0ustar00morganstaff000000 000000 require 'spec_helper' describe 'mysql::server::account_security' do on_pe_supported_platforms(PLATFORMS).each do |pe_version,pe_platforms| pe_platforms.each do |pe_platform,facts| describe "on #{pe_version} #{pe_platform}" do let(:facts) { facts.merge({: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 is_expected.to contain_mysql_user(user).with_ensure('absent') end end # 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 is_expected.to contain_mysql_user(user).with_ensure('absent') end end it 'should remove Mysql_database[test]' do is_expected.to contain_mysql_database('test').with_ensure('absent') end end describe "on #{pe_version} #{pe_platform} with fqdn==localhost" do let(:facts) { facts.merge({: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 is_expected.to contain_mysql_user(user).with_ensure('absent') end end end describe "on #{pe_version} #{pe_platform} with fqdn==localhost.localdomain" do let(:facts) { facts.merge({: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 is_expected.to contain_mysql_user(user).with_ensure('absent') end end end end end end puppetlabs-mysql-3.6.1/spec/classes/mysql_server_backup_spec.rb000644 000765 000024 00000032731 12600353444 025506 0ustar00morganstaff000000 000000 require 'spec_helper' describe 'mysql::server::backup' do on_pe_supported_platforms(PLATFORMS).each do |pe_version,pe_platforms| pe_platforms.each do |pe_platform,facts| describe "on #{pe_version} #{pe_platform}" do let(:facts) { facts } let(:default_params) { { 'backupuser' => 'testuser', 'backuppassword' => 'testpass', 'backupdir' => '/tmp', 'backuprotate' => '25', 'delete_before_dump' => true, 'execpath' => '/usr/bin:/usr/sbin:/bin:/sbin:/opt/zimbra/bin', } } 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_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) 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]') } end 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('mysqlbackupdir').with( :path => '/tmp', :ensure => 'directory' )} it 'should have compression by default' do is_expected.to contain_file('mysqlbackup.sh').with_content( /bzcat -zc/ ) end it 'should skip backing up events table by default' do is_expected.to contain_file('mysqlbackup.sh').with_content( /ADDITIONAL_OPTIONS="--ignore-table=mysql.event"/ ) end it 'should not mention triggers by default because file_per_database is false' do is_expected.to contain_file('mysqlbackup.sh').without_content( /.*triggers.*/ ) end it 'should not mention routines by default because file_per_database is false' do is_expected.to contain_file('mysqlbackup.sh').without_content( /.*routines.*/ ) end it 'should have 25 days of rotation' do # MySQL counts from 0 is_expected.to contain_file('mysqlbackup.sh').with_content(/.*ROTATE=24.*/) end it 'should have 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) end 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) end 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 is_expected.to contain_file('mysqlbackup.sh').without_content( /.*bzcat -zc.*/ ) end end context 'with mysql.events backedup' do let(:params) do { :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 'should be able to backup events table' do is_expected.to contain_file('mysqlbackup.sh').with_content( /ADDITIONAL_OPTIONS="--events"/ ) end end context 'with database list specified' do let(:params) do { :backupdatabases => ['mysql'] }.merge(default_params) end 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 is_expected.to contain_file('mysqlbackup.sh').with_content( /mysql | bzcat -zc \${DIR}\\\${PREFIX}mysql_`date'/ ) end it 'should skip backup triggers by default' do is_expected.to contain_file('mysqlbackup.sh').with_content( /ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --skip-triggers"/ ) end it 'should skip backing up routines by default' do is_expected.to contain_file('mysqlbackup.sh').with_content( /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 }) end it 'should backup triggers when asked' do is_expected.to contain_file('mysqlbackup.sh').with_content( /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 }) end it 'should skip backing up triggers when asked to skip' do is_expected.to contain_file('mysqlbackup.sh').with_content( /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 }) end it 'should backup routines when asked' do is_expected.to contain_file('mysqlbackup.sh').with_content( /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 }) end it 'should skip backing up routines when asked to skip' do is_expected.to contain_file('mysqlbackup.sh').with_content( /ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --skip-routines"/ ) end end end context 'with file per database' do let(:params) do 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.*/) end context 'with compression disabled' do let(:params) do 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.*/ ) end end it 'should skip backup triggers by default' do is_expected.to contain_file('mysqlbackup.sh').with_content( /ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --skip-triggers"/ ) end it 'should skip backing up routines by default' do is_expected.to contain_file('mysqlbackup.sh').with_content( /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 }) end it 'should backup triggers when asked' do is_expected.to contain_file('mysqlbackup.sh').with_content( /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 }) end it 'should skip backing up triggers when asked to skip' do is_expected.to contain_file('mysqlbackup.sh').with_content( /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 }) end it 'should backup routines when asked' do is_expected.to contain_file('mysqlbackup.sh').with_content( /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 }) end it 'should skip backing up routines when asked to skip' do is_expected.to contain_file('mysqlbackup.sh').with_content( /ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --skip-routines"/ ) end end end context 'with postscript' do let(:params) do default_params.merge({ :postscript => 'rsync -a /tmp backup01.local-lan:' }) end it 'should be add postscript' do is_expected.to contain_file('mysqlbackup.sh').with_content( /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:', ]}) end it 'should be 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:.*/ ) end end context 'with the xtrabackup provider' do let(:params) do default_params.merge({:provider => 'xtrabackup'}) end it 'should contain the wrapper script' do is_expected.to contain_file('xtrabackup.sh').with_content( /^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:', ] }) end it 'should contain 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:.*/ ) 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:', ] }) end it 'should contain 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:.*/ ) end end end end end end end puppetlabs-mysql-3.6.1/spec/classes/mysql_server_monitor_spec.rb000644 000765 000024 00000002051 12600353444 025720 0ustar00morganstaff000000 000000 require 'spec_helper' describe 'mysql::server::monitor' do on_pe_supported_platforms(PLATFORMS).each do |pe_version,pe_platforms| pe_platforms.each do |pe_platform,facts| describe "on #{pe_version} #{pe_platform}" do let(:facts) { facts } let :pre_condition do "include 'mysql::server'" end let :default_params do { :mysql_monitor_username => 'monitoruser', :mysql_monitor_password => 'monitorpass', :mysql_monitor_hostname => 'monitorhost', } end let :params do default_params end 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]' )} end end end end puppetlabs-mysql-3.6.1/spec/classes/mysql_server_mysqltuner_spec.rb000644 000765 000024 00000002635 12600353444 026464 0ustar00morganstaff000000 000000 require 'spec_helper' describe 'mysql::server::mysqltuner' do on_pe_supported_platforms(PLATFORMS).each do |pe_version,pe_platforms| pe_platforms.each do |pe_platform,facts| describe "on #{pe_version} #{pe_platform}" do let(:facts) { facts } 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', }) } end context 'ensure => absent' do let(:params) {{ :ensure => 'absent' }} it { is_expected.to compile } it { is_expected.to contain_file('/usr/local/bin/mysqltuner').with(:ensure => 'absent') } end context 'custom version' do 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', }) } end context 'custom source' do let(:params) {{ :source => '/tmp/foo' }} it { is_expected.to compile } it { is_expected.to contain_staging__file('mysqltuner-/tmp/foo').with({ :source => '/tmp/foo', }) } end end end end end puppetlabs-mysql-3.6.1/spec/classes/mysql_server_spec.rb000644 000765 000024 00000020003 12600353471 024146 0ustar00morganstaff000000 000000 require 'spec_helper' describe 'mysql::server' do on_pe_supported_platforms(PLATFORMS).each do |pe_version,pe_platforms| pe_platforms.each do |pe_platform,facts| describe "on #{pe_version} #{pe_platform}" do let(:facts) { facts } context 'with defaults' do it { is_expected.to contain_class('mysql::server::install') } it { is_expected.to contain_class('mysql::server::config') } it { is_expected.to contain_class('mysql::server::service') } it { is_expected.to contain_class('mysql::server::root_password') } it { is_expected.to contain_class('mysql::server::providers') } end context 'with remove_default_accounts set' do let(:params) {{ :remove_default_accounts => true }} it { is_expected.to contain_class('mysql::server::account_security') } end context 'mysql::server::install' do it 'contains the package by default' do is_expected.to contain_package('mysql-server').with({ :ensure => :present, }) end context 'with package_manage set to true' do 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 }} it { is_expected.not_to contain_package('mysql-server') } end context 'with datadir overridden' do let(:params) {{ :override_options => { 'mysqld' => { 'datadir' => '/tmp' }} }} it { is_expected.to contain_exec('mysql_install_db') } end end context 'mysql::server::service' do context 'with defaults' do it { is_expected.to contain_service('mysqld') } end context 'with package_manage set to true' do 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 }} 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 }} it do is_expected.to contain_service('mysqld').with({ :ensure => :stopped }) end end context 'with log-error overridden' do let(:params) {{ :override_options => { 'mysqld' => { 'log-error' => '/tmp/error.log' }} }} it { is_expected.to contain_file('/tmp/error.log') } 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' ) } 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' }} it { is_expected.to contain_mysql_user('root@localhost') } it { is_expected.to contain_file('/root/.my.cnf').that_requires('Mysql_user[root@localhost]') } end describe 'when root_password set, create_root_user set to false' do let(:params) {{ :root_password => 'SET', :create_root_user => false }} it { is_expected.not_to contain_mysql_user('root@localhost') } it { is_expected.to contain_file('/root/.my.cnf') } end describe 'when root_password set, create_root_my_cnf set to false' do 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 }} 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' }} 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' ) } end end 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 )} 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 )} 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')} end end end end end end puppetlabs-mysql-3.6.1/spec/acceptance/mysql_backup_spec.rb000644 000765 000024 00000013430 12600353444 024544 0ustar00morganstaff000000 000000 require 'spec_helper_acceptance' require 'puppet' require 'puppet/util/package' describe 'mysql::server::backup class' do 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 version_is_greater_than(version) return Puppet::Util::Package.versioncmp(@mysql_version, version) > 0 end context 'should work with no errors' do it 'when configuring mysql backups' do pp = <<-EOS class { 'mysql::server': root_password => 'password' } mysql::db { [ 'backup1', 'backup2' ]: user => 'backup', password => 'secret', } class { 'mysql::server::backup': backupuser => 'myuser', backuppassword => 'mypassword', backupdir => '/tmp/backups', backupcompress => true, postscript => [ 'rm -rf /var/tmp/mysqlbackups', 'rm -f /var/tmp/mysqlbackups.done', 'cp -r /tmp/backups /var/tmp/mysqlbackups', 'touch /var/tmp/mysqlbackups.done', ], execpath => '/usr/bin:/usr/sbin:/bin:/sbin:/opt/zimbra/bin', } EOS 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 shell("/usr/local/sbin/mysqlbackup.sh") do |r| expect(r.stderr).to eq("") end end it 'should dump all databases to single file' do shell('ls -l /tmp/backups/mysql_backup_*-*.sql.bz2 | wc -l') do |r| expect(r.stdout).to match(/1/) expect(r.exit_code).to be_zero end end context 'should create one file per database per run' do it 'executes mysqlbackup.sh a second time' do shell('sleep 1') shell('/usr/local/sbin/mysqlbackup.sh') end it 'creates at least one backup tarball' do shell('ls -l /tmp/backups/mysql_backup_*-*.sql.bz2 | wc -l') do |r| expect(r.stdout).to match(/2/) expect(r.exit_code).to be_zero end end end end context 'with one file per database' do context 'should work with no errors' do it 'when configuring mysql backups' do pp = <<-EOS class { 'mysql::server': root_password => 'password' } mysql::db { [ 'backup1', 'backup2' ]: user => 'backup', password => 'secret', } class { 'mysql::server::backup': backupuser => 'myuser', backuppassword => 'mypassword', backupdir => '/tmp/backups', backupcompress => true, file_per_database => true, postscript => [ 'rm -rf /var/tmp/mysqlbackups', 'rm -f /var/tmp/mysqlbackups.done', 'cp -r /tmp/backups /var/tmp/mysqlbackups', 'touch /var/tmp/mysqlbackups.done', ], execpath => '/usr/bin:/usr/sbin:/bin:/sbin:/opt/zimbra/bin', } EOS 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 shell("HOME=/tmp/dontreadrootcredentials /usr/local/sbin/mysqlbackup.sh") do |r| expect(r.stderr).to eq("") end end it 'should create one file per database' do ['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.exit_code).to be_zero end end end context 'should create one file per database per run' do it 'executes mysqlbackup.sh a second time' do shell('sleep 1') shell('HOME=/tmp/dontreadrootcredentials /usr/local/sbin/mysqlbackup.sh') end it 'has one file per database per run' do ['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 end end end end end context 'with triggers and routines' do it 'when configuring mysql backups with triggers and routines' do pre_run pp = <<-EOS class { 'mysql::server': root_password => 'password' } mysql::db { [ 'backup1', 'backup2' ]: user => 'backup', password => 'secret', } package { 'bzip2': ensure => present, } class { 'mysql::server::backup': backupuser => 'myuser', backuppassword => 'mypassword', backupdir => '/tmp/backups', backupcompress => true, file_per_database => true, include_triggers => #{version_is_greater_than('5.1.5')}, include_routines => true, postscript => [ 'rm -rf /var/tmp/mysqlbackups', 'rm -f /var/tmp/mysqlbackups.done', 'cp -r /tmp/backups /var/tmp/mysqlbackups', 'touch /var/tmp/mysqlbackups.done', ], execpath => '/usr/bin:/usr/sbin:/bin:/sbin:/opt/zimbra/bin', require => Package['bzip2'], } EOS apply_manifest(pp, :catch_failures => true) end it 'should run mysqlbackup.sh with no errors' do shell("/usr/local/sbin/mysqlbackup.sh") do |r| expect(r.stderr).to eq("") end end end end puppetlabs-mysql-3.6.1/spec/acceptance/mysql_db_spec.rb000644 000765 000024 00000004145 12600353444 023667 0ustar00morganstaff000000 000000 require 'spec_helper_acceptance' describe 'mysql::db define' do describe 'creating a database' do # Using puppet_apply as a helper it 'should work with no errors' do pp = <<-EOS class { 'mysql::server': root_password => 'password' } mysql::db { 'spec1': user => 'root1', password => 'password', } EOS # Run it twice and test for idempotency apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_changes => true) expect(shell("mysql -e 'show databases;'|grep spec1").exit_code).to be_zero end end describe 'creating a database with post-sql' do # Using puppet_apply as a helper it 'should work with no errors' do pp = <<-EOS class { 'mysql::server': override_options => { 'root_password' => 'password' } } file { '/tmp/spec.sql': ensure => file, content => 'CREATE TABLE table1 (id int);', before => Mysql::Db['spec2'], } mysql::db { 'spec2': user => 'root1', password => 'password', sql => '/tmp/spec.sql', } EOS # Run it twice and test for idempotency apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_changes => true) end it 'should have the table' do expect(shell("mysql -e 'show tables;' spec2|grep table1").exit_code).to be_zero end end describe 'creating a database with dbname parameter' do # Using puppet_apply as a helper it 'should work with no errors' do pp = <<-EOS class { 'mysql::server': override_options => { 'root_password' => 'password' } } mysql::db { 'spec1': user => 'root1', password => 'password', dbname => 'realdb', } EOS # Run it twice and test for idempotency apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_changes => true) end it 'should have the database named realdb' do expect(shell("mysql -e 'show databases;'|grep realdb").exit_code).to be_zero end end end puppetlabs-mysql-3.6.1/spec/acceptance/mysql_server_spec.rb000644 000765 000024 00000004436 12600353444 024613 0ustar00morganstaff000000 000000 require 'spec_helper_acceptance' describe 'mysql class' do describe 'running puppet code' do # Using puppet_apply as a helper it 'should work with no errors' do tmpdir = default.tmpdir('mysql') pp = <<-EOS class { 'mysql::server': config_file => '#{tmpdir}/my.cnf', includedir => '#{tmpdir}/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', service_enabled => 'true', service_manage => 'true', 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', }}, grants => { 'someuser@localhost/somedb.*' => { ensure => 'present', options => ['GRANT'], privileges => ['SELECT', 'INSERT', 'UPDATE', 'DELETE'], table => 'somedb.*', user => 'someuser@localhost', }, }, databases => { 'somedb' => { ensure => 'present', charset => 'utf8', }, } } EOS apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_changes => true) end end describe 'configuration needed for syslog' do it 'should work with no errors' do pp = <<-EOS class { 'mysql::server': override_options => { 'mysqld' => { 'log-error' => undef }, 'mysqld_safe' => { 'log-error' => false, 'syslog' => true }}, } EOS apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_changes => true) end end end puppetlabs-mysql-3.6.1/spec/acceptance/nodesets/000755 000765 000024 00000000000 12600353524 022335 5ustar00morganstaff000000 000000 puppetlabs-mysql-3.6.1/spec/acceptance/types/000755 000765 000024 00000000000 12600353524 021655 5ustar00morganstaff000000 000000 puppetlabs-mysql-3.6.1/spec/acceptance/types/mysql_database_spec.rb000644 000765 000024 00000003317 12600353444 026212 0ustar00morganstaff000000 000000 require 'spec_helper_acceptance' describe 'mysql_database' do describe 'setup' do it 'should work with no errors' do pp = <<-EOS class { 'mysql::server': } EOS apply_manifest(pp, :catch_failures => true) end end describe 'creating database' do it 'should work without errors' do pp = <<-EOS mysql_database { 'spec_db': ensure => present, } EOS apply_manifest(pp, :catch_failures => true) end it 'should find the database' 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 mysql_database { 'spec_latin1': charset => 'latin1', collate => 'latin1_swedish_ci', } mysql_database { 'spec_utf8': charset => 'utf8', collate => 'utf8_general_ci', } EOS apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_changes => true) end it 'should find latin1 db' 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 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 end end puppetlabs-mysql-3.6.1/spec/acceptance/types/mysql_grant_spec.rb000644 000765 000024 00000030357 12600353444 025565 0ustar00morganstaff000000 000000 require 'spec_helper_acceptance' describe 'mysql_grant' do describe 'setup' do it 'setup mysql::server' do pp = <<-EOS class { 'mysql::server': } EOS apply_manifest(pp, :catch_failures => true) end end describe 'missing privileges for user' do it 'should fail' do pp = <<-EOS mysql_grant { 'test1@tester/test.*': ensure => 'present', table => 'test.*', user => 'test1@tester', } EOS expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/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'/) end end describe 'missing table for user' do it 'should fail' do pp = <<-EOS mysql_grant { 'atest@tester/test.*': ensure => 'present', user => 'atest@tester', privileges => ['ALL'], } EOS 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'/) end end describe 'adding privileges' do it 'should work without errors' do pp = <<-EOS mysql_grant { 'test2@tester/test.*': ensure => 'present', table => 'test.*', user => 'test2@tester', privileges => ['SELECT', 'UPDATE'], } EOS 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'/) 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 mysql_grant { 'test-2@tester/test.*': ensure => 'present', table => 'test.*', user => 'test-2@tester', privileges => ['SELECT', 'UPDATE'], } EOS apply_manifest(pp, :catch_failures => true) end it 'should find the user' 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 end end end describe 'adding privileges with invalid name' do it 'should fail' do pp = <<-EOS mysql_grant { 'test': ensure => 'present', table => 'test.*', user => 'test2@tester', privileges => ['SELECT', 'UPDATE'], } EOS expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/name must match user and table parameters/) end end describe 'adding option' do it 'should work without errors' do pp = <<-EOS mysql_grant { 'test3@tester/test.*': ensure => 'present', table => 'test.*', user => 'test3@tester', options => ['GRANT'], privileges => ['SELECT', 'UPDATE'], } EOS 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$/) expect(r.stderr).to be_empty end end end describe 'adding all privileges without table' do it 'should fail' do pp = <<-EOS mysql_grant { 'test4@tester/test.*': ensure => 'present', user => 'test4@tester', options => ['GRANT'], privileges => ['SELECT', 'UPDATE', 'ALL'], } EOS expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/table parameter is required./) end end describe 'adding all privileges' do it 'should only try to apply ALL' do pp = <<-EOS mysql_grant { 'test4@tester/test.*': ensure => 'present', table => 'test.*', user => 'test4@tester', options => ['GRANT'], privileges => ['SELECT', 'UPDATE', 'ALL'], } EOS 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/) expect(r.stderr).to be_empty end end end # Test combinations of user@host to ensure all cases work. describe 'short hostname' do it 'should apply' do pp = <<-EOS mysql_grant { 'test@short/test.*': ensure => 'present', table => 'test.*', user => 'test@short', privileges => 'ALL', } mysql_grant { 'test@long.hostname.com/test.*': ensure => 'present', table => 'test.*', user => 'test@long.hostname.com', privileges => 'ALL', } mysql_grant { 'test@192.168.5.6/test.*': ensure => 'present', table => 'test.*', user => 'test@192.168.5.6', privileges => 'ALL', } mysql_grant { 'test@2607:f0d0:1002:0051:0000:0000:0000:0004/test.*': ensure => 'present', table => 'test.*', user => 'test@2607:f0d0:1002:0051:0000:0000:0000:0004', privileges => 'ALL', } mysql_grant { 'test@::1/128/test.*': ensure => 'present', table => 'test.*', user => 'test@::1/128', privileges => 'ALL', } EOS 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'/) expect(r.stderr).to be_empty end end it 'finds long hostname' 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 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 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 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 $dbSubnet = '10.10.10.%' mysql_database { 'foo': ensure => present, } exec { 'mysql-create-table': command => '/usr/bin/mysql -NBe "CREATE TABLE foo.bar (name VARCHAR(20))"', environment => "HOME=${::root_home}", unless => '/usr/bin/mysql -NBe "SELECT 1 FROM foo.bar LIMIT 1;"', require => Mysql_database['foo'], } Mysql_grant { ensure => present, options => ['GRANT'], privileges => ['ALL'], table => '*.*', require => [ Mysql_database['foo'], Exec['mysql-create-table'] ], } mysql_grant { "user1@${dbSubnet}/*.*": user => "user1@${dbSubnet}", } mysql_grant { "user2@${dbSubnet}/foo.bar": privileges => ['SELECT', 'INSERT', 'UPDATE'], user => "user2@${dbSubnet}", table => 'foo.bar', } mysql_grant { "user3@${dbSubnet}/foo.*": privileges => ['SELECT', 'INSERT', 'UPDATE'], user => "user3@${dbSubnet}", table => 'foo.*', } mysql_grant { 'web@%/*.*': user => 'web@%', } mysql_grant { "web@${dbSubnet}/*.*": user => "web@${dbSubnet}", } mysql_grant { "web@${fqdn}/*.*": user => "web@${fqdn}", } mysql_grant { 'web@localhost/*.*': user => 'web@localhost', } EOS 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 mysql_grant { 'lowercase@localhost/*.*': user => 'lowercase@localhost', privileges => 'ALL', table => '*.*', } EOS apply_manifest(pp, :catch_failures => true) end it 'create lowercase all privs' do pp = <<-EOS mysql_grant { 'lowercase@localhost/*.*': user => 'lowercase@localhost', privileges => 'all', table => '*.*', } EOS expect(apply_manifest(pp, :catch_failures => true).exit_code).to eq(0) end end describe 'adding procedure privileges' do it 'should work without errors' do pp = <<-EOS mysql_grant { 'test2@tester/PROCEDURE test.simpleproc': ensure => 'present', table => 'PROCEDURE test.simpleproc', user => 'test2@tester', privileges => ['EXECUTE'], } EOS 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 EXECUTE ON PROCEDURE `test`.`simpleproc` TO 'test2'@'tester'/) expect(r.stderr).to be_empty end end end describe 'grants with skip-name-resolve specified' do it 'setup mysql::server' do pp = <<-EOS class { 'mysql::server': override_options => { 'mysqld' => {'skip-name-resolve' => true} }, restart => true, } EOS apply_manifest(pp, :catch_failures => true) end it 'should apply' do pp = <<-EOS mysql_grant { 'test@fqdn.com/test.*': ensure => 'present', table => 'test.*', user => 'test@fqdn.com', privileges => 'ALL', } mysql_grant { 'test@192.168.5.7/test.*': ensure => 'present', table => 'test.*', user => 'test@192.168.5.7', privileges => 'ALL', } EOS apply_manifest(pp, :catch_failures => true) end it 'should fail with fqdn' do 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'/) end it 'finds ipv4' 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 mysql_grant { 'test@fqdn.com/test.*': ensure => 'present', table => 'test.*', user => 'test@fqdn.com', privileges => 'ALL', } EOS 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/) shell("mv #{mysql_cmd}.bak #{mysql_cmd}") end it 'reset mysql::server config' do pp = <<-EOS class { 'mysql::server': restart => true, } EOS apply_manifest(pp, :catch_failures => true) end end end puppetlabs-mysql-3.6.1/spec/acceptance/types/mysql_plugin_spec.rb000644 000765 000024 00000004361 12600353444 025744 0ustar00morganstaff000000 000000 require 'spec_helper_acceptance' # Different operating systems (and therefore different versions/forks # 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\./ plugin = nil # Plugins not supported on mysql on RHEL 5 elsif fact('operatingsystemrelease') =~ /^6\./ plugin = 'example' plugin_lib = 'ha_example.so' elsif fact('operatingsystemrelease') =~ /^7\./ plugin = 'pam' plugin_lib = 'auth_pam.so' end elsif fact('osfamily') =~ /Debian/ if fact('operatingsystem') =~ /Debian/ if fact('operatingsystemrelease') =~ /^6\./ # Only available plugin is innodb which is already loaded and not unload- or reload-able plugin = nil elsif fact('operatingsystemrelease') =~ /^7\./ plugin = 'example' plugin_lib = 'ha_example.so' end elsif fact('operatingsystem') =~ /Ubuntu/ if fact('operatingsystemrelease') =~ /^10\.04/ # Only available plugin is innodb which is already loaded and not unload- or reload-able plugin = nil else plugin = 'example' plugin_lib = 'ha_example.so' end end elsif fact('osfamily') =~ /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 class { 'mysql::server': } EOS apply_manifest(pp, :catch_failures => true) end end describe 'load plugin' do it 'should work without errors' do pp = <<-EOS mysql_plugin { #{plugin}: ensure => present, soname => '#{plugin_lib}', } EOS apply_manifest(pp, :catch_failures => true) end it 'should find the plugin' 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 puppetlabs-mysql-3.6.1/spec/acceptance/types/mysql_user_spec.rb000644 000765 000024 00000004441 12600353444 025423 0ustar00morganstaff000000 000000 require 'spec_helper_acceptance' describe 'mysql_user' do describe 'setup' do it 'should work with no errors' do pp = <<-EOS class { 'mysql::server': } EOS apply_manifest(pp, :catch_failures => true) end end context 'using ashp@localhost' do describe 'adding user' do it 'should work without errors' do pp = <<-EOS mysql_user { 'ashp@localhost': password_hash => '6f8c114b58f2ce9e', } EOS apply_manifest(pp, :catch_failures => true) end it 'should find the user' 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 end end context 'using ashp-dash@localhost' do describe 'adding user' do it 'should work without errors' do pp = <<-EOS mysql_user { 'ashp-dash@localhost': password_hash => '6f8c114b58f2ce9e', } EOS apply_manifest(pp, :catch_failures => true) end it 'should find the user' 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 end end context 'using ashp@LocalHost' do describe 'adding user' do it 'should work without errors' do pp = <<-EOS mysql_user { 'ashp@LocalHost': password_hash => '6f8c114b58f2ce9e', } EOS apply_manifest(pp, :catch_failures => true) end it 'should find the user' 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 end 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:/) end } end end end puppetlabs-mysql-3.6.1/spec/acceptance/nodesets/centos-510-x64.yml000644 000765 000024 00000000377 12600353444 025305 0ustar00morganstaff000000 000000 HOSTS: centos-510-x64: roles: - master platform: el-5-x86_64 box : centos-510-x64-virtualbox-nocm box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-510-x64-virtualbox-nocm.box hypervisor : vagrant CONFIG: type: git puppetlabs-mysql-3.6.1/spec/acceptance/nodesets/centos-59-x64.yml000644 000765 000024 00000000370 12600353444 025226 0ustar00morganstaff000000 000000 HOSTS: centos-59-x64: roles: - master platform: el-5-x86_64 box : centos-59-x64-vbox4210-nocm box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-59-x64-vbox4210-nocm.box hypervisor : vagrant CONFIG: type: git puppetlabs-mysql-3.6.1/spec/acceptance/nodesets/centos-64-x64-pe.yml000644 000765 000024 00000000432 12600353444 025623 0ustar00morganstaff000000 000000 HOSTS: centos-64-x64: roles: - master - database - dashboard platform: el-6-x86_64 box : centos-64-x64-vbox4210-nocm box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box hypervisor : vagrant CONFIG: type: pe puppetlabs-mysql-3.6.1/spec/acceptance/nodesets/centos-65-x64.yml000644 000765 000024 00000000372 12600353444 025225 0ustar00morganstaff000000 000000 HOSTS: centos-65-x64: roles: - master platform: el-6-x86_64 box : centos-65-x64-vbox436-nocm box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box hypervisor : vagrant CONFIG: type: foss puppetlabs-mysql-3.6.1/spec/acceptance/nodesets/default.yml000644 000765 000024 00000000411 12600353444 024501 0ustar00morganstaff000000 000000 HOSTS: centos-64-x64: roles: - master - default platform: el-6-x86_64 box : centos-64-x64-vbox4210-nocm box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box hypervisor : vagrant CONFIG: type: foss puppetlabs-mysql-3.6.1/spec/acceptance/nodesets/fedora-18-x64.yml000644 000765 000024 00000000376 12600353444 025174 0ustar00morganstaff000000 000000 HOSTS: fedora-18-x64: roles: - master platform: fedora-18-x86_64 box : fedora-18-x64-vbox4210-nocm box_url : http://puppet-vagrant-boxes.puppetlabs.com/fedora-18-x64-vbox4210-nocm.box hypervisor : vagrant CONFIG: type: foss puppetlabs-mysql-3.6.1/spec/acceptance/nodesets/sles-11-x64.yml000644 000765 000024 00000000401 12600353444 024660 0ustar00morganstaff000000 000000 HOSTS: sles-11-x64.local: roles: - master platform: sles-11-x64 box : sles-11sp1-x64-vbox4210-nocm box_url : http://puppet-vagrant-boxes.puppetlabs.com/sles-11sp1-x64-vbox4210-nocm.box hypervisor : vagrant CONFIG: type: foss puppetlabs-mysql-3.6.1/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml000644 000765 000024 00000000436 12600353444 026777 0ustar00morganstaff000000 000000 HOSTS: ubuntu-server-10044-x64: roles: - master platform: ubuntu-10.04-amd64 box : ubuntu-server-10044-x64-vbox4210-nocm box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-10044-x64-vbox4210-nocm.box hypervisor : vagrant CONFIG: type: foss puppetlabs-mysql-3.6.1/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml000644 000765 000024 00000000436 12600353444 026777 0ustar00morganstaff000000 000000 HOSTS: ubuntu-server-12042-x64: roles: - master platform: ubuntu-12.04-amd64 box : ubuntu-server-12042-x64-vbox4210-nocm box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box hypervisor : vagrant CONFIG: type: foss puppetlabs-mysql-3.6.1/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml000644 000765 000024 00000000420 12600353444 026710 0ustar00morganstaff000000 000000 HOSTS: ubuntu-server-1404-x64: roles: - master platform: ubuntu-14.04-amd64 box : puppetlabs/ubuntu-14.04-64-nocm box_url : https://vagrantcloud.com/puppetlabs/ubuntu-14.04-64-nocm hypervisor : vagrant CONFIG: log_level : debug type: git puppetlabs-mysql-3.6.1/manifests/backup/000755 000765 000024 00000000000 12600353524 020727 5ustar00morganstaff000000 000000 puppetlabs-mysql-3.6.1/manifests/bindings/000755 000765 000024 00000000000 12600353524 021257 5ustar00morganstaff000000 000000 puppetlabs-mysql-3.6.1/manifests/bindings.pp000644 000765 000024 00000005765 12600353444 021636 0ustar00morganstaff000000 000000 # See README.md. class mysql::bindings ( $install_options = undef, # Boolean to determine if we should include the classes. $java_enable = false, $perl_enable = false, $php_enable = false, $python_enable = false, $ruby_enable = false, $client_dev = false, $daemon_dev = false, # Settings for the various classes. $java_package_ensure = $mysql::params::java_package_ensure, $java_package_name = $mysql::params::java_package_name, $java_package_provider = $mysql::params::java_package_provider, $perl_package_ensure = $mysql::params::perl_package_ensure, $perl_package_name = $mysql::params::perl_package_name, $perl_package_provider = $mysql::params::perl_package_provider, $php_package_ensure = $mysql::params::php_package_ensure, $php_package_name = $mysql::params::php_package_name, $php_package_provider = $mysql::params::php_package_provider, $python_package_ensure = $mysql::params::python_package_ensure, $python_package_name = $mysql::params::python_package_name, $python_package_provider = $mysql::params::python_package_provider, $ruby_package_ensure = $mysql::params::ruby_package_ensure, $ruby_package_name = $mysql::params::ruby_package_name, $ruby_package_provider = $mysql::params::ruby_package_provider, $client_dev_package_ensure = $mysql::params::client_dev_package_ensure, $client_dev_package_name = $mysql::params::client_dev_package_name, $client_dev_package_provider = $mysql::params::client_dev_package_provider, $daemon_dev_package_ensure = $mysql::params::daemon_dev_package_ensure, $daemon_dev_package_name = $mysql::params::daemon_dev_package_name, $daemon_dev_package_provider = $mysql::params::daemon_dev_package_provider ) inherits mysql::params { 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 $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 $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.") } } default: { if $java_enable { include '::mysql::bindings::java' } if $perl_enable { include '::mysql::bindings::perl' } if $php_enable { include '::mysql::bindings::php' } if $python_enable { include '::mysql::bindings::python' } if $ruby_enable { include '::mysql::bindings::ruby' } } } if $client_dev { include '::mysql::bindings::client_dev' } if $daemon_dev { include '::mysql::bindings::daemon_dev' } } puppetlabs-mysql-3.6.1/manifests/client/000755 000765 000024 00000000000 12600353524 020740 5ustar00morganstaff000000 000000 puppetlabs-mysql-3.6.1/manifests/client.pp000644 000765 000024 00000001433 12600353444 021303 0ustar00morganstaff000000 000000 # class mysql::client ( $bindings_enable = $mysql::params::bindings_enable, $install_options = undef, $package_ensure = $mysql::params::client_package_ensure, $package_manage = $mysql::params::client_package_manage, $package_name = $mysql::params::client_package_name, ) inherits mysql::params { include '::mysql::client::install' if $bindings_enable { class { 'mysql::bindings': java_enable => true, perl_enable => true, php_enable => true, python_enable => true, ruby_enable => true, } } # 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': } } puppetlabs-mysql-3.6.1/manifests/db.pp000644 000765 000024 00000003743 12600353444 020420 0ustar00morganstaff000000 000000 # See README.md for details. 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, ) { #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' anchor{"mysql::db_${name}::begin": }-> Class['::mysql::client']-> anchor{"mysql::db_${name}::end": } $db_resource = { ensure => $ensure, charset => $charset, collate => $collate, provider => 'mysql', require => [ Class['mysql::client'] ], } ensure_resource('mysql_database', $dbname, $db_resource) $user_resource = { ensure => $ensure, password_hash => mysql_password($password), provider => 'mysql', } ensure_resource('mysql_user', "${user}@${host}", $user_resource) if $ensure == 'present' { mysql_grant { "${user}@${host}/${table}": privileges => $grant, provider => 'mysql', user => "${user}@${host}", table => $table, require => [ Mysql_database[$dbname], Mysql_user["${user}@${host}"], ], } $refresh = ! $enforce_sql if $sql { exec{ "${dbname}-import": command => "cat ${sql_inputs} | mysql ${dbname}", logoutput => true, environment => "HOME=${::root_home}", refreshonly => $refresh, path => '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin', require => Mysql_grant["${user}@${host}/${table}"], subscribe => Mysql_database[$dbname], timeout => $import_timeout, } } } } puppetlabs-mysql-3.6.1/manifests/params.pp000644 000765 000024 00000037345 12600353444 021323 0ustar00morganstaff000000 000000 # Private class: See README.md. class mysql::params { $manage_config_file = true $purge_conf_dir = false $restart = false $root_password = 'UNSET' $install_secret_file = '/.mysql_secret' $server_package_ensure = 'present' $server_package_manage = true $server_service_manage = true $server_service_enabled = true $client_package_ensure = 'present' $client_package_manage = true $create_root_user = true $create_root_my_cnf = true # mysql::bindings $bindings_enable = false $java_package_ensure = 'present' $java_package_provider = undef $perl_package_ensure = 'present' $perl_package_provider = undef $php_package_ensure = 'present' $php_package_provider = undef $python_package_ensure = 'present' $python_package_provider = undef $ruby_package_ensure = 'present' $ruby_package_provider = undef $client_dev_package_ensure = 'present' $client_dev_package_provider = undef $daemon_dev_package_ensure = 'present' $daemon_dev_package_provider = undef case $::osfamily { 'RedHat': { case $::operatingsystem { 'Fedora': { if versioncmp($::operatingsystemrelease, '19') >= 0 or $::operatingsystemrelease == 'Rawhide' { $provider = 'mariadb' } else { $provider = 'mysql' } } /^(RedHat|CentOS|Scientific|OracleLinux)$/: { if versioncmp($::operatingsystemmajrelease, '7') >= 0 { $provider = 'mariadb' } else { $provider = 'mysql' } } default: { $provider = 'mysql' } } if $provider == 'mariadb' { $client_package_name = 'mariadb' $server_package_name = 'mariadb-server' $server_service_name = 'mariadb' $log_error = '/var/log/mariadb/mariadb.log' $config_file = '/etc/my.cnf.d/server.cnf' # mariadb package by default has !includedir set in my.cnf to /etc/my.cnf.d $includedir = undef $pidfile = '/var/run/mariadb/mariadb.pid' } else { $client_package_name = 'mysql' $server_package_name = 'mysql-server' $server_service_name = 'mysqld' $log_error = '/var/log/mysqld.log' $config_file = '/etc/my.cnf' $includedir = '/etc/my.cnf.d' $pidfile = '/var/run/mysqld/mysqld.pid' } $basedir = '/usr' $datadir = '/var/lib/mysql' $root_group = 'root' $mysql_group = 'mysql' $socket = '/var/lib/mysql/mysql.sock' $ssl_ca = '/etc/mysql/cacert.pem' $ssl_cert = '/etc/mysql/server-cert.pem' $ssl_key = '/etc/mysql/server-key.pem' $tmpdir = '/tmp' # mysql::bindings $java_package_name = 'mysql-connector-java' $perl_package_name = 'perl-DBD-MySQL' $php_package_name = 'php-mysql' $python_package_name = 'MySQL-python' $ruby_package_name = 'ruby-mysql' $client_dev_package_name = undef $daemon_dev_package_name = 'mysql-devel' } 'Suse': { case $::operatingsystem { 'OpenSuSE': { $client_package_name = 'mysql-community-server-client' $server_package_name = 'mysql-community-server' $basedir = '/usr' } 'SLES','SLED': { if versioncmp($::operatingsystemrelease, '12') >= 0 { $client_package_name = 'mariadb-client' $server_package_name = 'mariadb' $basedir = undef } else { $client_package_name = 'mysql-client' $server_package_name = 'mysql' $basedir = '/usr' } } default: { fail("Unsupported platform: puppetlabs-${module_name} currently doesn't support ${::operatingsystem}") } } $config_file = '/etc/my.cnf' $includedir = '/etc/my.cnf.d' $datadir = '/var/lib/mysql' $log_error = $::operatingsystem ? { /OpenSuSE/ => '/var/log/mysql/mysqld.log', /(SLES|SLED)/ => '/var/log/mysqld.log', } $pidfile = $::operatingsystem ? { /OpenSuSE/ => '/var/run/mysql/mysqld.pid', /(SLES|SLED)/ => '/var/lib/mysql/mysqld.pid', } $root_group = 'root' $mysql_group = 'mysql' $server_service_name = 'mysql' $socket = $::operatingsystem ? { /OpenSuSE/ => '/var/run/mysql/mysql.sock', /(SLES|SLED)/ => '/var/lib/mysql/mysql.sock', } $ssl_ca = '/etc/mysql/cacert.pem' $ssl_cert = '/etc/mysql/server-cert.pem' $ssl_key = '/etc/mysql/server-key.pem' $tmpdir = '/tmp' # mysql::bindings $java_package_name = 'mysql-connector-java' $perl_package_name = 'perl-DBD-mysql' $php_package_name = 'apache2-mod_php53' $python_package_name = 'python-mysql' $ruby_package_name = $::operatingsystem ? { /OpenSuSE/ => 'rubygem-mysql', /(SLES|SLED)/ => 'ruby-mysql', } $client_dev_package_name = 'libmysqlclient-devel' $daemon_dev_package_name = 'mysql-devel' } 'Debian': { $client_package_name = 'mysql-client' $server_package_name = 'mysql-server' $basedir = '/usr' $config_file = '/etc/mysql/my.cnf' $includedir = '/etc/mysql/conf.d' $datadir = '/var/lib/mysql' $log_error = '/var/log/mysql/error.log' $pidfile = '/var/run/mysqld/mysqld.pid' $root_group = 'root' $mysql_group = 'mysql' $server_service_name = 'mysql' $socket = '/var/run/mysqld/mysqld.sock' $ssl_ca = '/etc/mysql/cacert.pem' $ssl_cert = '/etc/mysql/server-cert.pem' $ssl_key = '/etc/mysql/server-key.pem' $tmpdir = '/tmp' # mysql::bindings $java_package_name = 'libmysql-java' $perl_package_name = 'libdbd-mysql-perl' $php_package_name = 'php5-mysql' $python_package_name = 'python-mysqldb' $ruby_package_name = $::lsbdistcodename ? { 'trusty' => 'ruby-mysql', 'jessie' => 'ruby-mysql', default => 'libmysql-ruby', } $client_dev_package_name = 'libmysqlclient-dev' $daemon_dev_package_name = 'libmysqld-dev' } 'Archlinux': { $client_package_name = 'mariadb-clients' $server_package_name = 'mariadb' $basedir = '/usr' $config_file = '/etc/mysql/my.cnf' $datadir = '/var/lib/mysql' $log_error = '/var/log/mysqld.log' $pidfile = '/var/run/mysqld/mysqld.pid' $root_group = 'root' $mysql_group = 'mysql' $server_service_name = 'mysqld' $socket = '/var/lib/mysql/mysql.sock' $ssl_ca = '/etc/mysql/cacert.pem' $ssl_cert = '/etc/mysql/server-cert.pem' $ssl_key = '/etc/mysql/server-key.pem' $tmpdir = '/tmp' # mysql::bindings $java_package_name = 'mysql-connector-java' $perl_package_name = 'perl-dbd-mysql' $php_package_name = undef $python_package_name = 'mysql-python' $ruby_package_name = 'mysql-ruby' } 'Gentoo': { $client_package_name = 'virtual/mysql' $server_package_name = 'virtual/mysql' $basedir = '/usr' $config_file = '/etc/mysql/my.cnf' $datadir = '/var/lib/mysql' $log_error = '/var/log/mysql/mysqld.err' $pidfile = '/run/mysqld/mysqld.pid' $root_group = 'root' $mysql_group = 'mysql' $server_service_name = 'mysql' $socket = '/run/mysqld/mysqld.sock' $ssl_ca = '/etc/mysql/cacert.pem' $ssl_cert = '/etc/mysql/server-cert.pem' $ssl_key = '/etc/mysql/server-key.pem' $tmpdir = '/tmp' # mysql::bindings $java_package_name = 'dev-java/jdbc-mysql' $perl_package_name = 'dev-perl/DBD-mysql' $php_package_name = undef $python_package_name = 'dev-python/mysql-python' $ruby_package_name = 'dev-ruby/mysql-ruby' } 'FreeBSD': { $client_package_name = 'databases/mysql56-client' $server_package_name = 'databases/mysql56-server' $basedir = '/usr/local' $config_file = '/usr/local/etc/my.cnf' $includedir = '/usr/local/etc/my.cnf.d' $datadir = '/var/db/mysql' $log_error = '/var/log/mysqld.log' $pidfile = '/var/run/mysql.pid' $root_group = 'wheel' $mysql_group = 'mysql' $server_service_name = 'mysql-server' $socket = '/var/db/mysql/mysql.sock' $ssl_ca = undef $ssl_cert = undef $ssl_key = undef $tmpdir = '/tmp' # mysql::bindings $java_package_name = 'databases/mysql-connector-java' $perl_package_name = 'p5-DBD-mysql' $php_package_name = 'php5-mysql' $python_package_name = 'databases/py-MySQLdb' $ruby_package_name = 'databases/ruby-mysql' # The libraries installed by these packages are included in client and server packages, no installation required. $client_dev_package_name = undef $daemon_dev_package_name = undef } 'OpenBSD': { $client_package_name = 'mariadb-client' $server_package_name = 'mariadb-server' $basedir = '/usr/local' $config_file = '/etc/my.cnf' $includedir = undef $datadir = '/var/mysql' $log_error = "/var/mysql/${::hostname}.err" $pidfile = '/var/mysql/mysql.pid' $root_group = 'wheel' $mysql_group = '_mysql' $server_service_name = 'mysqld' $socket = '/var/run/mysql/mysql.sock' $ssl_ca = undef $ssl_cert = undef $ssl_key = undef $tmpdir = '/tmp' # mysql::bindings $java_package_name = undef $perl_package_name = 'p5-DBD-mysql' $php_package_name = 'php-mysql' $python_package_name = 'py-mysql' $ruby_package_name = 'ruby-mysql' # The libraries installed by these packages are included in client and server packages, no installation required. $client_dev_package_name = undef $daemon_dev_package_name = undef } 'Solaris': { $client_package_name = 'database/mysql-55/client' $server_package_name = 'database/mysql-55' $basedir = undef $config_file = '/etc/mysql/5.5/my.cnf' $datadir = '/var/mysql/5.5/data' $log_error = "/var/mysql/5.5/data/${::hostname}.err" $pidfile = "/var/mysql/5.5/data/${::hostname}.pid" $root_group = 'bin' $server_service_name = 'application/database/mysql:version_55' $socket = '/tmp/mysql.sock' $ssl_ca = undef $ssl_cert = undef $ssl_key = undef $tmpdir = '/tmp' # mysql::bindings $java_package_name = undef $perl_package_name = undef $php_package_name = 'web/php-53/extension/php-mysql' $python_package_name = 'library/python/python-mysql' $ruby_package_name = undef # The libraries installed by these packages are included in client and server packages, no installation required. $client_dev_package_name = undef $daemon_dev_package_name = undef } default: { case $::operatingsystem { 'Amazon': { $client_package_name = 'mysql' $server_package_name = 'mysql-server' $basedir = '/usr' $config_file = '/etc/my.cnf' $includedir = '/etc/my.cnf.d' $datadir = '/var/lib/mysql' $log_error = '/var/log/mysqld.log' $pidfile = '/var/run/mysqld/mysqld.pid' $root_group = 'root' $mysql_group = 'mysql' $server_service_name = 'mysqld' $socket = '/var/lib/mysql/mysql.sock' $ssl_ca = '/etc/mysql/cacert.pem' $ssl_cert = '/etc/mysql/server-cert.pem' $ssl_key = '/etc/mysql/server-key.pem' $tmpdir = '/tmp' # mysql::bindings $java_package_name = 'mysql-connector-java' $perl_package_name = 'perl-DBD-MySQL' $php_package_name = 'php-mysql' $python_package_name = 'MySQL-python' $ruby_package_name = 'ruby-mysql' # The libraries installed by these packages are included in client and server packages, no installation required. $client_dev_package_name = undef $daemon_dev_package_name = undef } default: { fail("Unsupported platform: puppetlabs-${module_name} currently doesn't support ${::osfamily} or ${::operatingsystem}") } } } } case $::operatingsystem { 'Ubuntu': { $server_service_provider = upstart } default: { $server_service_provider = undef } } $default_options = { 'client' => { 'port' => '3306', 'socket' => $mysql::params::socket, }, 'mysqld_safe' => { 'nice' => '0', 'log-error' => $mysql::params::log_error, 'socket' => $mysql::params::socket, }, 'mysqld' => { 'basedir' => $mysql::params::basedir, 'bind-address' => '127.0.0.1', 'datadir' => $mysql::params::datadir, 'expire_logs_days' => '10', 'key_buffer_size' => '16M', 'log-error' => $mysql::params::log_error, 'max_allowed_packet' => '16M', 'max_binlog_size' => '100M', 'max_connections' => '151', 'myisam_recover' => 'BACKUP', 'pid-file' => $mysql::params::pidfile, 'port' => '3306', 'query_cache_limit' => '1M', 'query_cache_size' => '16M', 'skip-external-locking' => true, 'socket' => $mysql::params::socket, 'ssl' => false, 'ssl-ca' => $mysql::params::ssl_ca, 'ssl-cert' => $mysql::params::ssl_cert, 'ssl-key' => $mysql::params::ssl_key, 'ssl-disable' => false, 'thread_cache_size' => '8', 'thread_stack' => '256K', 'tmpdir' => $mysql::params::tmpdir, 'user' => 'mysql', }, 'mysqldump' => { 'max_allowed_packet' => '16M', 'quick' => true, 'quote-names' => true, }, 'isamchk' => { 'key_buffer_size' => '16M', }, } ## Additional graceful failures if $::osfamily == 'RedHat' and $::operatingsystemmajrelease == '4' { fail("Unsupported platform: puppetlabs-${module_name} only supports RedHat 5.0 and beyond") } } puppetlabs-mysql-3.6.1/manifests/server/000755 000765 000024 00000000000 12600353524 020770 5ustar00morganstaff000000 000000 puppetlabs-mysql-3.6.1/manifests/server.pp000644 000765 000024 00000006127 12600353444 021340 0ustar00morganstaff000000 000000 # Class: mysql::server: See README.md for documentation. class mysql::server ( $config_file = $mysql::params::config_file, $includedir = $mysql::params::includedir, $install_options = undef, $install_secret_file = $mysql::params::install_secret_file, $manage_config_file = $mysql::params::manage_config_file, $override_options = {}, $package_ensure = $mysql::params::server_package_ensure, $package_manage = $mysql::params::server_package_manage, $package_name = $mysql::params::server_package_name, $purge_conf_dir = $mysql::params::purge_conf_dir, $remove_default_accounts = false, $restart = $mysql::params::restart, $root_group = $mysql::params::root_group, $mysql_group = $mysql::params::mysql_group, $root_password = $mysql::params::root_password, $service_enabled = $mysql::params::server_service_enabled, $service_manage = $mysql::params::server_service_manage, $service_name = $mysql::params::server_service_name, $service_provider = $mysql::params::server_service_provider, $create_root_user = $mysql::params::create_root_user, $create_root_my_cnf = $mysql::params::create_root_my_cnf, $users = {}, $grants = {}, $databases = {}, # Deprecated parameters $enabled = undef, $manage_service = undef, $old_root_password = undef ) inherits mysql::params { # Deprecated parameters. if $enabled { crit('This parameter has been renamed to service_enabled.') $real_service_enabled = $enabled } else { $real_service_enabled = $service_enabled } if $manage_service { crit('This parameter has been renamed to service_manage.') $real_service_manage = $manage_service } else { $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') } # Create a merged together set of options. Rightmost hashes win over left. $options = mysql_deepmerge($mysql::params::default_options, $override_options) Class['mysql::server::root_password'] -> Mysql::Db <| |> include '::mysql::server::install' include '::mysql::server::config' include '::mysql::server::installdb' include '::mysql::server::service' include '::mysql::server::root_password' include '::mysql::server::providers' if $remove_default_accounts { class { '::mysql::server::account_security': require => Anchor['mysql::server::end'], } } anchor { 'mysql::server::start': } anchor { 'mysql::server::end': } if $restart { Class['mysql::server::config'] ~> Class['mysql::server::service'] } Anchor['mysql::server::start'] -> Class['mysql::server::install'] -> Class['mysql::server::config'] -> Class['mysql::server::installdb'] -> Class['mysql::server::service'] -> Class['mysql::server::root_password'] -> Class['mysql::server::providers'] -> Anchor['mysql::server::end'] } puppetlabs-mysql-3.6.1/manifests/server/account_security.pp000644 000765 000024 00000001667 12600353444 024727 0ustar00morganstaff000000 000000 # See README.md. class mysql::server::account_security { mysql_user { [ 'root@127.0.0.1', 'root@::1', '@localhost', '@%']: ensure => 'absent', require => Anchor['mysql::server::end'], } if ($::fqdn != 'localhost.localdomain') { mysql_user { [ 'root@localhost.localdomain', '@localhost.localdomain']: ensure => 'absent', require => Anchor['mysql::server::end'], } } if ($::fqdn != 'localhost') { mysql_user { [ "root@${::fqdn}", "@${::fqdn}"]: ensure => 'absent', require => Anchor['mysql::server::end'], } } if ($::fqdn != $::hostname) { if ($::hostname != 'localhost') { mysql_user { ["root@${::hostname}", "@${::hostname}"]: ensure => 'absent', require => Anchor['mysql::server::end'], } } } mysql_database { 'test': ensure => 'absent', require => Anchor['mysql::server::end'], } } puppetlabs-mysql-3.6.1/manifests/server/backup.pp000644 000765 000024 00000003446 12600353444 022606 0ustar00morganstaff000000 000000 # See README.me for usage. class mysql::server::backup ( $backupuser = undef, $backuppassword = undef, $backupdir = undef, $backupdirmode = '0700', $backupdirowner = 'root', $backupdirgroup = 'root', $backupcompress = true, $backuprotate = 30, $ignore_events = true, $delete_before_dump = false, $backupdatabases = [], $file_per_database = false, $include_routines = false, $include_triggers = false, $ensure = 'present', $time = ['23', '5'], $prescript = false, $postscript = false, $execpath = '/usr/bin:/usr/sbin:/bin:/sbin', $provider = 'mysqldump', ) { if $prescript and $provider =~ /(mysqldump|mysqlbackup)/ { warning("The \$prescript option is not currently implemented for the ${provider} backup provider.") } create_resources('class', { "mysql::backup::${provider}" => { 'backupuser' => $backupuser, 'backuppassword' => $backuppassword, 'backupdir' => $backupdir, 'backupdirmode' => $backupdirmode, 'backupdirowner' => $backupdirowner, 'backupdirgroup' => $backupdirgroup, 'backupcompress' => $backupcompress, 'backuprotate' => $backuprotate, 'ignore_events' => $ignore_events, 'delete_before_dump' => $delete_before_dump, 'backupdatabases' => $backupdatabases, 'file_per_database' => $file_per_database, 'include_routines' => $include_routines, 'include_triggers' => $include_triggers, 'ensure' => $ensure, 'time' => $time, 'prescript' => $prescript, 'postscript' => $postscript, 'execpath' => $execpath, } }) } puppetlabs-mysql-3.6.1/manifests/server/config.pp000644 000765 000024 00000002624 12600353444 022603 0ustar00morganstaff000000 000000 # See README.me for options. class mysql::server::config { $options = $mysql::server::options $includedir = $mysql::server::includedir File { owner => 'root', group => $mysql::server::root_group, mode => '0400', } if $includedir and $includedir != '' { file { $includedir: ensure => directory, mode => '0755', recurse => $mysql::server::purge_conf_dir, purge => $mysql::server::purge_conf_dir, } } $logbin = pick($options['mysqld']['log-bin'], $options['mysqld']['log_bin'], false) if $logbin { $logbindir = mysql_dirname($logbin) #Stop puppet from managing directory if just a filename/prefix is specified if $logbindir != '.' { file { $logbindir: ensure => directory, mode => '0755', owner => $options['mysqld']['user'], group => $options['mysqld']['user'], } } } if $mysql::server::manage_config_file { file { 'mysql-config-file': path => $mysql::server::config_file, content => template('mysql/my.cnf.erb'), mode => '0644', selinux_ignore_defaults => true, } } 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' } } } puppetlabs-mysql-3.6.1/manifests/server/install.pp000644 000765 000024 00000000436 12600353444 023003 0ustar00morganstaff000000 000000 # class mysql::server::install { if $mysql::server::package_manage { package { 'mysql-server': ensure => $mysql::server::package_ensure, install_options => $mysql::server::install_options, name => $mysql::server::package_name, } } } puppetlabs-mysql-3.6.1/manifests/server/installdb.pp000644 000765 000024 00000001662 12600353471 023313 0ustar00morganstaff000000 000000 # class mysql::server::installdb { if $mysql::server::package_manage { # Build the initial databases. $mysqluser = $mysql::server::options['mysqld']['user'] $datadir = $mysql::server::options['mysqld']['datadir'] $basedir = $mysql::server::options['mysqld']['basedir'] $config_file = $mysql::server::config_file if $mysql::server::manage_config_file { $install_db_args = "--basedir=${basedir} --defaults-extra-file=${config_file} --datadir=${datadir} --user=${mysqluser}" } exec { 'mysql_install_db': command => "mysql_install_db ${install_db_args}", creates => "${datadir}/mysql", logoutput => on_failure, path => '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin', require => Package['mysql-server'], } if $mysql::server::restart { Exec['mysql_install_db'] { notify => Class['mysql::server::service'], } } } } puppetlabs-mysql-3.6.1/manifests/server/monitor.pp000644 000765 000024 00000001462 12600353444 023024 0ustar00morganstaff000000 000000 #This is a helper class to add a monitoring user to the database class mysql::server::monitor ( $mysql_monitor_username = '', $mysql_monitor_password = '', $mysql_monitor_hostname = '' ) { Anchor['mysql::server::end'] -> Class['mysql::server::monitor'] mysql_user { "${mysql_monitor_username}@${mysql_monitor_hostname}": ensure => present, password_hash => mysql_password($mysql_monitor_password), require => Class['mysql::server::service'], } mysql_grant { "${mysql_monitor_username}@${mysql_monitor_hostname}/*.*": ensure => present, user => "${mysql_monitor_username}@${mysql_monitor_hostname}", table => '*.*', privileges => [ 'PROCESS', 'SUPER' ], require => Mysql_user["${mysql_monitor_username}@${mysql_monitor_hostname}"], } } puppetlabs-mysql-3.6.1/manifests/server/mysqltuner.pp000644 000765 000024 00000002643 12600353444 023562 0ustar00morganstaff000000 000000 # class mysql::server::mysqltuner( $ensure = 'present', $version = 'v1.3.0', $source = undef, ) { if $source { $_version = $source $_source = $source } else { $_version = $version $_source = "https://github.com/major/MySQLTuner-perl/raw/${version}/mysqltuner.pl" } if $ensure == 'present' { # $::puppetversion doesn't exist in puppet 4.x so would break strict # variables if ! $::settings::strict_variables { $_puppetversion = $::puppetversion } else { # defined only works with puppet >= 3.5.0, so don't use it unless we're # actually using strict variables $_puppetversion = defined('$puppetversion') ? { true => $::puppetversion, default => undef, } } # see https://tickets.puppetlabs.com/browse/ENTERPRISE-258 if $_puppetversion and $_puppetversion =~ /Puppet Enterprise/ and versioncmp($_puppetversion, '3.8.0') < 0 { class { 'staging': path => '/opt/mysql_staging', } } else { class { 'staging': } } staging::file { "mysqltuner-${_version}": source => $_source, } file { '/usr/local/bin/mysqltuner': ensure => $ensure, mode => '0550', source => "${::staging::path}/mysql/mysqltuner-${_version}", require => Staging::File["mysqltuner-${_version}"], } } else { file { '/usr/local/bin/mysqltuner': ensure => $ensure, } } } puppetlabs-mysql-3.6.1/manifests/server/providers.pp000644 000765 000024 00000000545 12600353444 023353 0ustar00morganstaff000000 000000 # Convenience class to call each of the three providers with the corresponding # hashes provided in mysql::server. # See README.md for details. class mysql::server::providers { create_resources('mysql_user', $mysql::server::users) create_resources('mysql_grant', $mysql::server::grants) create_resources('mysql_database', $mysql::server::databases) } puppetlabs-mysql-3.6.1/manifests/server/root_password.pp000644 000765 000024 00000003174 12600353444 024244 0ustar00morganstaff000000 000000 # class mysql::server::root_password { $options = $mysql::server::options $secret_file = $mysql::server::install_secret_file # New installations of MySQL will configure a default random password for the root user # with an expiration. No actions can be performed until this password is changed. The # below exec will remove this default password. If the user has supplied a root # password it will be set further down with the mysql_user resource. $rm_pass_cmd = join([ "mysqladmin -u root --password=\$(grep -o '[^ ]\\+\$' ${secret_file}) password ''", "rm -f ${secret_file}" ], ' && ') exec { 'remove install pass': command => $rm_pass_cmd, onlyif => "test -f ${secret_file}", path => '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin' } # manage root password if it is set if $mysql::server::create_root_user == true and $mysql::server::root_password != 'UNSET' { mysql_user { 'root@localhost': ensure => present, password_hash => mysql_password($mysql::server::root_password), require => Exec['remove install pass'] } } if $mysql::server::create_root_my_cnf == true and $mysql::server::root_password != 'UNSET' { file { "${::root_home}/.my.cnf": content => template('mysql/my.cnf.pass.erb'), owner => 'root', mode => '0600', } # show_diff was added with puppet 3.0 if versioncmp($::puppetversion, '3.0') <= 0 { File["${::root_home}/.my.cnf"] { show_diff => false } } if $mysql::server::create_root_user == true { Mysql_user['root@localhost'] -> File["${::root_home}/.my.cnf"] } } } puppetlabs-mysql-3.6.1/manifests/server/service.pp000644 000765 000024 00000002533 12600353444 022775 0ustar00morganstaff000000 000000 # class mysql::server::service { $options = $mysql::server::options if $mysql::server::real_service_manage { if $mysql::server::real_service_enabled { $service_ensure = 'running' } else { $service_ensure = 'stopped' } } else { $service_ensure = undef } 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'] } if $options['mysqld']['log-error'] { file { $options['mysqld']['log-error']: ensure => present, owner => $mysqluser, group => $::mysql::server::mysql_group, } } service { 'mysqld': ensure => $service_ensure, name => $mysql::server::service_name, enable => $mysql::server::real_service_enabled, provider => $mysql::server::service_provider, } # only establish ordering between service and package if # we're managing the package. if $mysql::server::package_manage { Service['mysqld'] { require => Package['mysql-server'], } } # only establish ordering between config file and service if # we're managing the config file. if $mysql::server::manage_config_file { File['mysql-config-file'] -> Service['mysqld'] } } puppetlabs-mysql-3.6.1/manifests/client/install.pp000644 000765 000024 00000000456 12600353444 022755 0ustar00morganstaff000000 000000 # See README.md. class mysql::client::install { if $mysql::client::package_manage { package { 'mysql_client': ensure => $mysql::client::package_ensure, install_options => $mysql::client::install_options, name => $mysql::client::package_name, } } } puppetlabs-mysql-3.6.1/manifests/bindings/client_dev.pp000644 000765 000024 00000001006 12600353444 023732 0ustar00morganstaff000000 000000 # Private class class mysql::bindings::client_dev { if $mysql::bindings::client_dev_package_name { package { 'mysql-client_dev': ensure => $mysql::bindings::client_dev_package_ensure, install_options => $mysql::bindings::install_options, name => $mysql::bindings::client_dev_package_name, provider => $mysql::bindings::client_dev_package_provider, } } else { warning("No MySQL client development package configured for ${::operatingsystem}.") } } puppetlabs-mysql-3.6.1/manifests/bindings/daemon_dev.pp000644 000765 000024 00000001006 12600353444 023717 0ustar00morganstaff000000 000000 # Private class class mysql::bindings::daemon_dev { if $mysql::bindings::daemon_dev_package_name { package { 'mysql-daemon_dev': ensure => $mysql::bindings::daemon_dev_package_ensure, install_options => $mysql::bindings::install_options, name => $mysql::bindings::daemon_dev_package_name, provider => $mysql::bindings::daemon_dev_package_provider, } } else { warning("No MySQL daemon development package configured for ${::operatingsystem}.") } } puppetlabs-mysql-3.6.1/manifests/bindings/java.pp000644 000765 000024 00000000516 12600353444 022544 0ustar00morganstaff000000 000000 # Private class class mysql::bindings::java { package { 'mysql-connector-java': ensure => $mysql::bindings::java_package_ensure, install_options => $mysql::bindings::install_options, name => $mysql::bindings::java_package_name, provider => $mysql::bindings::java_package_provider, } } puppetlabs-mysql-3.6.1/manifests/bindings/perl.pp000644 000765 000024 00000000503 12600353444 022561 0ustar00morganstaff000000 000000 # Private class class mysql::bindings::perl { package{ 'perl_mysql': ensure => $mysql::bindings::perl_package_ensure, install_options => $mysql::bindings::install_options, name => $mysql::bindings::perl_package_name, provider => $mysql::bindings::perl_package_provider, } } puppetlabs-mysql-3.6.1/manifests/bindings/php.pp000644 000765 000024 00000000516 12600353444 022412 0ustar00morganstaff000000 000000 # Private class: See README.md class mysql::bindings::php { package { 'php-mysql': ensure => $mysql::bindings::php_package_ensure, install_options => $mysql::bindings::install_options, name => $mysql::bindings::php_package_name, provider => $mysql::bindings::php_package_provider, } } puppetlabs-mysql-3.6.1/manifests/bindings/python.pp000644 000765 000024 00000000520 12600353444 023137 0ustar00morganstaff000000 000000 # Private class class mysql::bindings::python { package { 'python-mysqldb': ensure => $mysql::bindings::python_package_ensure, install_options => $mysql::bindings::install_options, name => $mysql::bindings::python_package_name, provider => $mysql::bindings::python_package_provider, } } puppetlabs-mysql-3.6.1/manifests/bindings/ruby.pp000644 000765 000024 00000000503 12600353444 022600 0ustar00morganstaff000000 000000 # Private class class mysql::bindings::ruby { package{ 'ruby_mysql': ensure => $mysql::bindings::ruby_package_ensure, install_options => $mysql::bindings::install_options, name => $mysql::bindings::ruby_package_name, provider => $mysql::bindings::ruby_package_provider, } } puppetlabs-mysql-3.6.1/manifests/backup/mysqlbackup.pp000644 000765 000024 00000006057 12600353444 023634 0ustar00morganstaff000000 000000 # See README.me for usage. class mysql::backup::mysqlbackup ( $backupuser = '', $backuppassword = '', $backupdir = '', $backupdirmode = '0700', $backupdirowner = 'root', $backupdirgroup = $mysql::params::root_group, $backupcompress = true, $backuprotate = 30, $ignore_events = true, $delete_before_dump = false, $backupdatabases = [], $file_per_database = false, $include_triggers = true, $include_routines = false, $ensure = 'present', $time = ['23', '5'], $prescript = false, $postscript = false, $execpath = '/usr/bin:/usr/sbin:/bin:/sbin', ) { mysql_user { "${backupuser}@localhost": ensure => $ensure, password_hash => mysql_password($backuppassword), require => Class['mysql::server::root_password'], } package { 'meb': ensure => $ensure, } # http://dev.mysql.com/doc/mysql-enterprise-backup/3.11/en/mysqlbackup.privileges.html mysql_grant { "${backupuser}@localhost/*.*": ensure => $ensure, user => "${backupuser}@localhost", table => '*.*', privileges => [ 'RELOAD', 'SUPER', 'REPLICATION CLIENT' ], require => Mysql_user["${backupuser}@localhost"], } mysql_grant { "${backupuser}@localhost/mysql.backup_progress": ensure => $ensure, user => "${backupuser}@localhost", table => 'mysql.backup_progress', privileges => [ 'CREATE', 'INSERT', 'DROP', 'UPDATE' ], require => Mysql_user["${backupuser}@localhost"], } mysql_grant { "${backupuser}@localhost/mysql.backup_history": ensure => $ensure, user => "${backupuser}@localhost", table => 'mysql.backup_history', privileges => [ 'CREATE', 'INSERT', 'SELECT', 'DROP', 'UPDATE' ], require => Mysql_user["${backupuser}@localhost"], } cron { 'mysqlbackup-weekly': ensure => $ensure, command => 'mysqlbackup backup', user => 'root', hour => $time[0], minute => $time[1], weekday => 0, require => Package['meb'], } cron { 'mysqlbackup-daily': ensure => $ensure, command => 'mysqlbackup --incremental backup', user => 'root', hour => $time[0], minute => $time[1], weekday => 1-6, require => Package['meb'], } $default_options = { 'mysqlbackup' => { 'backup-dir' => $backupdir, 'with-timestamp' => true, 'incremental_base' => 'history:last_backup', 'incremental_backup_dir' => $backupdir, 'user' => $backupuser, 'password' => $backuppassword, } } $options = mysql_deepmerge($default_options, $mysql::server::override_options) file { 'mysqlbackup-config-file': path => '/etc/mysql/conf.d/meb.cnf', content => template('mysql/meb.cnf.erb'), mode => '0600', } file { 'mysqlbackupdir': ensure => 'directory', path => $backupdir, mode => $backupdirmode, owner => $backupdirowner, group => $backupdirgroup, } } puppetlabs-mysql-3.6.1/manifests/backup/mysqldump.pp000644 000765 000024 00000003653 12600353444 023333 0ustar00morganstaff000000 000000 # See README.me for usage. class mysql::backup::mysqldump ( $backupuser = '', $backuppassword = '', $backupdir = '', $backupdirmode = '0700', $backupdirowner = 'root', $backupdirgroup = $mysql::params::root_group, $backupcompress = true, $backuprotate = 30, $ignore_events = true, $delete_before_dump = false, $backupdatabases = [], $file_per_database = false, $include_triggers = false, $include_routines = false, $ensure = 'present', $time = ['23', '5'], $prescript = false, $postscript = false, $execpath = '/usr/bin:/usr/sbin:/bin:/sbin', ) { mysql_user { "${backupuser}@localhost": ensure => $ensure, password_hash => mysql_password($backuppassword), require => Class['mysql::server::root_password'], } if $include_triggers { $privs = [ 'SELECT', 'RELOAD', 'LOCK TABLES', 'SHOW VIEW', 'PROCESS', 'TRIGGER' ] } else { $privs = [ 'SELECT', 'RELOAD', 'LOCK TABLES', 'SHOW VIEW', 'PROCESS' ] } mysql_grant { "${backupuser}@localhost/*.*": ensure => $ensure, user => "${backupuser}@localhost", table => '*.*', privileges => $privs, require => Mysql_user["${backupuser}@localhost"], } cron { 'mysql-backup': ensure => $ensure, command => '/usr/local/sbin/mysqlbackup.sh', user => 'root', hour => $time[0], minute => $time[1], require => File['mysqlbackup.sh'], } file { 'mysqlbackup.sh': ensure => $ensure, path => '/usr/local/sbin/mysqlbackup.sh', mode => '0700', owner => 'root', group => $mysql::params::root_group, content => template('mysql/mysqlbackup.sh.erb'), } file { 'mysqlbackupdir': ensure => 'directory', path => $backupdir, mode => $backupdirmode, owner => $backupdirowner, group => $backupdirgroup, } } puppetlabs-mysql-3.6.1/manifests/backup/xtrabackup.pp000644 000765 000024 00000003322 12600353444 023435 0ustar00morganstaff000000 000000 # See README.me for usage. class mysql::backup::xtrabackup ( $backupuser = '', $backuppassword = '', $backupdir = '', $backupmethod = 'mysqldump', $backupdirmode = '0700', $backupdirowner = 'root', $backupdirgroup = $mysql::params::root_group, $backupcompress = true, $backuprotate = 30, $ignore_events = true, $delete_before_dump = false, $backupdatabases = [], $file_per_database = false, $include_triggers = true, $include_routines = false, $ensure = 'present', $time = ['23', '5'], $prescript = false, $postscript = false, $execpath = '/usr/bin:/usr/sbin:/bin:/sbin', ) { package{ 'percona-xtrabackup': ensure => $ensure, } cron { 'xtrabackup-weekly': ensure => $ensure, command => "/usr/local/sbin/xtrabackup.sh ${backupdir}", user => 'root', hour => $time[0], minute => $time[1], weekday => 0, require => Package['percona-xtrabackup'], } cron { 'xtrabackup-daily': ensure => $ensure, command => "/usr/local/sbin/xtrabackup.sh --incremental ${backupdir}", user => 'root', hour => $time[0], minute => $time[1], weekday => 1-6, require => Package['percona-xtrabackup'], } file { 'mysqlbackupdir': ensure => 'directory', path => $backupdir, mode => $backupdirmode, owner => $backupdirowner, group => $backupdirgroup, } file { 'xtrabackup.sh': ensure => $ensure, path => '/usr/local/sbin/xtrabackup.sh', mode => '0700', owner => 'root', group => $mysql::params::root_group, content => template('mysql/xtrabackup.sh.erb'), } } puppetlabs-mysql-3.6.1/lib/facter/000755 000765 000024 00000000000 12600353524 017503 5ustar00morganstaff000000 000000 puppetlabs-mysql-3.6.1/lib/puppet/000755 000765 000024 00000000000 12600353524 017554 5ustar00morganstaff000000 000000 puppetlabs-mysql-3.6.1/lib/puppet/parser/000755 000765 000024 00000000000 12600353524 021050 5ustar00morganstaff000000 000000 puppetlabs-mysql-3.6.1/lib/puppet/provider/000755 000765 000024 00000000000 12600353524 021406 5ustar00morganstaff000000 000000 puppetlabs-mysql-3.6.1/lib/puppet/type/000755 000765 000024 00000000000 12600353524 020535 5ustar00morganstaff000000 000000 puppetlabs-mysql-3.6.1/lib/puppet/type/mysql_database.rb000644 000765 000024 00000001036 12600353444 024054 0ustar00morganstaff000000 000000 Puppet::Type.newtype(:mysql_database) do @doc = 'Manage MySQL databases.' ensurable autorequire(:file) { '/root/.my.cnf' } autorequire(:class) { 'mysql::server' } 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+$/) end newproperty(:collate) do desc 'The COLLATE setting for the database' defaultto :utf8_general_ci newvalue(/^\S+$/) end end puppetlabs-mysql-3.6.1/lib/puppet/type/mysql_grant.rb000644 000765 000024 00000007064 12600353471 023432 0ustar00morganstaff000000 000000 # This has to be a separate type to enable collecting Puppet::Type.newtype(:mysql_grant) do @doc = "Manage a MySQL user's rights." ensurable autorequire(:file) { '/root/.my.cnf' } autorequire(:mysql_user) { self[:user] } def initialize(*args) super # Forcibly munge any privilege with 'ALL' in the array to exist of just # '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') 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! end 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]}" end newparam(:name, :namevar => true) do desc 'Name to describe the grant.' munge do |value| value.delete("'") end end newproperty(:privileges, :array_matching => :all) do desc 'Privileges for user' end newproperty(:table) do desc 'Table to apply privileges to.' munge do |value| value.delete("`") end newvalues(/.*\..*/,/@/) end newproperty(:user) do desc 'User to operate on.' 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) user_part = matches[2] host_part = matches[3] elsif matches = /^([0-9a-zA-Z$_]*)@([\w%\.:\-\/]+)$/.match(value) user_part = matches[1] host_part = matches[2] elsif matches = /^((?!['`"]).*[^0-9a-zA-Z$_].*)@(.+)$/.match(value) user_part = matches[1] host_part = matches[2] else raise(ArgumentError, "Invalid database user #{value}") end mysql_version = Facter.value(:mysql_version) unless mysql_version.nil? if Puppet::Util::Package.versioncmp(mysql_version, '10.0.0') < 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 > 80 raise(ArgumentError, 'MySQL usernames are limited to a maximum of 80 characters') end end end munge do |value| matches = /^((['`"]?).*\2)@(.+)$/.match(value) "#{matches[1]}@#{matches[3].downcase}" end end newproperty(:options, :array_matching => :all) do desc 'Options to grant.' end end puppetlabs-mysql-3.6.1/lib/puppet/type/mysql_plugin.rb000644 000765 000024 00000000504 12600353444 023605 0ustar00morganstaff000000 000000 Puppet::Type.newtype(:mysql_plugin) do @doc = 'Manage MySQL plugins.' ensurable autorequire(:file) { '/root/.my.cnf' } 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+$/) end end puppetlabs-mysql-3.6.1/lib/puppet/type/mysql_user.rb000644 000765 000024 00000005133 12600353471 023270 0ustar00morganstaff000000 000000 # This has to be a separate type to enable collecting Puppet::Type.newtype(:mysql_user) do @doc = 'Manage a MySQL user. This includes management of users password as well as privileges.' ensurable autorequire(:file) { '/root/.my.cnf' } autorequire(:class) { 'mysql::server' } 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) user_part = matches[2] host_part = matches[3] elsif matches = /^([0-9a-zA-Z$_]*)@([\w%\.:\-\/]+)$/.match(value) user_part = matches[1] host_part = matches[2] elsif matches = /^((?!['`"]).*[^0-9a-zA-Z$_].*)@(.+)$/.match(value) user_part = matches[1] host_part = matches[2] else raise(ArgumentError, "Invalid database user #{value}") end mysql_version = Facter.value(:mysql_version) unless mysql_version.nil? if Puppet::Util::Package.versioncmp(mysql_version, '10.0.0') < 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 > 80 raise(ArgumentError, 'MySQL usernames are limited to a maximum of 80 characters') end end end munge do |value| matches = /^((['`"]?).*\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*/) end newproperty(:plugin) do desc 'The authentication plugin of the user.' newvalue(/\w+/) end newproperty(:max_user_connections) do desc "Max concurrent connections for the user. 0 means no (or global) limit." newvalue(/\d+/) end newproperty(:max_connections_per_hour) do desc "Max connections per hour for the user. 0 means no (or global) limit." newvalue(/\d+/) end newproperty(:max_queries_per_hour) do desc "Max queries per hour for the user. 0 means no (or global) limit." newvalue(/\d+/) end newproperty(:max_updates_per_hour) do desc "Max updates per hour for the user. 0 means no (or global) limit." newvalue(/\d+/) end end puppetlabs-mysql-3.6.1/lib/puppet/provider/mysql.rb000644 000765 000024 00000003262 12600353444 023104 0ustar00morganstaff000000 000000 class Puppet::Provider::Mysql < Puppet::Provider # Without initvars commands won't work. initvars commands :mysql => 'mysql' commands :mysqladmin => 'mysqladmin' # 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 end def defaults_file self.class.defaults_file end def self.users mysql([defaults_file, '-NBe', "SELECT CONCAT(User, '@',Host) AS User FROM mysql.user"].compact).split("\n") end # Take root@localhost and munge it to 'root'@'localhost' def self.cmd_user(user) "'#{user.sub('@', "'@'")}'" end # Take root.* and return ON `root`.* def self.cmd_table(table) 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 end def self.cmd_privs(privileges) if privileges.include?('ALL') return 'ALL PRIVILEGES' else priv_string = '' privileges.each do |priv| priv_string << "#{priv}, " end end # Remove trailing , from the last element. priv_string.sub(/, $/, '') 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 end option_string end end puppetlabs-mysql-3.6.1/lib/puppet/provider/mysql_database/000755 000765 000024 00000000000 12600353524 024377 5ustar00morganstaff000000 000000 puppetlabs-mysql-3.6.1/lib/puppet/provider/mysql_grant/000755 000765 000024 00000000000 12600353524 023746 5ustar00morganstaff000000 000000 puppetlabs-mysql-3.6.1/lib/puppet/provider/mysql_plugin/000755 000765 000024 00000000000 12600353524 024131 5ustar00morganstaff000000 000000 puppetlabs-mysql-3.6.1/lib/puppet/provider/mysql_user/000755 000765 000024 00000000000 12600353524 023611 5ustar00morganstaff000000 000000 puppetlabs-mysql-3.6.1/lib/puppet/provider/mysql_user/mysql.rb000644 000765 000024 00000012225 12600353444 025306 0ustar00morganstaff000000 000000 require File.expand_path(File.join(File.dirname(__FILE__), '..', 'mysql')) Puppet::Type.type(:mysql_user).provide(:mysql, :parent => Puppet::Provider::Mysql) do desc 'manage users for a mysql database.' commands :mysql => '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") # To reduce the number of calls to MySQL we collect all the properties in # one big swoop. users.collect do |name| query = "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, PASSWORD /*!50508 , PLUGIN */ FROM mysql.user WHERE CONCAT(user, '@', host) = '#{name}'" @max_user_connections, @max_connections_per_hour, @max_queries_per_hour, @max_updates_per_hour, @password, @plugin = mysql([defaults_file, "-NBe", query].compact).split(/\s/) 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 ) end end # We iterate over each mysql_user entry in the catalog and compare it against # the contents of the property_hash generated by self.instances def self.prefetch(resources) users = instances resources.keys.each do |name| if provider = users.find { |user| user.name == name } resources[name].provider = provider end end end def create merged_name = @resource[:name].sub('@', "'@'") password_hash = @resource.value(:password_hash) plugin = @resource.value(:plugin) max_user_connections = @resource.value(:max_user_connections) || 0 max_connections_per_hour = @resource.value(:max_connections_per_hour) || 0 max_queries_per_hour = @resource.value(:max_queries_per_hour) || 0 max_updates_per_hour = @resource.value(:max_updates_per_hour) || 0 # 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? mysql([defaults_file, '-e', "CREATE USER '#{merged_name}' IDENTIFIED WITH '#{plugin}'"].compact) @property_hash[:ensure] = :present @property_hash[:plugin] = plugin else mysql([defaults_file, '-e', "CREATE USER '#{merged_name}' IDENTIFIED BY PASSWORD '#{password_hash}'"].compact) @property_hash[:ensure] = :present @property_hash[:password_hash] = password_hash end mysql([defaults_file, '-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) @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 exists? ? (return true) : (return false) end def destroy merged_name = @resource[:name].sub('@', "'@'") mysql([defaults_file, '-e', "DROP USER '#{merged_name}'"].compact) @property_hash.clear exists? ? (return false) : (return true) end def exists? @property_hash[:ensure] == :present || false end ## ## MySQL user properties ## # Generates method for all properties of the property_hash mk_resource_methods def password_hash=(string) merged_name = self.class.cmd_user(@resource[:name]) mysql([defaults_file, '-e', "SET PASSWORD FOR #{merged_name} = '#{string}'"].compact) password_hash == string ? (return true) : (return false) end def max_user_connections=(int) merged_name = self.class.cmd_user(@resource[:name]) mysql([defaults_file, '-e', "GRANT USAGE ON *.* TO #{merged_name} WITH MAX_USER_CONNECTIONS #{int}"].compact).chomp 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, '-e', "GRANT USAGE ON *.* TO #{merged_name} WITH MAX_CONNECTIONS_PER_HOUR #{int}"].compact).chomp 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, '-e', "GRANT USAGE ON *.* TO #{merged_name} WITH MAX_QUERIES_PER_HOUR #{int}"].compact).chomp 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, '-e', "GRANT USAGE ON *.* TO #{merged_name} WITH MAX_UPDATES_PER_HOUR #{int}"].compact).chomp max_updates_per_hour == int ? (return true) : (return false) end end puppetlabs-mysql-3.6.1/lib/puppet/provider/mysql_plugin/mysql.rb000644 000765 000024 00000003143 12600353444 025625 0ustar00morganstaff000000 000000 require File.expand_path(File.join(File.dirname(__FILE__), '..', 'mysql')) Puppet::Type.type(:mysql_plugin).provide(:mysql, :parent => Puppet::Provider::Mysql) do desc 'Manages MySQL plugins.' commands :mysql => '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 ) end end # We iterate over each mysql_plugin entry in the catalog and compare it against # the contents of the property_hash generated by self.instances def self.prefetch(resources) plugins = instances resources.keys.each do |plugin| if provider = plugins.find { |pl| pl.name == plugin } resources[plugin].provider = provider end end end 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) @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) @property_hash.clear exists? ? (return false) : (return true) end def exists? @property_hash[:ensure] == :present || false end mk_resource_methods end puppetlabs-mysql-3.6.1/lib/puppet/provider/mysql_grant/mysql.rb000644 000765 000024 00000014261 12600353444 025445 0ustar00morganstaff000000 000000 require File.expand_path(File.join(File.dirname(__FILE__), '..', 'mysql')) Puppet::Type.type(:mysql_grant).provide(:mysql, :parent => Puppet::Provider::Mysql) do desc 'Set grants for users in MySQL.' def self.instances instances = [] users.select{ |user| user =~ /.+@/ }.collect do |user| user_string = self.cmd_user(user) query = "SHOW GRANTS FOR #{user_string};" begin grants = mysql([defaults_file, "-NBe", query].compact) 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 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("`") # 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. options = ['GRANT'] if rest.match(/WITH\sGRANT\sOPTION/) # 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 end return instances end def self.prefetch(resources) users = instances resources.keys.each do |name| if provider = users.find { |user| user.name == name } resources[name].provider = provider end end end 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) query = "GRANT #{priv_string}" query << " ON #{table_string}" query << " TO #{user_string}" query << self.class.cmd_options(options) unless options.nil? mysql([defaults_file, '-e', query].compact) end def create grant(@resource[:user], @resource[:table], @resource[:privileges], @resource[:options]) @property_hash[:ensure] = :present @property_hash[:table] = @resource[:table] @property_hash[:user] = @resource[:user] @property_hash[:options] = @resource[:options] if @resource[:options] @property_hash[:privileges] = @resource[:privileges] exists? ? (return true) : (return false) end def revoke(user, table, revoke_privileges = ['ALL']) user_string = self.class.cmd_user(user) table_string = 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' query = "REVOKE GRANT OPTION ON #{table_string} FROM #{user_string}" mysql([defaults_file, '-e', query].compact) end query = "REVOKE #{priv_string} ON #{table_string} FROM #{user_string}" mysql([defaults_file, '-e', query].compact) end def destroy revoke(@property_hash[:user], @property_hash[:table]) @property_hash.clear exists? ? (return false) : (return true) end def exists? @property_hash[:ensure] == :present || false end def flush @property_hash.clear mysql([defaults_file, '-NBe', 'FLUSH PRIVILEGES'].compact) end mk_resource_methods def diff_privileges(privileges_old, privileges_new) diff = {:revoke => Array.new, :grant => Array.new} if privileges_old.include? 'ALL' diff[:revoke] = privileges_old diff[:grant] = privileges_new elsif privileges_new.include? 'ALL' diff[:grant] = privileges_new else diff[:revoke] = privileges_old - privileges_new diff[:grant] = privileges_new - privileges_old end return diff end def privileges=(privileges) diff = diff_privileges(@property_hash[:privileges], privileges) if not diff[:revoke].empty? revoke(@property_hash[:user], @property_hash[:table], diff[:revoke]) end if not diff[:grant].empty? grant(@property_hash[:user], @property_hash[:table], diff[:grant], @property_hash[:options]) end @property_hash[:privileges] = privileges self.privileges end def options=(options) revoke(@property_hash[:user], @property_hash[:table]) grant(@property_hash[:user], @property_hash[:table], @property_hash[:privileges], options) @property_hash[:options] = options self.options end end puppetlabs-mysql-3.6.1/lib/puppet/provider/mysql_database/mysql.rb000644 000765 000024 00000004270 12600353444 026075 0ustar00morganstaff000000 000000 require File.expand_path(File.join(File.dirname(__FILE__), '..', 'mysql')) Puppet::Type.type(:mysql_database).provide(:mysql, :parent => Puppet::Provider::Mysql) do desc 'Manages MySQL databases.' commands :mysql => 'mysql' def self.instances mysql([defaults_file, '-NBe', 'show databases'].compact).split("\n").collect do |name| attributes = {} mysql([defaults_file, '-NBe', "show variables like '%_database'", name].compact).split("\n").each do |line| k,v = line.split(/\s/) attributes[k] = v end new(:name => name, :ensure => :present, :charset => attributes['character_set_database'], :collate => attributes['collation_database'] ) end end # We iterate over each mysql_database entry in the catalog and compare it against # the contents of the property_hash generated by self.instances def self.prefetch(resources) databases = instances resources.keys.each do |database| if provider = databases.find { |db| db.name == database } resources[database].provider = provider end end end def create mysql([defaults_file, '-NBe', "create database if not exists `#{@resource[:name]}` character set `#{@resource[:charset]}` collate `#{@resource[:collate]}`"].compact) @property_hash[:ensure] = :present @property_hash[:charset] = @resource[:charset] @property_hash[:collate] = @resource[:collate] exists? ? (return true) : (return false) end def destroy mysql([defaults_file, '-NBe', "drop database if exists `#{@resource[:name]}`"].compact) @property_hash.clear exists? ? (return false) : (return true) end def exists? @property_hash[:ensure] == :present || false end mk_resource_methods def charset=(value) mysql([defaults_file, '-NBe', "alter database `#{resource[:name]}` CHARACTER SET #{value}"].compact) @property_hash[:charset] = value charset == value ? (return true) : (return false) end def collate=(value) mysql([defaults_file, '-NBe', "alter database `#{resource[:name]}` COLLATE #{value}"].compact) @property_hash[:collate] = value collate == value ? (return true) : (return false) end end puppetlabs-mysql-3.6.1/lib/puppet/parser/functions/000755 000765 000024 00000000000 12600353524 023060 5ustar00morganstaff000000 000000 puppetlabs-mysql-3.6.1/lib/puppet/parser/functions/mysql_deepmerge.rb000644 000765 000024 00000004163 12600353444 026574 0ustar00morganstaff000000 000000 module Puppet::Parser::Functions newfunction(:mysql_deepmerge, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args| Recursively merges two or more hashes together and returns the resulting hash. For example: $hash1 = {'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } } $hash2 = {'two' => 'dos', 'three' => { 'five' => 5 } } $merged_hash = mysql_deepmerge($hash1, $hash2) # The resulting hash is equivalent to: # $merged_hash = { 'one' => 1, 'two' => 'dos', 'three' => { 'four' => 4, 'five' => 5 } } When there is a duplicate key that is a hash, they are recursively merged. When there is a duplicate key that is not a hash, the key in the rightmost hash will "win." When there are conficting uses of dashes and underscores in two keys (which mysql would otherwise equate), the rightmost style will win. ENDHEREDOC if args.length < 2 raise Puppet::ParseError, ("mysql_deepmerge(): wrong number of arguments (#{args.length}; must be at least 2)") end result = Hash.new args.each do |arg| next if arg.is_a? String and 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" 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 ) end 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; end 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 ) else hash1[key] = value end end end puppetlabs-mysql-3.6.1/lib/puppet/parser/functions/mysql_dirname.rb000644 000765 000024 00000000610 12600353444 026247 0ustar00morganstaff000000 000000 module Puppet::Parser::Functions newfunction(:mysql_dirname, :type => :rvalue, :doc => <<-EOS Returns the dirname of a path. EOS ) do |arguments| raise(Puppet::ParseError, "mysql_dirname(): Wrong number of arguments " + "given (#{arguments.size} for 1)") if arguments.size < 1 path = arguments[0] return File.dirname(path) end end # vim: set ts=2 sw=2 et : puppetlabs-mysql-3.6.1/lib/puppet/parser/functions/mysql_password.rb000644 000765 000024 00000001004 12600353444 026470 0ustar00morganstaff000000 000000 # hash a string as mysql's "PASSWORD()" function would do it require 'digest/sha1' module Puppet::Parser::Functions newfunction(:mysql_password, :type => :rvalue, :doc => <<-EOS Returns the mysql password hash from the clear text password. EOS ) do |args| raise(Puppet::ParseError, 'mysql_password(): Wrong number of arguments ' + "given (#{args.size} for 1)") if args.size != 1 return '' if args[0].empty? '*' + Digest::SHA1.hexdigest(Digest::SHA1.digest(args[0])).upcase end end puppetlabs-mysql-3.6.1/lib/puppet/parser/functions/mysql_strip_hash.rb000644 000765 000024 00000001043 12600353444 026775 0ustar00morganstaff000000 000000 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. EOS ) do |args| hash = args[0] unless hash.is_a?(Hash) raise(Puppet::ParseError, 'mysql_strip_hash(): Requires hash to work with') 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 end end end puppetlabs-mysql-3.6.1/lib/facter/mysql_server_id.rb000644 000765 000024 00000000306 12600353444 023237 0ustar00morganstaff000000 000000 def get_mysql_id Facter.value(:macaddress).split(':').inject(0) { |total,value| (total << 4) + value.hex } end Facter.add("mysql_server_id") do setcode do get_mysql_id rescue nil end end puppetlabs-mysql-3.6.1/lib/facter/mysql_version.rb000644 000765 000024 00000000272 12600353444 022744 0ustar00morganstaff000000 000000 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 end end puppetlabs-mysql-3.6.1/examples/backup.pp000644 000765 000024 00000000301 12600353444 021110 0ustar00morganstaff000000 000000 class { 'mysql::server': root_password => 'password' } class { 'mysql::server::backup': backupuser => 'myuser', backuppassword => 'mypassword', backupdir => '/tmp/backups', } puppetlabs-mysql-3.6.1/examples/bindings.pp000644 000765 000024 00000000063 12600353444 021445 0ustar00morganstaff000000 000000 class { 'mysql::bindings': php_enable => true, } puppetlabs-mysql-3.6.1/examples/java.pp000644 000765 000024 00000000030 12600353444 020563 0ustar00morganstaff000000 000000 class { 'mysql::java':} puppetlabs-mysql-3.6.1/examples/mysql_database.pp000644 000765 000024 00000000520 12600353444 022637 0ustar00morganstaff000000 000000 class { 'mysql::server': root_password => 'password' } mysql::db{ ['test1', 'test2', 'test3']: ensure => present, charset => 'utf8', require => Class['mysql::server'], } mysql::db{ 'test4': ensure => present, charset => 'latin1', } mysql::db{ 'test5': ensure => present, charset => 'binary', collate => 'binary', } puppetlabs-mysql-3.6.1/examples/mysql_db.pp000644 000765 000024 00000000564 12600353444 021470 0ustar00morganstaff000000 000000 class { 'mysql::server': root_password => 'password' } mysql::db { 'mydb': user => 'myuser', password => 'mypass', host => 'localhost', grant => ['SELECT', 'UPDATE'], } mysql::db { "mydb_${fqdn}": user => 'myuser', password => 'mypass', dbname => 'mydb', host => $::fqdn, grant => ['SELECT', 'UPDATE'], tag => $domain, } puppetlabs-mysql-3.6.1/examples/mysql_grant.pp000644 000765 000024 00000000207 12600353444 022210 0ustar00morganstaff000000 000000 mysql_grant{'test1@localhost/redmine.*': user => 'test1@localhost', table => 'redmine.*', privileges => ['UPDATE'], } puppetlabs-mysql-3.6.1/examples/mysql_plugin.pp000644 000765 000024 00000000725 12600353444 022400 0ustar00morganstaff000000 000000 class { 'mysql::server': root_password => 'password' } $validate_password_soname = $::osfamily ? { windows => 'validate_password.dll', default => 'validate_password.so' } mysql::plugin { 'validate_password': ensure => present, soname => $validate_password_soname, } $auth_socket_soname = $::osfamily ? { windows => 'auth_socket.dll', default => 'auth_socket.so' } mysql::plugin { 'auth_socket': ensure => present, soname => $auth_socket_soname, } puppetlabs-mysql-3.6.1/examples/mysql_user.pp000644 000765 000024 00000001232 12600353444 022052 0ustar00morganstaff000000 000000 $mysql_root_pw = 'password' class { 'mysql::server': root_password => 'password', } mysql_user{ 'redmine@localhost': ensure => present, password_hash => mysql_password('redmine'), require => Class['mysql::server'], } mysql_user{ 'dan@localhost': ensure => present, password_hash => mysql_password('blah') } mysql_user{ 'dan@%': ensure => present, password_hash => mysql_password('blah'), } mysql_user{ 'socketplugin@%': ensure => present, plugin => 'unix_socket', } mysql_user{ 'socketplugin@%': ensure => present, password_hash => mysql_password('blah'), plugin => 'mysql_native_password', } puppetlabs-mysql-3.6.1/examples/perl.pp000644 000765 000024 00000000036 12600353444 020612 0ustar00morganstaff000000 000000 include mysql::bindings::perl puppetlabs-mysql-3.6.1/examples/python.pp000644 000765 000024 00000000044 12600353444 021170 0ustar00morganstaff000000 000000 class { 'mysql::bindings::python':} puppetlabs-mysql-3.6.1/examples/ruby.pp000644 000765 000024 00000000036 12600353444 020631 0ustar00morganstaff000000 000000 include mysql::bindings::ruby puppetlabs-mysql-3.6.1/examples/server/000755 000765 000024 00000000000 12600353524 020615 5ustar00morganstaff000000 000000 puppetlabs-mysql-3.6.1/examples/server.pp000644 000765 000024 00000000072 12600353444 021156 0ustar00morganstaff000000 000000 class { 'mysql::server': root_password => 'password', } puppetlabs-mysql-3.6.1/examples/server/account_security.pp000644 000765 000024 00000000147 12600353444 024544 0ustar00morganstaff000000 000000 class { 'mysql::server': root_password => 'password', } class { 'mysql::server::account_security': } puppetlabs-mysql-3.6.1/examples/server/config.pp000644 000765 000024 00000000047 12600353444 022425 0ustar00morganstaff000000 000000 mysql::server::config { 'testfile': }