# HG changeset patch # User ymh # Date 1460130836 -7200 # Node ID dc4d1cdc47e065dfea4857696b553db87de0661b # Parent 49b75287c30b59292731ac9a073b8f529b83e267 first implementation of handle install. Need refinement diff -r 49b75287c30b -r dc4d1cdc47e0 .hgignore --- a/.hgignore Fri Apr 08 17:50:49 2016 +0200 +++ b/.hgignore Fri Apr 08 17:53:56 2016 +0200 @@ -1,8 +1,10 @@ syntax: regexp ^dev2 ^dev/\.vagrant +^dev/handle ^dev/corpus-dev.box$ ^dev/.*\.rpm +^dev/provisioning/custom.yaml ^server/data ^server/src/\.git.* ^server/src/\.env diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/custom.yaml --- a/dev/provisioning/custom.yaml Fri Apr 08 17:50:49 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ ---- -sysconfig::params::vhost : "int.corpusdelaparole.huma-num.fr" - -sysconfig::params::db_name : corpus -sysconfig::params::db_drpl_name : corpusdelaparole -sysconfig::params::db_user : corpus -sysconfig::params::db_pw : corpus@mariadb -sysconfig::params::db_host : 127.0.0.1 -sysconfig::params::db_port : 3306 - -sysconfig::params::es_host : 127.0.0.1 -sysconfig::params::es_port : 9200 -sysconfig::params::es_instance : "es_01" - -sysconfig::params::tomcat_open_port : true - -sysconfig::params::corpus_app_key : "v6kgofcM4mCqon7ioz9NKSjeug5wiKt6" diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/custom.yaml.tmpl --- a/dev/provisioning/custom.yaml.tmpl Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/custom.yaml.tmpl Fri Apr 08 17:53:56 2016 +0200 @@ -15,6 +15,7 @@ # database server port sysconfig::params::db_port : 3306 + # elasticsearch host sysconfig::params::es_host : 127.0.0.1 # elasticsearch port @@ -22,6 +23,12 @@ # elasticsearch instamce sysconfig::params::es_instance : es_01 +# handle host +sysconfig::params::hdl_host : 172.16.1.6 + +# handle database +sysconfig::params::hdl_db_name : handle + # memory percentage used by memcached sysconfig::params::memcached_max_memory : 25% diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/default.pp --- a/dev/provisioning/default.pp Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/default.pp Fri Apr 08 17:53:56 2016 +0200 @@ -18,6 +18,9 @@ # install php class { 'sysconfig::php': } +# install handle +class { 'sysconfig::handle': } + # install tomcat class { 'sysconfig::tomcat': } diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/.fixtures.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/mysql/.fixtures.yml Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,6 @@ +fixtures: + repositories: + "stdlib": "https://github.com/puppetlabs/puppetlabs-stdlib" + "staging": "https://github.com/nanliu/puppet-staging" + symlinks: + "mysql": "#{source_dir}" diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/.geppetto-rc.json --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/mysql/.geppetto-rc.json Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,9 @@ +{ + "excludes": [ + "**/contrib/**", + "**/examples/**", + "**/tests/**", + "**/spec/**", + "**/pkg/**" + ] +} diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/.gitattributes --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/mysql/.gitattributes Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,5 @@ +#This file is generated by ModuleSync, do not edit. +*.rb eol=lf +*.erb eol=lf +*.pp eol=lf +*.sh eol=lf diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/.gitignore --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/mysql/.gitignore Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,11 @@ +#This file is generated by ModuleSync, do not edit. +pkg/ +Gemfile.lock +vendor/ +spec/fixtures/ +.vagrant/ +.bundle/ +coverage/ +log/ +.idea/ +*.iml diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/.nodeset.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/mysql/.nodeset.yml Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,31 @@ +--- +default_set: 'centos-64-x64' +sets: + 'centos-59-x64': + nodes: + "main.foo.vm": + prefab: 'centos-59-x64' + 'centos-64-x64': + nodes: + "main.foo.vm": + prefab: 'centos-64-x64' + 'fedora-18-x64': + nodes: + "main.foo.vm": + prefab: 'fedora-18-x64' + 'debian-607-x64': + nodes: + "main.foo.vm": + prefab: 'debian-607-x64' + 'debian-70rc1-x64': + nodes: + "main.foo.vm": + prefab: 'debian-70rc1-x64' + 'ubuntu-server-10044-x64': + nodes: + "main.foo.vm": + prefab: 'ubuntu-server-10044-x64' + 'ubuntu-server-12042-x64': + nodes: + "main.foo.vm": + prefab: 'ubuntu-server-12042-x64' diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/.rspec --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/mysql/.rspec Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,2 @@ +--color +--format documentation diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/.sync.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/mysql/.sync.yml Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,5 @@ +--- +Gemfile: + optional: + ':development, :unit_tests': + - gem: rspec-puppet-facts diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/.travis.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/mysql/.travis.yml Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,20 @@ +#This file is generated by ModuleSync, do not edit. +--- +sudo: false +language: ruby +cache: bundler +bundler_args: --without system_tests +script: "bundle exec rake validate lint spec" +matrix: + fast_finish: true + include: + - rvm: 2.1.6 + env: PUPPET_GEM_VERSION="~> 4.0" STRICT_VARIABLES="yes" + - rvm: 2.1.5 + env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes" + - rvm: 2.1.5 + env: PUPPET_GEM_VERSION="~> 3.0" + - rvm: 1.9.3 + env: PUPPET_GEM_VERSION="~> 3.0" +notifications: + email: false diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/CHANGELOG.md --- a/dev/provisioning/modules/mysql/CHANGELOG.md Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/modules/mysql/CHANGELOG.md Fri Apr 08 17:53:56 2016 +0200 @@ -1,3 +1,50 @@ +## Supported Release 3.7.0 +###Summary + +A large release with several new features. Also includes a considerable amount of bugfixes, many around compatibility and improvements to current functionality. + +#### Features + +- Now uses mariadb in OpenSuSE >= 13.1. +- Switch to rspec-puppet-facts. +- Additional function to check if table exists before grant. +- Add ability to input password hash directly. +- Now checking major release instead of specific release. +- Debian 8 support. + +#### Bugfixes + +- Minor doc update. +- Fixes improper use of function `warn` in backup manifest of server. +- Fixes to Compatibility with PE 3.3. +- Fixes `when not managing config file` in `mysql_server_spec`. +- Improved user validation and munging. +- Fixes fetching the mysql_user password for MySQL >=5.7.6. +- Fixes unique server_id within my.cnf, the issue were the entire mac address was not being read in to generate the id. +- Corrects the daemon_dev_package_name for mariadb on redhat. +- Fix version compare to properly suppress show_diff for root password. +- Fixes to ensure compatibility with future parser. +- Solaris removed from PE in metadata as its not supported. +- Use MYSQL_PWD to avoid mysqldump warnings. +- Use temp cnf file instead of env variable which creates acceptance test failures. +- No longer hash passwords that are already hashed. +- Fix Gemfile to work with ruby 1.8.7. +- Fixed MySQL 5.7.6++ compatibility. +- Fixing error when disabling service management and the service does not exist. +- Ubuntu vivid should use systemd not upstart. +- Fixed new mysql_datadir provider on CentOS for MySQl 5.7.6 compatibility. +- Ensure if service restart to wait till mysql is up. +- Move all dependencies to not have them in case of service unmanaged. +- Re-Added the ability to set a empty string as option parameter. +- Fixes edge-case with dropping pre-existing users with grants. +- Fix logic for choosing rspec version. +- Refactored main acceptance suite. +- Skip idempotency tests on test cells that do have PUP-5016 unfixed. +- Fix tmpdir to be shared across examples. +- Update to current msync configs [006831f]. +- Fix mysql_grant with MySQL ANSI_QUOTES mode. +- Generate .my.cnf for all sections. + ## Supported Release 3.6.2 ###Summary diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/Gemfile --- a/dev/provisioning/modules/mysql/Gemfile Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/modules/mysql/Gemfile Fri Apr 08 17:53:56 2016 +0200 @@ -1,49 +1,40 @@ +#This file is generated by ModuleSync, do not edit. + source ENV['GEM_SOURCE'] || "https://rubygems.org" -def location_for(place, fake_version = nil) +def location_for(place, version = nil) if place =~ /^(git[:@][^#]*)#(.*)/ - [fake_version, { :git => $1, :branch => $2, :require => false }].compact + [version, { :git => $1, :branch => $2, :require => false}].compact elsif place =~ /^file:\/\/(.*)/ - ['>= 0', { :path => File.expand_path($1), :require => false }] + ['>= 0', { :path => File.expand_path($1), :require => false}] else - [place, { :require => false }] + [place, version, { :require => false}].compact 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 + gem 'json', :require => false + gem 'metadata-json-lint', :require => false + gem 'puppet_facts', :require => false + gem 'puppet-blacksmith', :require => false + gem 'puppetlabs_spec_helper', :require => false + gem 'rspec-puppet', '>= 2.3.2', :require => false + gem 'simplecov', :require => false + gem 'rspec-puppet-facts', :require => false +end +group :system_tests do + gem 'beaker-rspec', *location_for(ENV['BEAKER_RSPEC_VERSION'] || '>= 3.4') + gem 'beaker', *location_for(ENV['BEAKER_VERSION']) + gem 'serverspec', :require => false + gem 'beaker-puppet_install_helper', :require => false + gem 'master_manipulator', :require => false + gem 'beaker-hostgenerator', *location_for(ENV['BEAKER_HOSTGENERATOR_VERSION']) 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 +gem 'facter', *location_for(ENV['FACTER_GEM_VERSION']) +gem 'puppet', *location_for(ENV['PUPPET_GEM_VERSION']) - -if facterversion = ENV['FACTER_GEM_VERSION'] - gem 'facter', facterversion, :require => false -else - gem 'facter', :require => false +if File.exists? "#{__FILE__}.local" + eval(File.read("#{__FILE__}.local"), binding) end - -if puppetversion = ENV['PUPPET_GEM_VERSION'] - gem 'puppet', puppetversion, :require => false -else - gem 'puppet', :require => false -end - -# vim:ft=ruby diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/LICENSE --- a/dev/provisioning/modules/mysql/LICENSE Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/modules/mysql/LICENSE Fri Apr 08 17:53:56 2016 +0200 @@ -1,3 +1,4 @@ + Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -180,13 +181,13 @@ 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 + 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 + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/NOTICE --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/mysql/NOTICE Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,18 @@ +mysql puppet module + +Copyright (C) 2013-2016 Puppet Labs, Inc. + +Puppet Labs can be contacted at: info@puppetlabs.com + + +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. diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/README.md --- a/dev/provisioning/modules/mysql/README.md Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/modules/mysql/README.md Fri Apr 08 17:53:56 2016 +0200 @@ -3,104 +3,108 @@ #### 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) +2. [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) +3. [Usage - Configuration options and additional functionality](#usage) + * [Customize server options](#customize-server-options) + * [Create a database](#create-a-database) + * [Customize configuration](#create-custom-configuration) + * [Work with an existing server](#work-with-an-existing-server) + * [Specify passwords](#specify-passwords) +4. [Reference - An under-the-hood peek at what the module is doing and how](#reference) +5. [Limitations - OS compatibility, etc.](#limitations) +6. [Development - Guide for contributing to the module](#development) ## Module Description -The MySQL module installs, configures, and manages the MySQL service. +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. +This 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 +### Beginning with mysql -If you want a server installed with the default options you can run +To install a server with the default options: + `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: +To customize options, such as the root +password or `/etc/my.cnf` settings, you must also pass in an override hash: -~~~ +```puppet class { '::mysql::server': 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`. +See [**Customize Server Options**](#customize-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 +### Customize server options -The hash structure for overrides in `mysql::server` can be structured like a hash in the my.cnf file, so: +To define server options, structure a hash structure of overrides in `mysql::server`. This hash resembles a hash in the my.cnf file: -~~~ +```puppet $override_options = { 'section' => { 'item' => 'thing', } } -~~~ +``` -For items that you would traditionally represent as +For options that you would traditionally represent in this format: -~~~ +``` [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. +...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`. +You can pass a variable in the hash without setting a value for it; the variable would then use MySQL's default settings. To exclude an option from the my.cnf file --- for example, when using `override_options` to revert to a default value --- pass `thing => undef`. -If an option needs multiple instances, you can pass an array. For example, +If an option needs multiple instances, pass an array. For example, -~~~ +```puppet $override_options = { 'mysqld' => { 'replicate-do-db' => ['base1', 'base2'], } } -~~~ +``` produces -~~~ +``` [mysqld] replicate-do-db = base1 replicate-do-db = base2 -~~~ +``` -### Creating a database +To implement version specific parameters, specify the version, such as [mysqld-5.5]. This allows one config for different versions of MySQL. -To use `mysql::db` to create a database with a user and assign some privileges: +### Create a database -~~~ +To create a database with a user and some assigned privileges: + +```puppet mysql::db { 'mydb': user => 'myuser', password => 'mypass', host => 'localhost', grant => ['SELECT', 'UPDATE'], } -~~~ +``` -Or to use a different resource name with exported resources: +To use a different resource name with exported resources: -~~~ +```puppet @@mysql::db { "mydb_${fqdn}": user => 'myuser', password => 'mypass', @@ -109,19 +113,19 @@ grant => ['SELECT', 'UPDATE'], tag => $domain, } -~~~ +``` Then you can collect it on the remote DB server: -~~~ +```puppet 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. +If you set the sql parameter to a file when creating a database, the file is imported into the new database. -For large sql files, you should raise the $import_timeout parameter, set by default to 300 seconds. +For large sql files, increase the `import_timeout` parameter, which defaults to 300 seconds. -~~~ +```puppet mysql::db { 'mydb': user => 'myuser', password => 'mypass', @@ -130,27 +134,37 @@ sql => '/path/to/sqlfile', import_timeout => 900, } -~~~ +``` -### Custom Configuration +### Customize 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. +To add custom MySQL configuration, place additional files into `includedir`. This allows you to override settings or add additional ones, which is helpful if you don't use `override_options` in `mysql::server`. The `includedir` location is by default set to `/etc/mysql/conf.d`. -### Working with an existing server +### Work with an existing server + +To instantiate databases and users on an existing MySQL server, you need a `.my.cnf` file in `root`'s home directory. This file must specify the remote server address and credentials. For example: -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. + +### Specify passwords - [client] - user=root - host=localhost - password=secret +In addition to passing passwords as plain text, you can input them as hashes. For example: -When working with a remote server, do *not* use the -`mysql::server` class in your Puppet manifests. +```puppet +mysql::db { 'mydb': + user => 'myuser', + password => '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4', + host => 'localhost', + grant => ['SELECT', 'UPDATE'], +} +``` ## Reference @@ -168,6 +182,7 @@ #### Private classes * `mysql::server::install`: Installs packages. +* `mysql::server::installdb`: Implements setup of mysqld data directory (e.g. /var/lib/mysql) * `mysql::server::config`: Configures MYSQL. * `mysql::server::service`: Manages service. * `mysql::server::account_security`: Deletes default MySQL accounts. @@ -191,23 +206,21 @@ ##### `create_root_user` -Specify whether root user should be created. Valid values are 'true', 'false'. Defaults to 'true'. +Whether root user should be created. Valid values are true, false. Defaults to true. -This is useful for a cluster setup with Galera. The root user has to -be created only once. `create_root_user` can be set to 'true' on one node while -it is set to 'false' on the remaining nodes. +This is useful for a cluster setup with Galera. The root user has to be created only once. You can set this parameter true on one node and set it to false on the remaining nodes. ##### `create_root_my_cnf` -If set to 'true', creates `/root/.my.cnf`. Valid values are 'true', 'false'. Defaults to 'true'. +Whether to create `/root/.my.cnf`. Valid values are true, false. Defaults to true. -`create_root_my_cnf` allows creation of `/root/.my.cnf` independently of `create_root_user`. This can be used for a cluster setup with Galera where you want `/root/.my.cnf` to exist on all nodes. +`create_root_my_cnf` allows creation of `/root/.my.cnf` independently of `create_root_user`. You can use this for a cluster setup with Galera where you want `/root/.my.cnf` to exist on all nodes. ##### `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. +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. @@ -217,17 +230,17 @@ ##### `override_options` -The hash of override options to pass into MySQL. Structured like a hash in the my.cnf file: +Specifies override options to pass into MySQL. Structured like a hash in the my.cnf file: -~~~ +```puppet $override_options = { 'section' => { 'item' => 'thing', } } -~~~ +``` -See [**Customizing Server Options**](#customizing-server-options) above for usage details. +See [**Customize Server Options**](#customize-server-options) above for usage details. ##### `config_file` @@ -235,21 +248,21 @@ ##### `manage_config_file` -Whether the MySQL configuration file should be managed. Valid values are 'true', 'false'. Defaults to 'true'. +Whether the MySQL configuration file should be managed. Valid values are true, false. Defaults to true. ##### `includedir` The location, as a path, of !includedir for custom configuration overrides. ##### `install_options` -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. +Passes [install_options](https://docs.puppetlabs.com/references/latest/type.html#package-attribute-install_options) array to managed package resources. You must pass the appropriate options for the specified package manager. ##### `purge_conf_dir` -Whether the `includedir` directory should be purged. Valid values are 'true', 'false'. Defaults to 'false'. +Whether the `includedir` directory should be purged. Valid values are true, false. Defaults to false. ##### `restart` -Whether the service should be restarted when things change. Valid values are 'true', 'false'. Defaults to 'false'. +Whether the service should be restarted when things change. Valid values are true, false. Defaults to false. ##### `root_group` @@ -273,15 +286,15 @@ ##### `remove_default_accounts` -Specify whether to automatically include `mysql::server::account_security`. Valid values are 'true', 'false'. Defaults to 'false'. +Specifies whether to automatically include `mysql::server::account_security`. Valid values are true, false. Defaults to false. ##### `service_enabled` -Specify whether the service should be enabled. Valid values are 'true', 'false'. Defaults to 'true'. +Specifies whether the service should be enabled. Valid values are true, false. Defaults to true. ##### `service_manage` -Specify whether the service should be managed. Valid values are 'true', 'false'. Defaults to 'true'. +Specifies whether the service should be managed. Valid values are true, false. Defaults to true. ##### `service_name` @@ -295,7 +308,7 @@ Optional hash of users to create, which are passed to [mysql_user](#mysql_user). -~~~ +``` users => { 'someuser@localhost' => { ensure => 'present', @@ -306,13 +319,13 @@ password_hash => '*F3A2A51A9B0F2BE2468926B4132313728C250DBF', }, } -~~~ +``` ##### `grants` Optional hash of grants, which are passed to [mysql_grant](#mysql_grant). -~~~ +``` grants => { 'someuser@localhost/somedb.*' => { ensure => 'present', @@ -322,20 +335,20 @@ 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 @@ -368,7 +381,7 @@ ##### `backupcompress` -Whether backups should be compressed. Valid values are 'true', 'false'. Defaults to 'true'. +Whether backups should be compressed. Valid values are true, false. Defaults to true. ##### `backuprotate` @@ -376,23 +389,23 @@ ##### `delete_before_dump` -Whether to delete old .sql files before backing up. Setting to 'true' deletes old files before backing up, while setting to 'false' deletes them after backup. Valid values are 'true', 'false'. Defaults to 'false'. +Whether to delete old .sql files before backing up. Setting to true deletes old files before backing up, while setting to false deletes them after backup. Valid values are true, false. Defaults to false. ##### `backupdatabases` -Specify an array of databases to back up. +Specifies 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'. +Whether a separate file be used per database. Valid values are true, false. Defaults to false. ##### `include_routines` -Whether or not to include routines for each database when doing a `file_per_database` backup. Defaults to `false`. +Whether or not to include routines for each database when doing a `file_per_database` backup. Defaults to false. ##### `include_triggers` -Whether or not to include triggers for each database when doing a `file_per_database` backup. Defaults to `false`. +Whether or not to include triggers for each database when doing a `file_per_database` backup. Defaults to false. ##### `ensure` @@ -450,41 +463,41 @@ ##### `source` -Parameter to optionally specify the source. If not specified, defaults to `https://github.com/major/MySQLTuner-perl/raw/${version}/mysqltuner.pl` +Specifies 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'. +Specifies 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'. +Specifies 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'. +Specifies 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'. +Specifies 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'. +Specifies 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'. +Specifies 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'. +Specifies 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). +Passes `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` @@ -570,7 +583,7 @@ ##### `bindings_enable` -Whether to automatically install all bindings. Valid values are 'true', 'false'. Default to 'false'. +Whether to automatically install all bindings. Valid values are true, false. Default to false. ##### `install_options` Array of install options for managed package resources. You must pass the appropriate options for the package manager. @@ -591,7 +604,7 @@ #### mysql::db -~~~ +``` mysql_database { 'information_schema': ensure => 'present', charset => 'utf8', @@ -602,7 +615,7 @@ charset => 'latin1', collate => 'latin1_swedish_ci', } -~~~ +``` ##### `user` @@ -638,11 +651,11 @@ ##### `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'. +Specifies whether executing the sqlfiles should happen on every run. If set to false, sqlfiles only run once. Valid values are true, false. Defaults to false. ##### `ensure` -Specify whether to create the database. Valid values are 'present', 'absent'. Defaults to 'present'. +Specifies whether to create the database. Valid values are 'present', 'absent'. Defaults to 'present'. ##### `import_timeout` @@ -674,7 +687,7 @@ Creates and manages user grants within MySQL. -~~~ +``` mysql_user { 'root@127.0.0.1': ensure => 'present', max_connections_per_hour => '0', @@ -682,16 +695,16 @@ 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` @@ -724,7 +737,7 @@ 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'], @@ -732,18 +745,18 @@ 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` @@ -773,12 +786,12 @@ `mysql_plugin` can be used to load plugins into the MySQL Server. -~~~ +``` mysql_plugin { 'auth_socket': ensure => 'present', soname => 'auth_socket.so', } -~~~ +``` ##### `ensure` @@ -792,6 +805,17 @@ The library file name. +#### `mysql_datadir` + +Initializes the MySQL data directory with version specific code. Pre MySQL 5.7.6 +it uses mysql_install_db. After MySQL 5.7.6 it uses mysqld --initialize-insecure. + +Insecure initialization is needed, as mysqld version 5.7 introduced "secure by default" mode. +This means MySQL generates a random password and writes it to STDOUT. This means puppet +can never accesss the database server afterwards, as no credencials are available. + +This type is an internal type and should not be called directly. + ### Facts #### `mysql_version` diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/Rakefile --- a/dev/provisioning/modules/mysql/Rakefile Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/modules/mysql/Rakefile Fri Apr 08 17:53:56 2016 +0200 @@ -1,5 +1,6 @@ +require 'puppet_blacksmith/rake_tasks' +require 'puppet-lint/tasks/puppet-lint' require 'puppetlabs_spec_helper/rake_tasks' -require 'puppet-lint/tasks/puppet-lint' PuppetLint.configuration.fail_on_warnings = true PuppetLint.configuration.send('relative') @@ -8,3 +9,34 @@ PuppetLint.configuration.send('disable_documentation') PuppetLint.configuration.send('disable_single_quote_string_with_variables') PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"] + +desc 'Generate pooler nodesets' +task :gen_nodeset do + require 'beaker-hostgenerator' + require 'securerandom' + require 'fileutils' + + agent_target = ENV['TEST_TARGET'] + if ! agent_target + STDERR.puts 'TEST_TARGET environment variable is not set' + STDERR.puts 'setting to default value of "redhat-64default."' + agent_target = 'redhat-64default.' + end + + master_target = ENV['MASTER_TEST_TARGET'] + if ! master_target + STDERR.puts 'MASTER_TEST_TARGET environment variable is not set' + STDERR.puts 'setting to default value of "redhat7-64mdcl"' + master_target = 'redhat7-64mdcl' + end + + targets = "#{master_target}-#{agent_target}" + cli = BeakerHostGenerator::CLI.new([targets]) + nodeset_dir = "tmp/nodesets" + nodeset = "#{nodeset_dir}/#{targets}-#{SecureRandom.uuid}.yaml" + FileUtils.mkdir_p(nodeset_dir) + File.open(nodeset, 'w') do |fh| + fh.print(cli.execute) + end + puts nodeset +end diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/checksums.json --- a/dev/provisioning/modules/mysql/checksums.json Fri Apr 08 17:50:49 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,111 +0,0 @@ -{ - "CHANGELOG.md": "d399acef847a31667783e1f9d5f62547", - "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": "2372889b329a6ac5eac163334a03562b", - "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" -} \ No newline at end of file diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/lib/facter/mysql_server_id.rb --- a/dev/provisioning/modules/mysql/lib/facter/mysql_server_id.rb Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/modules/mysql/lib/facter/mysql_server_id.rb Fri Apr 08 17:53:56 2016 +0200 @@ -1,5 +1,5 @@ def get_mysql_id - Facter.value(:macaddress).split(':').inject(0) { |total,value| (total << 4) + value.hex } + Facter.value(:macaddress).split(':').inject(0) { |total,value| (total << 6) + value.hex } end Facter.add("mysql_server_id") do diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/lib/puppet/parser/functions/mysql_password.rb --- a/dev/provisioning/modules/mysql/lib/puppet/parser/functions/mysql_password.rb Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/modules/mysql/lib/puppet/parser/functions/mysql_password.rb Fri Apr 08 17:53:56 2016 +0200 @@ -11,6 +11,7 @@ "given (#{args.size} for 1)") if args.size != 1 return '' if args[0].empty? + return args[0] if args[0] =~ /\*[A-F0-9]{40}$/ '*' + Digest::SHA1.hexdigest(Digest::SHA1.digest(args[0])).upcase end end diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/lib/puppet/parser/functions/mysql_table_exists.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/mysql/lib/puppet/parser/functions/mysql_table_exists.rb Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,30 @@ +module Puppet::Parser::Functions + newfunction(:mysql_table_exists, :type => :rvalue, :doc => <<-EOS + Check if table exists in database. + + For example: + + mysql_table_exists('*.*') or mysql_table_exists('example_database.*') always return true + mysql_table_exists('example_db.example_table') check existence table `example_table` in `example_database` + + EOS + ) do |args| + + return raise(Puppet::ParseError, + "mysql_table_exists() accept 1 argument - table string like 'database_name.table_name'") unless (args.size == 1 and match = args[0].match(/(.*)\.(.*)/)) + + db_name, table_name = match.captures + return true if (db_name.eql?('*') or table_name.eql?('*')) ## *.* is valid table string, but we shouldn't check it for existence + query = "SELECT TABLE_NAME FROM information_schema.tables WHERE TABLE_NAME = '#{table_name}' AND TABLE_SCHEMA = '#{db_name}';" + %x{mysql #{defaults_file} -NBe #{query}}.strip.eql?(table_name) + + end +end + +def defaults_file + if File.file?("#{Facter.value(:root_home)}/.my.cnf") + "--defaults-extra-file=#{Facter.value(:root_home)}/.my.cnf" + else + nil + end +end \ No newline at end of file diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/lib/puppet/provider/mysql.rb --- a/dev/provisioning/modules/mysql/lib/puppet/provider/mysql.rb Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/modules/mysql/lib/puppet/provider/mysql.rb Fri Apr 08 17:53:56 2016 +0200 @@ -2,7 +2,12 @@ # Without initvars commands won't work. initvars + + # Make sure we find mysqld on CentOS + ENV['PATH']=ENV['PATH'] + ':/usr/libexec' + commands :mysql => 'mysql' + commands :mysqld => 'mysqld' commands :mysqladmin => 'mysqladmin' # Optional defaults file @@ -13,7 +18,41 @@ nil end end - + + def self.mysqld_type + # find the mysql "dialect" like mariadb / mysql etc. + mysqld_version_string.scan(/\s\(mariadb/i) { return "mariadb" } + mysqld_version_string.scan(/\s\(mysql/i) { return "mysql" } + mysqld_version_string.scan(/\s\(percona/i) { return "percona" } + nil + end + + def mysqld_type + self.class.mysqld_type + end + + def self.mysqld_version_string + # we cache the result ... + return @mysqld_version_string unless @mysqld_version_string.nil? + @mysqld_version_string = mysqld(['-V'].compact) + return @mysqld_version_string + end + + def mysqld_version_string + self.class.mysqld_version_string + end + + def self.mysqld_version + # note: be prepared for '5.7.6-rc-log' etc results + # versioncmp detects 5.7.6-log to be newer then 5.7.6 + # this is why we need the trimming. + mysqld_version_string.scan(/\d+\.\d+\.\d+/).first unless mysqld_version_string.nil? + end + + def mysqld_version + self.class.mysqld_version + end + def defaults_file self.class.defaults_file end diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/lib/puppet/provider/mysql_datadir/mysql.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/mysql/lib/puppet/provider/mysql_datadir/mysql.rb Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,70 @@ +require File.expand_path(File.join(File.dirname(__FILE__), '..', 'mysql')) +Puppet::Type.type(:mysql_datadir).provide(:mysql, :parent => Puppet::Provider::Mysql) do + + desc 'manage data directories for mysql instances' + + initvars + + # Make sure we find mysqld on CentOS + ENV['PATH']=ENV['PATH'] + ':/usr/libexec' + + commands :mysqld => 'mysqld' + commands :mysql_install_db => 'mysql_install_db' + + def create + name = @resource[:name] + insecure = @resource.value(:insecure) || true + defaults_extra_file = @resource.value(:defaults_extra_file) + user = @resource.value(:user) || "mysql" + basedir = @resource.value(:basedir) || "/usr" + datadir = @resource.value(:datadir) || @resource[:name] + + unless defaults_extra_file.nil? + if File.exist?(defaults_extra_file) + defaults_extra_file="--defaults-extra-file=#{defaults_extra_file}" + else + raise ArgumentError, "Defaults-extra-file #{defaults_extra_file} is missing" + end + end + + if insecure == true + initialize="--initialize-insecure" + else + initialize="--initialize" + end + + if mysqld_version.nil? + debug("Installing MySQL data directory with mysql_install_db --basedir=#{basedir} #{defaults_extra_file} --datadir=#{datadir} --user=#{user}") + mysql_install_db(["--basedir=#{basedir}",defaults_extra_file, "--datadir=#{datadir}", "--user=#{user}"].compact) + else + if mysqld_type == "mysql" and Puppet::Util::Package.versioncmp(mysqld_version, '5.7.6') >= 0 + debug("Initializing MySQL data directory >= 5.7.6 with 'mysqld #{defaults_extra_file} #{initialize} --basedir=#{basedir} --datadir=#{datadir} --user=#{user}'") + mysqld([defaults_extra_file,initialize,"--basedir=#{basedir}","--datadir=#{datadir}", "--user=#{user}", "--log_error=/var/tmp/mysqld_initialize.log"].compact) + else + debug("Installing MySQL data directory with mysql_install_db --basedir=#{basedir} #{defaults_extra_file} --datadir=#{datadir} --user=#{user}") + mysql_install_db(["--basedir=#{basedir}",defaults_extra_file, "--datadir=#{datadir}", "--user=#{user}"].compact) + end + end + + exists? + end + + def destroy + name = @resource[:name] + raise ArgumentError, "ERROR: Resource can not be removed" + end + + def exists? + datadir = @resource[:datadir] + File.directory?("#{datadir}/mysql") + end + + ## + ## MySQL datadir properties + ## + + # Generates method for all properties of the property_hash + mk_resource_methods + +end + diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/lib/puppet/provider/mysql_grant/mysql.rb --- a/dev/provisioning/modules/mysql/lib/puppet/provider/mysql_grant/mysql.rb Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/modules/mysql/lib/puppet/provider/mysql_grant/mysql.rb Fri Apr 08 17:53:56 2016 +0200 @@ -25,7 +25,7 @@ # 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("`") + munged_grant = grant.delete("'").delete("`").delete('"') # Matching: GRANT (SELECT, UPDATE) PRIVILEGES ON (*.*) TO ('root')@('127.0.0.1') (WITH GRANT OPTION) if match = munged_grant.match(/^GRANT\s(.+)\sON\s(.+)\sTO\s(.*)@(.*?)(\s.*)?$/) privileges, table, user, host, rest = match.captures @@ -114,7 +114,11 @@ end def destroy - revoke(@property_hash[:user], @property_hash[:table]) + # if the user was dropped, it'll have been removed from the user hash + # as the grants are alraedy removed by the DROP statement + if self.class.users.include? @property_hash[:user] + revoke(@property_hash[:user], @property_hash[:table]) + end @property_hash.clear exists? ? (return false) : (return true) diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/lib/puppet/provider/mysql_user/mysql.rb --- a/dev/provisioning/modules/mysql/lib/puppet/provider/mysql_user/mysql.rb Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/modules/mysql/lib/puppet/provider/mysql_user/mysql.rb Fri Apr 08 17:53:56 2016 +0200 @@ -12,7 +12,16 @@ # 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}'" + if mysqld_version.nil? + ## Default ... + query = "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, PASSWORD /*!50508 , PLUGIN */ FROM mysql.user WHERE CONCAT(user, '@', host) = '#{name}'" + else + if mysqld_type == "mysql" and Puppet::Util::Package.versioncmp(mysqld_version, '5.7.6') >= 0 + query = "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, AUTHENTICATION_STRING, PLUGIN FROM mysql.user WHERE CONCAT(user, '@', host) = '#{name}'" + else + query = "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, PASSWORD /*!50508 , PLUGIN */ FROM mysql.user WHERE CONCAT(user, '@', host) = '#{name}'" + end + end @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/) @@ -51,7 +60,11 @@ # 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) + if plugin == 'sha256_password' and !password_hash.nil? + mysql([defaults_file, '-e', "CREATE USER '#{merged_name}' IDENTIFIED WITH '#{plugin}' AS '#{password_hash}'"].compact) + else + mysql([defaults_file, '-e', "CREATE USER '#{merged_name}' IDENTIFIED WITH '#{plugin}'"].compact) + end @property_hash[:ensure] = :present @property_hash[:plugin] = plugin else @@ -89,7 +102,24 @@ def password_hash=(string) merged_name = self.class.cmd_user(@resource[:name]) - mysql([defaults_file, '-e', "SET PASSWORD FOR #{merged_name} = '#{string}'"].compact) + + # We have a fact for the mysql version ... + if mysqld_version.nil? + # default ... if mysqld_version does not work + mysql([defaults_file, '-e', "SET PASSWORD FOR #{merged_name} = '#{string}'"].compact) + else + # Version >= 5.7.6 (many password related changes) + if mysqld_type == "mysql" and Puppet::Util::Package.versioncmp(mysqld_version, '5.7.6') >= 0 + if string.match(/^\*/) + mysql([defaults_file, '-e', "ALTER USER #{merged_name} IDENTIFIED WITH mysql_native_password AS '#{string}'"].compact) + else + raise ArgumentError, "Only mysql_native_password (*ABCD...XXX) hashes are supported" + end + else + # older versions + mysql([defaults_file, '-e', "SET PASSWORD FOR #{merged_name} = '#{string}'"].compact) + end + end password_hash == string ? (return true) : (return false) end diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/lib/puppet/type/mysql_datadir.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/mysql/lib/puppet/type/mysql_datadir.rb Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,30 @@ +Puppet::Type.newtype(:mysql_datadir) do + @doc = 'Manage MySQL datadirs with mysql_install_db OR mysqld (5.7.6 and above).' + + ensurable + + autorequire(:package) { 'mysql-server' } + + newparam(:datadir, :namevar => true) do + desc "The datadir name" + end + + newparam(:basedir) do + desc 'The basedir name, default /usr.' + newvalues(/^\//) + end + + newparam(:user) do + desc 'The user for the directory default mysql (name, not uid).' + end + + newparam(:defaults_extra_file) do + desc "MySQL defaults-extra-file with absolute path (*.cnf)." + newvalues(/^\/.*\.cnf$/) + end + + newparam(:insecure, :boolean => true) do + desc "Insecure initialization (needed for 5.7.6++)." + end + +end diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/manifests/backup/mysqlbackup.pp --- a/dev/provisioning/modules/mysql/manifests/backup/mysqlbackup.pp Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/modules/mysql/manifests/backup/mysqlbackup.pp Fri Apr 08 17:53:56 2016 +0200 @@ -62,7 +62,7 @@ user => 'root', hour => $time[0], minute => $time[1], - weekday => 0, + weekday => '0', require => Package['meb'], } @@ -72,7 +72,7 @@ user => 'root', hour => $time[0], minute => $time[1], - weekday => 1-6, + weekday => '1-6', require => Package['meb'], } diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/manifests/backup/xtrabackup.pp --- a/dev/provisioning/modules/mysql/manifests/backup/xtrabackup.pp Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/modules/mysql/manifests/backup/xtrabackup.pp Fri Apr 08 17:53:56 2016 +0200 @@ -32,7 +32,7 @@ user => 'root', hour => $time[0], minute => $time[1], - weekday => 0, + weekday => '0', require => Package['percona-xtrabackup'], } @@ -42,7 +42,7 @@ user => 'root', hour => $time[0], minute => $time[1], - weekday => 1-6, + weekday => '1-6', require => Package['percona-xtrabackup'], } diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/manifests/params.pp --- a/dev/provisioning/modules/mysql/manifests/params.pp Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/modules/mysql/manifests/params.pp Fri Apr 08 17:53:56 2016 +0200 @@ -55,22 +55,24 @@ } 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' + $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' + $includedir = undef + $pidfile = '/var/run/mariadb/mariadb.pid' + $daemon_dev_package_name = 'mariadb-devel' } 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' + $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' + $daemon_dev_package_name = 'mysql-devel' } $basedir = '/usr' @@ -89,15 +91,22 @@ $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' + if versioncmp( $::operatingsystemmajrelease, '13' ) >= 0 { + $client_package_name = 'mariadb-client' + $server_package_name = 'mariadb' + # First service start fails if this is set. Runs fine without + # it being set, in any case. Leaving it as-is for the mysql. + $basedir = undef + } else { + $client_package_name = 'mysql-community-server-client' + $server_package_name = 'mysql-community-server' + $basedir = '/usr' + } } 'SLES','SLED': { if versioncmp($::operatingsystemrelease, '12') >= 0 { @@ -350,7 +359,11 @@ case $::operatingsystem { 'Ubuntu': { - $server_service_provider = upstart + if versioncmp($::operatingsystemmajrelease, '14.10') > 0 { + $server_service_provider = 'systemd' + } else { + $server_service_provider = 'upstart' + } } default: { $server_service_provider = undef @@ -367,6 +380,21 @@ 'log-error' => $mysql::params::log_error, 'socket' => $mysql::params::socket, }, + 'mysqld-5.0' => { + 'myisam-recover' => 'BACKUP', + }, + 'mysqld-5.1' => { + 'myisam-recover' => 'BACKUP', + }, + 'mysqld-5.5' => { + 'myisam-recover' => 'BACKUP', + }, + 'mysqld-5.6' => { + 'myisam-recover-options' => 'BACKUP', + }, + 'mysqld-5.7' => { + 'myisam-recover-options' => 'BACKUP', + }, 'mysqld' => { 'basedir' => $mysql::params::basedir, 'bind-address' => '127.0.0.1', @@ -377,7 +405,6 @@ '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', diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/manifests/server/installdb.pp --- a/dev/provisioning/modules/mysql/manifests/server/installdb.pp Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/modules/mysql/manifests/server/installdb.pp Fri Apr 08 17:53:56 2016 +0200 @@ -10,20 +10,21 @@ $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}" - + $_config_file=$config_file + } else { + $_config_file=undef } - 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'], + mysql_datadir { $datadir: + ensure => 'present', + datadir => $datadir, + basedir => $basedir, + user => $mysqluser, + defaults_extra_file => $_config_file, } if $mysql::server::restart { - Exec['mysql_install_db'] { + Mysql_datadir[$datadir] { notify => Class['mysql::server::service'], } } diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/manifests/server/root_password.pp --- a/dev/provisioning/modules/mysql/manifests/server/root_password.pp Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/modules/mysql/manifests/server/root_password.pp Fri Apr 08 17:53:56 2016 +0200 @@ -35,7 +35,7 @@ } # show_diff was added with puppet 3.0 - if versioncmp($::puppetversion, '3.0') <= 0 { + if versioncmp($::puppetversion, '3.0') >= 0 { File["${::root_home}/.my.cnf"] { show_diff => false } } if $mysql::server::create_root_user == true { diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/manifests/server/service.pp --- a/dev/provisioning/modules/mysql/manifests/server/service.pp Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/modules/mysql/manifests/server/service.pp Fri Apr 08 17:53:56 2016 +0200 @@ -26,25 +26,41 @@ } } - service { 'mysqld': - ensure => $service_ensure, - name => $mysql::server::service_name, - enable => $mysql::server::real_service_enabled, - provider => $mysql::server::service_provider, - } + if $mysql::server::real_service_manage { + 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 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'] + } + + if $mysql::server::override_options and $mysql::server::override_options['mysqld'] and $mysql::server::override_options['mysqld']['socket'] { + $mysqlsocket = $mysql::server::override_options['mysqld']['socket'] + } else { + $mysqlsocket = $options['mysqld']['socket'] + } + + exec { 'wait_for_mysql_socket_to_open': + command => "test -S ${mysqlsocket}", + unless => "test -S ${mysqlsocket}", + tries => '3', + try_sleep => '10', + require => Service['mysqld'], + path => '/bin:/usr/bin', } } - - # 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'] - } - } diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/metadata.json --- a/dev/provisioning/modules/mysql/metadata.json Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/modules/mysql/metadata.json Fri Apr 08 17:53:56 2016 +0200 @@ -1,6 +1,6 @@ { "name": "puppetlabs-mysql", - "version": "3.6.2", + "version": "3.7.0", "author": "Puppet Labs", "summary": "Installs, configures, and manages the MySQL service.", "license": "Apache-2.0", @@ -55,7 +55,8 @@ "operatingsystem": "Debian", "operatingsystemrelease": [ "6", - "7" + "7", + "8" ] }, { @@ -63,15 +64,8 @@ "operatingsystemrelease": [ "10.04", "12.04", - "14.04" - ] - }, - { - "operatingsystem": "Solaris", - "operatingsystemrelease": [ - "11.2", - "11.3", - "12.0" + "14.04", + "16.04" ] } ], diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/spec/acceptance/mysql_db_spec.rb --- a/dev/provisioning/modules/mysql/spec/acceptance/mysql_db_spec.rb Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/modules/mysql/spec/acceptance/mysql_db_spec.rb Fri Apr 08 17:53:56 2016 +0200 @@ -2,28 +2,26 @@ 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 + let(:pp) do + <<-EOS class { 'mysql::server': root_password => 'password' } mysql::db { 'spec1': user => 'root1', password => 'password', } EOS + end + it_behaves_like "a idempotent resource" - # 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 + describe command("mysql -e 'show databases;'") do + its(:exit_status) { is_expected.to eq 0 } + its(:stdout) { is_expected.to match /^spec1$/ } 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 + let(:pp) do + <<-EOS class { 'mysql::server': override_options => { 'root_password' => 'password' } } file { '/tmp/spec.sql': ensure => file, @@ -36,21 +34,19 @@ sql => '/tmp/spec.sql', } EOS + end + it_behaves_like "a idempotent resource" - # 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 + describe command("mysql -e 'show tables;' spec2") do + its(:exit_status) { is_expected.to eq 0 } + its(:stdout) { is_expected.to match /^table1$/ } 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 + let(:check_command) { " | grep realdb" } + let(:pp) do + <<-EOS class { 'mysql::server': override_options => { 'root_password' => 'password' } } mysql::db { 'spec1': user => 'root1', @@ -58,14 +54,12 @@ dbname => 'realdb', } EOS + end + it_behaves_like "a idempotent resource" - # 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 + describe command("mysql -e 'show databases;'") do + its(:exit_status) { is_expected.to eq 0 } + its(:stdout) { is_expected.to match /^realdb$/ } end end end diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/spec/acceptance/mysql_server_spec.rb --- a/dev/provisioning/modules/mysql/spec/acceptance/mysql_server_spec.rb Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/modules/mysql/spec/acceptance/mysql_server_spec.rb Fri Apr 08 17:53:56 2016 +0200 @@ -1,15 +1,15 @@ 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 + describe 'advanced config' do + before(:all) do + @tmpdir = default.tmpdir('mysql') + end + let(:pp) do + <<-EOS class { 'mysql::server': - config_file => '#{tmpdir}/my.cnf', - includedir => '#{tmpdir}/include', + config_file => '#{@tmpdir}/my.cnf', + includedir => '#{@tmpdir}/include', manage_config_file => 'true', override_options => { 'mysqld' => { 'key_buffer_size' => '32M' }}, package_ensure => 'present', @@ -46,23 +46,33 @@ } } EOS + end - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end + it_behaves_like "a idempotent resource" end - describe 'configuration needed for syslog' do - it 'should work with no errors' do - pp = <<-EOS + describe 'syslog configuration' do + let(:pp) do + <<-EOS class { 'mysql::server': override_options => { 'mysqld' => { 'log-error' => undef }, 'mysqld_safe' => { 'log-error' => false, 'syslog' => true }}, } EOS + end - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) + it_behaves_like "a idempotent resource" + end + + context 'when changing the password' do + let(:password) { 'THE NEW SECRET' } + let(:pp) { "class { 'mysql::server': root_password => '#{password}' }" } + + it 'should not display the password' do + result = apply_manifest(pp, :catch_failures => true) + # this does not actually prove anything, as show_diff in the puppet config defaults to false. + expect(result.stdout).not_to match /#{password}/ end + + it_behaves_like "a idempotent resource" end end - diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/spec/acceptance/types/mysql_grant_spec.rb --- a/dev/provisioning/modules/mysql/spec/acceptance/types/mysql_grant_spec.rb Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/modules/mysql/spec/acceptance/types/mysql_grant_spec.rb Fri Apr 08 17:53:56 2016 +0200 @@ -413,4 +413,76 @@ end end + describe 'adding privileges to specific table' do + # Using puppet_apply as a helper + it 'setup mysql server' do + pp = <<-EOS + class { 'mysql::server': override_options => { 'root_password' => 'password' } } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'creates grant on missing table will fail' do + pp = <<-EOS + mysql_grant { 'test@localhost/grant_spec_db.grant_spec_table': + user => 'test@localhost', + privileges => ['SELECT'], + table => 'grant_spec_db.grant_spec_table', + } + EOS + expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/Table 'grant_spec_db\.grant_spec_table' doesn't exist/) + end + + it 'checks if table exists before grant' do + pp = <<-EOS + if mysql_table_exists('grant_spec_db.grant_spec_table') { + mysql_grant { 'test@localhost/grant_spec_db.grant_spec_table': + user => 'test@localhost', + privileges => 'ALL', + table => 'grant_spec_db.grant_spec_table', + } + } + EOS + apply_manifest(pp, :catch_changes => true) + end + + it 'creates table' do + pp = <<-EOS + file { '/tmp/grant_spec_table.sql': + ensure => file, + content => 'CREATE TABLE grant_spec_table (id int);', + before => Mysql::Db['grant_spec_db'], + } + mysql::db { 'grant_spec_db': + user => 'root1', + password => 'password', + sql => '/tmp/grant_spec_table.sql', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should have the table' do + expect(shell("mysql -e 'show tables;' grant_spec_db|grep grant_spec_table").exit_code).to be_zero + end + + it 'checks if table exists before grant' do + pp = <<-EOS + if mysql_table_exists('grant_spec_db.grant_spec_table') { + mysql_grant { 'test@localhost/grant_spec_db.grant_spec_table': + user => 'test@localhost', + privileges => ['SELECT'], + table => 'grant_spec_db.grant_spec_table', + } + } + EOS + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + + end + end diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/spec/classes/graceful_failures_spec.rb --- a/dev/provisioning/modules/mysql/spec/classes/graceful_failures_spec.rb Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/modules/mysql/spec/classes/graceful_failures_spec.rb Fri Apr 08 17:53:56 2016 +0200 @@ -1,15 +1,19 @@ 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 "on an unsupported OS" do + # fetch any sets of facts to modify them + os, facts = on_supported_os.first - context 'should gracefully fail' do - it { expect { is_expected.to compile}.to raise_error(Puppet::Error, /Unsupported platform:/) } - end - end + let(:facts) { + facts.merge({ + :osfamily => 'UNSUPPORTED', + :operatingsystem => 'UNSUPPORTED', + }) + } + + it 'should gracefully fail' do + is_expected.to compile.and_raise_error(/Unsupported platform:/) end end end diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/spec/classes/mycnf_template_spec.rb --- a/dev/provisioning/modules/mysql/spec/classes/mycnf_template_spec.rb Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/modules/mysql/spec/classes/mycnf_template_spec.rb Fri Apr 08 17:53:56 2016 +0200 @@ -2,76 +2,83 @@ 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 } + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) { + facts.merge({ + :root_home => '/root', + }) + } - context 'normal entry' do - let(:params) {{ :override_options => { 'mysqld' => { 'socket' => '/var/lib/mysql/mysql.sock' } } }} - it do - is_expected.to contain_file('mysql-config-file').with({ - :mode => '0644', - :selinux_ignore_defaults => true, - }).with_content(/socket = \/var\/lib\/mysql\/mysql.sock/) - end + 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 '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 'skip-name-resolve set to an empty string' do + let(:params) {{ :override_options => { 'mysqld' => { 'skip-name-resolve' => '' }}}} + it { is_expected.to contain_file('mysql-config-file').with_content(/^skip-name-resolve$/) } + 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 - 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 + # 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 '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/) } + 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 - # 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 + it { is_expected.to contain_file('mysql-config-file').with_content(/!includedir/) } + 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/) } + 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 - 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 + it { is_expected.to contain_file('mysql-config-file').without_content(/!includedir/) } end end end diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/spec/classes/mysql_bindings_spec.rb --- a/dev/provisioning/modules/mysql/spec/classes/mysql_bindings_spec.rb Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/modules/mysql/spec/classes/mysql_bindings_spec.rb Fri Apr 08 17:53:56 2016 +0200 @@ -1,30 +1,32 @@ 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 } + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) { + facts.merge({ + :root_home => '/root', + }) + } - let(:params) {{ - 'java_enable' => true, - 'perl_enable' => true, - 'php_enable' => true, - 'python_enable' => true, - 'ruby_enable' => true, - 'client_dev' => true, - 'daemon_dev' => true, - 'client_dev_package_name' => 'libmysqlclient-devel', - 'daemon_dev_package_name' => 'mysql-devel', - }} + let(:params) {{ + '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 + 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 diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/spec/classes/mysql_client_spec.rb --- a/dev/provisioning/modules/mysql/spec/classes/mysql_client_spec.rb Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/modules/mysql/spec/classes/mysql_client_spec.rb Fri Apr 08 17:53:56 2016 +0200 @@ -1,36 +1,38 @@ 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 } + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) { + facts.merge({ + :root_home => '/root', + }) + } - context 'with defaults' do - it { is_expected.not_to contain_class('mysql::bindings') } - it { is_expected.to contain_package('mysql_client') } - end + 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 }} + 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 + 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 }} + context 'with package_manage set to true' do + let(:params) {{ :package_manage => true }} - it { is_expected.to contain_package('mysql_client') } - end + it { is_expected.to contain_package('mysql_client') } + end - context 'with package_manage set to false' do - let(:params) {{ :package_manage => false }} + context 'with package_manage set to false' do + let(:params) {{ :package_manage => false }} - it { is_expected.not_to contain_package('mysql_client') } - end + it { is_expected.not_to contain_package('mysql_client') } + end - end end end end diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/spec/classes/mysql_server_account_security_spec.rb --- a/dev/provisioning/modules/mysql/spec/classes/mysql_server_account_security_spec.rb Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/modules/mysql/spec/classes/mysql_server_account_security_spec.rb Fri Apr 08 17:53:56 2016 +0200 @@ -1,10 +1,16 @@ 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'}) } + on_supported_os.each do |os, facts| + context "on #{os}" do + context "with fqdn==myhost.mydomain" do + let(:facts) { + facts.merge({ + :root_home => '/root', + :fqdn => 'myhost.mydomain', + :hostname => 'myhost', + }) + } [ 'root@myhost.mydomain', 'root@127.0.0.1', @@ -32,8 +38,14 @@ end end - describe "on #{pe_version} #{pe_platform} with fqdn==localhost" do - let(:facts) { facts.merge({:fqdn => 'localhost', :hostname => 'localhost'}) } + context "with fqdn==localhost" do + let(:facts) { + facts.merge({ + :root_home => '/root', + :fqdn => 'localhost', + :hostname => 'localhost', + }) + } [ 'root@127.0.0.1', 'root@::1', @@ -48,8 +60,14 @@ end end - describe "on #{pe_version} #{pe_platform} with fqdn==localhost.localdomain" do - let(:facts) { facts.merge({:fqdn => 'localhost.localdomain', :hostname => 'localhost'}) } + context "with fqdn==localhost.localdomain" do + let(:facts) { + facts.merge({ + :root_home => '/root', + :fqdn => 'localhost.localdomain', + :hostname => 'localhost', + }) + } [ 'root@127.0.0.1', 'root@::1', diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/spec/classes/mysql_server_backup_spec.rb --- a/dev/provisioning/modules/mysql/spec/classes/mysql_server_backup_spec.rb Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/modules/mysql/spec/classes/mysql_server_backup_spec.rb Fri Apr 08 17:53:56 2016 +0200 @@ -1,400 +1,402 @@ 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 } + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) { + facts.merge({ + :root_home => '/root', + }) + } + + 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 - 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', - } + 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' + ) } - context 'standard conditions' do - let(:params) { default_params } + 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 - # 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 'should skip backup triggers by default' do + is_expected.to contain_file('mysqlbackup.sh').with_content( + /ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --skip-triggers"/ + ) + end - it { is_expected.to contain_mysql_grant('testuser@localhost/*.*').with( - :privileges => ['SELECT', 'RELOAD', 'LOCK TABLES', 'SHOW VIEW', 'PROCESS'] - ).that_requires('Mysql_user[testuser@localhost]') } + it '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 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]') } + context 'with include_triggers set to true' do + let(:params) do + default_params.merge({ + :backupdatabases => ['mysql'], + :include_triggers => true + }) 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 + it 'should backup triggers when asked' 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.*/ + /ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --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 + context 'with include_triggers set to false' do let(:params) do - { :backupdirmode => '0750', - :backupdirowner => 'testuser', - :backupdirgroup => 'testgrp', - }.merge(default_params) + 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 { is_expected.to contain_file('mysqlbackupdir').with( - :path => '/tmp', - :ensure => 'directory', - :mode => '0750', - :owner => 'testuser', - :group => 'testgrp' - ) } + 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 - { :backupcompress => false }.merge(default_params) + default_params.merge({ :file_per_database => true, :backupcompress => false }) 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 + 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 - context 'with mysql.events backedup' do + 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 - { :ignore_events => false }.merge(default_params) + default_params.merge({ + :file_per_database => true, + :include_triggers => true + }) 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 + it 'should backup triggers when asked' do is_expected.to contain_file('mysqlbackup.sh').with_content( - /ADDITIONAL_OPTIONS="--events"/ + /ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --triggers"/ ) end end - context 'with database list specified' do + context 'with include_triggers set to false' do let(:params) do - { :backupdatabases => ['mysql'] }.merge(default_params) + default_params.merge({ + :file_per_database => true, + :include_triggers => false + }) 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 + 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 - - 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 + 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 + context 'with include_routines set to true' do + let(:params) do + default_params.merge({ + :file_per_database => true, + :include_routines => true + }) 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 + 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 file per database' do + context 'with include_routines set to false' 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.*/) + default_params.merge({ + :file_per_database => true, + :include_triggers => true + }) 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 + 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 include_triggers set to true' do - let(:params) do - default_params.merge({ - :file_per_database => true, - :include_triggers => true - }) - 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 backup triggers when asked' do - is_expected.to contain_file('mysqlbackup.sh').with_content( - /ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --triggers"/ - ) - end - 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 - context 'with include_triggers set to false' do - let(:params) do - default_params.merge({ - :file_per_database => true, - :include_triggers => false - }) - end + it 'should contain the wrapper script' do + is_expected.to contain_file('xtrabackup.sh').with_content( + /^innobackupex\s+"\$@"/ + ) + 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 + 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 - 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( + 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 the xtrabackup provider' do + context 'with postscript defined' 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+"\$@"/ - ) + default_params.merge({ + :provider => 'xtrabackup', + :postscript => [ + 'rsync -a /tmp backup01.local-lan:', + 'rsync -a /tmp backup02.local-lan:', + ] + }) 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 + 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 diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/spec/classes/mysql_server_monitor_spec.rb --- a/dev/provisioning/modules/mysql/spec/classes/mysql_server_monitor_spec.rb Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/modules/mysql/spec/classes/mysql_server_monitor_spec.rb Fri Apr 08 17:53:56 2016 +0200 @@ -1,35 +1,38 @@ 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 + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) { + facts.merge({ + :root_home => '/root', + }) + } + + 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 :default_params do + { + :mysql_monitor_username => 'monitoruser', + :mysql_monitor_password => 'monitorpass', + :mysql_monitor_hostname => 'monitorhost', + } + end - let :params do - default_params - end + let :params do + default_params + end - it { is_expected.to contain_mysql_user('monitoruser@monitorhost')} + it { is_expected.to contain_mysql_user('monitoruser@monitorhost')} - it { is_expected.to contain_mysql_grant('monitoruser@monitorhost/*.*').with( - :ensure => 'present', - :user => 'monitoruser@monitorhost', - :table => '*.*', - :privileges => ["PROCESS", "SUPER"], - :require => 'Mysql_user[monitoruser@monitorhost]' - )} - end + 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 diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/spec/classes/mysql_server_mysqltuner_spec.rb --- a/dev/provisioning/modules/mysql/spec/classes/mysql_server_mysqltuner_spec.rb Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/modules/mysql/spec/classes/mysql_server_mysqltuner_spec.rb Fri Apr 08 17:53:56 2016 +0200 @@ -1,42 +1,44 @@ 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 } + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) { + facts.merge({ + :root_home => '/root', + }) + } - 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 => 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 '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 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 + 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 diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/spec/classes/mysql_server_spec.rb --- a/dev/provisioning/modules/mysql/spec/classes/mysql_server_spec.rb Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/modules/mysql/spec/classes/mysql_server_spec.rb Fri Apr 08 17:53:56 2016 +0200 @@ -1,28 +1,71 @@ 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 } + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) { + facts.merge({ + :root_home => '/root', + }) + } + + 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 'when not managing config file' do + let(:params) {{ :manage_config_file => false }} + it { is_expected.to compile.with_all_deps } + 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_mysql_datadir('/tmp') } + end + end + + context 'mysql::server::service' do 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') } + 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 }} - 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, + it do + is_expected.to contain_service('mysqld').with({ + :ensure => :stopped }) end context 'with package_manage set to true' do @@ -35,151 +78,135 @@ end context 'with datadir overridden' do let(:params) {{ :override_options => { 'mysqld' => { 'datadir' => '/tmp' }} }} - it { is_expected.to contain_exec('mysql_install_db') } + it { is_expected.to contain_mysql_datadir('/tmp') } end end + context 'with log-error overridden' do + let(:params) {{ :override_options => { 'mysqld' => { 'log-error' => '/tmp/error.log' }} }} + it { is_expected.to contain_file('/tmp/error.log') } + 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') } + 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') } + if Puppet.version.to_f >= 3.0 + it { is_expected.to contain_file('/root/.my.cnf').with(:show_diff => false).that_requires('Mysql_user[root@localhost]') } + else + it { is_expected.to contain_file('/root/.my.cnf').that_requires('Mysql_user[root@localhost]') } 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') } + 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') } + if Puppet.version.to_f >= 3.0 + it { is_expected.to contain_file('/root/.my.cnf').with(:show_diff => false) } + else 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 + 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 - 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 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 + 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 diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/spec/defines/mysql_db_spec.rb --- a/dev/provisioning/modules/mysql/spec/defines/mysql_db_spec.rb Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/modules/mysql/spec/defines/mysql_db_spec.rb Fri Apr 08 17:53:56 2016 +0200 @@ -1,74 +1,76 @@ 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 } + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) { + facts.merge({ + :root_home => '/root', + }) + } - let(:title) { 'test_db' } - - let(:params) { - { 'user' => 'testuser', - 'password' => 'testpass', - } - } + let(:title) { 'test_db' } - 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 + let(:params) { + { 'user' => 'testuser', + 'password' => 'testpass', + } + } - 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 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 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 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 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 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 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 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 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 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 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 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 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 + 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 diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/spec/spec_helper.rb --- a/dev/provisioning/modules/mysql/spec/spec_helper.rb Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/modules/mysql/spec/spec_helper.rb Fri Apr 08 17:53:56 2016 +0200 @@ -1,7 +1,8 @@ +#This file is generated by ModuleSync, do not edit. 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(' ') +# put local configuration and setup into spec_helper_local +begin + require 'spec_helper_local' +rescue LoadError +end diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/spec/spec_helper_acceptance.rb --- a/dev/provisioning/modules/mysql/spec/spec_helper_acceptance.rb Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/modules/mysql/spec/spec_helper_acceptance.rb Fri Apr 08 17:53:56 2016 +0200 @@ -12,6 +12,12 @@ # Readable test descriptions c.formatter = :documentation + # detect the situation where PUP-5016 is triggered and skip the idempotency tests in that case + # also note how fact('puppetversion') is not available because of PUP-4359 + if fact('osfamily') == 'Debian' && fact('operatingsystemmajrelease') == '8' && shell('puppet --version').stdout =~ /^4\.2/ + c.filter_run_excluding :skip_pup_5016 => true + end + # Configure all nodes in nodeset c.before :suite do # Install module and dependencies @@ -47,3 +53,13 @@ end end end + +shared_examples "a idempotent resource" do + it 'should apply with no errors' do + apply_manifest(pp, :catch_failures => true) + end + + it 'should apply a second time without changes', :skip_pup_5016 do + apply_manifest(pp, :catch_changes => true) + end +end diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/spec/spec_helper_local.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/mysql/spec/spec_helper_local.rb Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,3 @@ +require 'rspec-puppet-facts' +include RspecPuppetFacts + diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/spec/unit/facter/mysql_server_id_spec.rb --- a/dev/provisioning/modules/mysql/spec/unit/facter/mysql_server_id_spec.rb Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/modules/mysql/spec/unit/facter/mysql_server_id_spec.rb Fri Apr 08 17:53:56 2016 +0200 @@ -11,7 +11,7 @@ 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' + Facter.fact(:mysql_server_id).value.to_s.should == '66961985441' end end diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/spec/unit/puppet/functions/mysql_password_spec.rb --- a/dev/provisioning/modules/mysql/spec/unit/puppet/functions/mysql_password_spec.rb Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/modules/mysql/spec/unit/puppet/functions/mysql_password_spec.rb Fri Apr 08 17:53:56 2016 +0200 @@ -29,4 +29,9 @@ expect(result).to(eq('')) end + it 'should not convert a password that is already a hash' do + result = scope.function_mysql_password(['*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19']) + expect(result).to(eq('*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19')) + end + end diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/spec/unit/puppet/functions/mysql_table_exists_spec.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/mysql/spec/unit/puppet/functions/mysql_table_exists_spec.rb Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,26 @@ +require 'spec_helper' + +describe 'the mysql_table_exists 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_table_exists')).to eq('function_mysql_table_exists') + end + + it 'should raise a ParseError if there is less than 1 arguments' do + expect { scope.function_mysql_table_exists([]) }.to( raise_error(Puppet::ParseError)) + end + + it 'should raise a ParserError if argument doesn\'t look like database_name.table_name' do + expect { scope.function_mysql_table_exists(['foo_bar']) }.to( raise_error(Puppet::ParseError)) + end + + it 'should raise a ParseError if there is more than 1 arguments' do + expect { scope.function_mysql_table_exists(%w(foo.bar foo.bar)) }.to( raise_error(Puppet::ParseError)) + end + +end \ No newline at end of file diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/spec/unit/puppet/provider/mysql_user/mysql_spec.rb --- a/dev/provisioning/modules/mysql/spec/unit/puppet/provider/mysql_user/mysql_spec.rb Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/modules/mysql/spec/unit/puppet/provider/mysql_user/mysql_spec.rb Fri Apr 08 17:53:56 2016 +0200 @@ -1,6 +1,47 @@ require 'spec_helper' describe Puppet::Type.type(:mysql_user).provider(:mysql) do + + # Output of mysqld -V + mysql_version_string_hash = { + 'mysql-5.5' => + { + :version => '5.5.46', + :string => '/usr/sbin/mysqld Ver 5.5.46-log for Linux on x86_64 (MySQL Community Server (GPL))', + :mysql_type => 'mysql', + }, + 'mysql-5.6' => + { + :version => '5.6.27', + :string => '/usr/sbin/mysqld Ver 5.6.27 for Linux on x86_64 (MySQL Community Server (GPL))', + :mysql_type => 'mysql', + }, + 'mysql-5.7.1' => + { + :version => '5.7.1', + :string => '/usr/sbin/mysqld Ver 5.7.1 for Linux on x86_64 (MySQL Community Server (GPL))', + :mysql_type => 'mysql', + }, + 'mysql-5.7.6' => + { + :version => '5.7.8', + :string => '/usr/sbin/mysqld Ver 5.7.8-rc for Linux on x86_64 (MySQL Community Server (GPL))', + :mysql_type => 'mysql', + }, + 'mariadb-10.0' => + { + :version => '10.0.21', + :string => '/usr/sbin/mysqld Ver 10.0.21-MariaDB for Linux on x86_64 (MariaDB Server)', + :mysql_type => 'mariadb', + }, + 'percona-5.5' => + { + :version => '5.5.39', + :string => 'mysqld Ver 5.5.39-36.0-55 for Linux on x86_64 (Percona XtraDB Cluster (GPL), Release rel36.0, Revision 824, WSREP version 25.11, wsrep_25.11.r4023)', + :mysql_type => 'percona', + }, + } + let(:defaults_file) { '--defaults-extra-file=/root/.my.cnf' } let(:newhash) { '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5' } @@ -35,7 +76,9 @@ # 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') + provider.class.instance_variable_set(:@mysqld_version_string, '5.6.24') Puppet::Util.stubs(:which).with('mysql').returns('/usr/bin/mysql') + Puppet::Util.stubs(:which).with('mysqld').returns('/usr/sbin/mysqld') File.stubs(:file?).with('/root/.my.cnf').returns(true) provider.class.stubs(:mysql).with([defaults_file, '-NBe', "SELECT CONCAT(User, '@',Host) AS User FROM mysql.user"]).returns('joe@localhost') provider.class.stubs(:mysql).with([defaults_file, '-NBe', "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, PASSWORD /*!50508 , PLUGIN */ FROM mysql.user WHERE CONCAT(user, '@', host) = 'joe@localhost'"]).returns('10 10 10 10 *6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4') @@ -44,7 +87,28 @@ let(:instance) { provider.class.instances.first } describe 'self.instances' do - it 'returns an array of users' do + it 'returns an array of users MySQL 5.5' do + provider.class.instance_variable_set(:@mysqld_version_string, mysql_version_string_hash['mysql-5.5'][:string]) + provider.class.stubs(:mysql).with([defaults_file, '-NBe', "SELECT CONCAT(User, '@',Host) AS User FROM mysql.user"]).returns(raw_users) + parsed_users.each do |user| + provider.class.stubs(:mysql).with([defaults_file, '-NBe', "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, 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 + it 'returns an array of users MySQL 5.6' do + provider.class.instance_variable_set(:@mysqld_version_string, mysql_version_string_hash['mysql-5.6'][:string]) + provider.class.stubs(:mysql).with([defaults_file, '-NBe', "SELECT CONCAT(User, '@',Host) AS User FROM mysql.user"]).returns(raw_users) + parsed_users.each do |user| + provider.class.stubs(:mysql).with([defaults_file, '-NBe', "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, 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 + it 'returns an array of users MySQL >= 5.7.0 < 5.7.6' do + provider.class.instance_variable_set(:@mysqld_version_string, mysql_version_string_hash['mysql-5.7.1'][:string]) provider.class.stubs(:mysql).with([defaults_file, '-NBe', "SELECT CONCAT(User, '@',Host) AS User FROM mysql.user"]).returns(raw_users) parsed_users.each do |user| provider.class.stubs(:mysql).with([defaults_file, '-NBe', "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, PASSWORD /*!50508 , PLUGIN */ FROM mysql.user WHERE CONCAT(user, '@', host) = '#{user}'"]).returns('10 10 10 10 ') @@ -53,6 +117,49 @@ usernames = provider.class.instances.collect {|x| x.name } expect(parsed_users).to match_array(usernames) end + it 'returns an array of users MySQL >= 5.7.6' do + provider.class.instance_variable_set(:@mysqld_version_string, mysql_version_string_hash['mysql-5.7.6'][:string]) + provider.class.stubs(:mysql).with([defaults_file, '-NBe', "SELECT CONCAT(User, '@',Host) AS User FROM mysql.user"]).returns(raw_users) + parsed_users.each do |user| + provider.class.stubs(:mysql).with([defaults_file, '-NBe', "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, AUTHENTICATION_STRING, 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 + it 'returns an array of users mariadb 10.0' do + provider.class.instance_variable_set(:@mysqld_version_string, mysql_version_string_hash['mariadb-10.0'][:string]) + provider.class.stubs(:mysql).with([defaults_file, '-NBe', "SELECT CONCAT(User, '@',Host) AS User FROM mysql.user"]).returns(raw_users) + parsed_users.each do |user| + provider.class.stubs(:mysql).with([defaults_file, '-NBe', "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, 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 + it 'returns an array of users percona 5.5' do + provider.class.instance_variable_set(:@mysqld_version_string, mysql_version_string_hash['percona-5.5'][:string]) + provider.class.stubs(:mysql).with([defaults_file, '-NBe', "SELECT CONCAT(User, '@',Host) AS User FROM mysql.user"]).returns(raw_users) + parsed_users.each do |user| + provider.class.stubs(:mysql).with([defaults_file, '-NBe', "SELECT MAX_USER_CONNECTIONS, MAX_CONNECTIONS, MAX_QUESTIONS, MAX_UPDATES, 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 'mysql version and type detection' do + mysql_version_string_hash.each do |name,line| + version=line[:version] + string=line[:string] + mysql_type=line[:mysql_type] + it "detects type '#{mysql_type}' with version '#{version}'" do + provider.class.instance_variable_set(:@mysqld_version_string, string) + expect(provider.mysqld_version).to eq(version) + expect(provider.mysqld_type).to eq(mysql_type) + end + end end describe 'self.prefetch' do @@ -85,6 +192,30 @@ end end + describe 'self.mysqld_version' do + it 'queries mysql if unset' do + provider.class.instance_variable_set(:@mysqld_version_string, nil) + provider.class.expects(:mysqld).with(['-V']) + expect(provider.mysqld_version).to be_nil + end + it 'returns 5.7.6 for "mysqld Ver 5.7.6 for Linux on x86_64 (MySQL Community Server (GPL))"' do + provider.class.instance_variable_set(:@mysqld_version_string, 'mysqld Ver 5.7.6 for Linux on x86_64 (MySQL Community Server (GPL))') + expect(provider.mysqld_version).to eq '5.7.6' + end + it 'returns 5.7.6 for "mysqld Ver 5.7.6-rc for Linux on x86_64 (MySQL Community Server (GPL))"' do + provider.class.instance_variable_set(:@mysqld_version_string, 'mysqld Ver 5.7.6-rc for Linux on x86_64 (MySQL Community Server (GPL))') + expect(provider.mysqld_version).to eq '5.7.6' + end + it 'detects >= 5.7.6 for 5.7.7-log' do + provider.class.instance_variable_set(:@mysqld_version_string, 'mysqld Ver 5.7.7-log for Linux on x86_64 (MySQL Community Server (GPL))') + expect(Puppet::Util::Package.versioncmp(provider.mysqld_version, '5.7.6')).to be >= 0 + end + it 'detects < 5.7.6 for 5.7.5-log' do + provider.class.instance_variable_set(:@mysqld_version_string, 'mysqld Ver 5.7.5-log for Linux on x86_64 (MySQL Community Server (GPL))') + expect(Puppet::Util::Package.versioncmp(provider.mysqld_version, '5.7.6')).to be < 0 + end + end + describe 'self.defaults_file' do it 'sets --defaults-extra-file' do File.stubs(:file?).with('/root/.my.cnf').returns(true) @@ -103,7 +234,43 @@ end describe 'password_hash=' do - it 'changes the hash' do + it 'changes the hash mysql 5.5' do + provider.class.instance_variable_set(:@mysqld_version_string, mysql_version_string_hash['mysql-5.5'][:string]) + provider.expects(:mysql).with([defaults_file, '-e', "SET PASSWORD FOR 'joe'@'localhost' = '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5'"]).returns('0') + + provider.expects(:password_hash).returns('*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5') + provider.password_hash=('*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5') + end + it 'changes the hash mysql 5.6' do + provider.class.instance_variable_set(:@mysqld_version_string, mysql_version_string_hash['mysql-5.6'][:string]) + provider.expects(:mysql).with([defaults_file, '-e', "SET PASSWORD FOR 'joe'@'localhost' = '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5'"]).returns('0') + + provider.expects(:password_hash).returns('*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5') + provider.password_hash=('*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5') + end + it 'changes the hash mysql < 5.7.6' do + provider.class.instance_variable_set(:@mysqld_version_string, mysql_version_string_hash['mysql-5.7.1'][:string]) + provider.expects(:mysql).with([defaults_file, '-e', "SET PASSWORD FOR 'joe'@'localhost' = '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5'"]).returns('0') + + provider.expects(:password_hash).returns('*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5') + provider.password_hash=('*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5') + end + it 'changes the hash MySQL >= 5.7.6' do + provider.class.instance_variable_set(:@mysqld_version_string, mysql_version_string_hash['mysql-5.7.6'][:string]) + provider.expects(:mysql).with([defaults_file, '-e', "ALTER USER 'joe'@'localhost' IDENTIFIED WITH mysql_native_password AS '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5'"]).returns('0') + + provider.expects(:password_hash).returns('*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5') + provider.password_hash=('*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5') + end + it 'changes the hash mariadb-10.0' do + provider.class.instance_variable_set(:@mysqld_version_string, mysql_version_string_hash['mariadb-10.0'][:string]) + provider.expects(:mysql).with([defaults_file, '-e', "SET PASSWORD FOR 'joe'@'localhost' = '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5'"]).returns('0') + + provider.expects(:password_hash).returns('*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5') + provider.password_hash=('*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5') + end + it 'changes the hash percona-5.5' do + provider.class.instance_variable_set(:@mysqld_version_string, mysql_version_string_hash['percona-5.5'][:string]) provider.expects(:mysql).with([defaults_file, '-e', "SET PASSWORD FOR 'joe'@'localhost' = '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5'"]).returns('0') provider.expects(:password_hash).returns('*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF5') diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/templates/my.cnf.erb --- a/dev/provisioning/modules/mysql/templates/my.cnf.erb Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/modules/mysql/templates/my.cnf.erb Fri Apr 08 17:53:56 2016 +0200 @@ -6,7 +6,7 @@ <% v.sort.map do |ki, vi| -%> <% if ki == 'ssl-disable' or (ki =~ /^ssl/ and v['ssl-disable'] == true) -%> <% next %> -<% elsif vi == true or v == '' -%> +<% elsif vi == true or vi == '' -%> <%= ki %> <% elsif vi.is_a?(Array) -%> <% vi.each do |vii| -%> diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/templates/my.cnf.pass.erb --- a/dev/provisioning/modules/mysql/templates/my.cnf.pass.erb Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/modules/mysql/templates/my.cnf.pass.erb Fri Apr 08 17:53:56 2016 +0200 @@ -1,9 +1,11 @@ ### MANAGED BY PUPPET ### -[client] +<% %w(mysql client mysqldump mysqladmin mysqlcheck).each do |section| %> +[<%= section -%>] user=root host=localhost <% unless scope.lookupvar('mysql::server::root_password') == 'UNSET' -%> password='<%= scope.lookupvar('mysql::server::root_password') %>' <% end -%> -socket=<%= @options['client']['socket'] -%> +socket=<%= @options['client']['socket'] %> +<% end %> diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/mysql/templates/mysqlbackup.sh.erb --- a/dev/provisioning/modules/mysql/templates/mysqlbackup.sh.erb Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/modules/mysql/templates/mysqlbackup.sh.erb Fri Apr 08 17:53:56 2016 +0200 @@ -19,6 +19,10 @@ DIR=<%= @backupdir %> ROTATE=<%= [ Integer(@backuprotate) - 1, 0 ].max %> +# Create temporary mysql cnf file. +TMPFILE=`mktemp /tmp/backup.XXXXXX` || exit 1 +echo -e "[client]\npassword=$PASS\nuser=$USER" > $TMPFILE + PREFIX=mysql_backup_ <% if @ignore_events %> ADDITIONAL_OPTIONS="--ignore-table=mysql.event" @@ -61,20 +65,20 @@ <% end -%> <% if @backupdatabases.empty? -%> <% if @file_per_database -%> -mysql -u${USER} -p${PASS} -s -r -N -e 'SHOW DATABASES' | while read dbname +mysql --defaults-file=$TMPFILE -s -r -N -e 'SHOW DATABASES' | while read dbname do - mysqldump -u${USER} -p${PASS} --opt --flush-logs --single-transaction \ + mysqldump --defaults-file=$TMPFILE --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 \ +mysqldump --defaults-file=$TMPFILE --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 \ +mysqldump --defaults-file=$TMPFILE --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 -%> @@ -91,3 +95,6 @@ <%= script %> <%- end -%> <% end -%> + +# Remove temporary file +rm -f $TMPFILE diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/sysconfig/files/corpus/handle.service --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/sysconfig/files/corpus/handle.service Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,12 @@ +[Unit] +Description=Starts and stops a handle server +Documentation=http://handle.net + +[Service] +Type=simple +EnvironmentFile=/etc/sysconfig/handle +User=handle +Group=handle +# PIDFile=/var/run/handle/handle.pid +ExecStart=echo "${HANDLE_KEY_PSWD}" | /opt/handle/bin/hdl-server /var/lib/handle +ExecStop=rm -f /var/lib/handle/delete_this_to_stop_server diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/sysconfig/files/handle/handle.service --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/sysconfig/files/handle/handle.service Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,15 @@ +[Unit] +Description=Handle server +Documentation=http://handle.net + +[Service] +Type=simple +EnvironmentFile=/etc/sysconfig/handle +User=handle +Group=handle +# PIDFile=/var/run/handle/handle.pid +ExecStart=/opt/handle/sbin/start_handle "${HANDLE_KEY_PSWD}" +ExecStop=/usr/bin/rm -f /var/lib/handle/delete_this_to_stop_server + +[Install] +WantedBy=multi-user.target diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/sysconfig/files/handle/handle_data.sql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/sysconfig/files/handle/handle_data.sql Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,45 @@ +-- MySQL dump 10.16 Distrib 10.1.13-MariaDB, for osx10.11 (x86_64) +-- +-- Host: 172.16.1.6 Database: handle +-- ------------------------------------------------------ +-- Server version 5.5.44-MariaDB + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Dumping data for table `handles` +-- + +LOCK TABLES `handles` WRITE; +/*!40000 ALTER TABLE `handles` DISABLE KEYS */; +INSERT INTO `handles` VALUES ('12345/ADMIN',300,'HS_SECKEY','admin',0,86400,1459508158,'',1,1,0,0); +/*!40000 ALTER TABLE `handles` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `nas` +-- + +LOCK TABLES `nas` WRITE; +/*!40000 ALTER TABLE `nas` DISABLE KEYS */; +INSERT INTO `nas` VALUES ('0.NA/12345'); +/*!40000 ALTER TABLE `nas` ENABLE KEYS */; +UNLOCK TABLES; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2016-04-02 2:15:04 diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/sysconfig/files/handle/handle_data_2.sql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/sysconfig/files/handle/handle_data_2.sql Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,45 @@ +-- MySQL dump 10.16 Distrib 10.1.13-MariaDB, for osx10.11 (x86_64) +-- +-- Host: 172.16.1.6 Database: handle +-- ------------------------------------------------------ +-- Server version 5.5.44-MariaDB + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Dumping data for table `handles` +-- + +LOCK TABLES `handles` WRITE; +/*!40000 ALTER TABLE `handles` DISABLE KEYS */; +INSERT INTO `handles` VALUES ('12345/ADMIN',200,0x48535F564C495354,0x3330303A31302E35302F555352313B203330303A31302E35302F555352323B,0,86400,1460065541,'',1,1,1,0),('12345/ADMIN',300,0x48535F5055424B4559,0x0000000B5253415F5055425F4B455900000000000301000100000101009B894C2F4E7E0F7FB8F6897DFFCEBD31A94C0D70EBF23A05D25559782148F67066E28F9B1D16338C1A38ACEF6A315BC08AEB3768941F5CA8E358C5A89CD6EBFCF14BC7AAA04CF3D897FF942CEED365891E486A3D65CDBE1F72208DABD8A86C8D17FC4CA5F4309FD4AE2C861A8A5F74941362DDCE71D85BF6E967BB16D6B102A5AB49AD33559B383126CF98332A688718722D84680569948FC8EEEC520C5F02067F14FD67889113CB72275179B40DA8557E61BEC05EFDBFE2801B6212DB6262F370A17F48CA6CA5A0C8F369BB4478B30EA9C9E1FC0A735AA2A4720DFC2D97025A882BDD6C538508DFC18EE4F5767F9C103C33D0795DADB673F290942F198E3EF500000000,0,86400,1460065541,'',1,1,1,0),('12345/ADMIN',301,0x48535F5345434B4559,0x61646D696E,0,86400,1460065541,'',1,1,0,0); +/*!40000 ALTER TABLE `handles` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `nas` +-- + +LOCK TABLES `nas` WRITE; +/*!40000 ALTER TABLE `nas` DISABLE KEYS */; +INSERT INTO `nas` VALUES ('0.NA/12345'); +/*!40000 ALTER TABLE `nas` ENABLE KEYS */; +UNLOCK TABLES; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2016-04-08 9:37:17 diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/sysconfig/files/handle/handle_data_3.sql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/sysconfig/files/handle/handle_data_3.sql Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,47 @@ +-- MySQL dump 10.16 Distrib 10.1.13-MariaDB, for osx10.11 (x86_64) +-- +-- Host: 172.16.1.6 Database: handle +-- ------------------------------------------------------ +-- Server version 5.5.44-MariaDB + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Dumping data for table `handles` +-- + +LOCK TABLES `handles` WRITE; +/*!40000 ALTER TABLE `handles` DISABLE KEYS */; +INSERT INTO `handles` VALUES ('12345/ADMIN',200,'HS_VLIST','300:10.50/USR1; 300:10.50/USR2;',0,86400,1460065541,'',1,1,1,0); +INSERT INTO `handles` VALUES ('12345/ADMIN',300,'HS_PUBKEY','\0\0\0 RSA_PUB_KEY\0\0\0\0\0\0\0\0\0L/N~}ν1L\rp:UYx!Hpf⏛3\Z8j1[7h\\XŨKǪLؗ,eHj=e;r بlL0Ԯ,\Z_tbq[gֱI3U81&Ϙ3*hr-hiR _gr\'Qy\rU~a^bbbpHliDx\nsZr\r-Z+lSv<3y]s/>\0\0\0\0',0,86400,1460065541,'',1,1,1,0); +INSERT INTO `handles` VALUES ('12345/ADMIN',301,'HS_SECKEY','admin',0,86400,1460065541,'',1,1,0,0); +/*!40000 ALTER TABLE `handles` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `nas` +-- + +LOCK TABLES `nas` WRITE; +/*!40000 ALTER TABLE `nas` DISABLE KEYS */; +INSERT INTO `nas` VALUES ('0.NA/12345'); +/*!40000 ALTER TABLE `nas` ENABLE KEYS */; +UNLOCK TABLES; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2016-04-08 9:43:09 diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/sysconfig/files/handle/handle_data_4.sql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/sysconfig/files/handle/handle_data_4.sql Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,47 @@ +-- MySQL dump 10.16 Distrib 10.1.13-MariaDB, for osx10.11 (x86_64) +-- +-- Host: 172.16.1.6 Database: handle +-- ------------------------------------------------------ +-- Server version 5.5.44-MariaDB + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Dumping data for table `handles` +-- + +LOCK TABLES `handles` WRITE; +/*!40000 ALTER TABLE `handles` DISABLE KEYS */; +INSERT INTO `handles` VALUES ('12345/ADMIN',200,0x48535F564C495354,0x3330303A31302E35302F555352313B203330303A31302E35302F555352323B,0,86400,1460065541,'',1,1,1,0); +INSERT INTO `handles` VALUES ('12345/ADMIN',300,0x48535F5055424B4559,0x0000000B5253415F5055425F4B455900000000000301000100000101009B894C2F4E7E0F7FB8F6897DFFCEBD31A94C0D70EBF23A05D25559782148F67066E28F9B1D16338C1A38ACEF6A315BC08AEB3768941F5CA8E358C5A89CD6EBFCF14BC7AAA04CF3D897FF942CEED365891E486A3D65CDBE1F72208DABD8A86C8D17FC4CA5F4309FD4AE2C861A8A5F74941362DDCE71D85BF6E967BB16D6B102A5AB49AD33559B383126CF98332A688718722D84680569948FC8EEEC520C5F02067F14FD67889113CB72275179B40DA8557E61BEC05EFDBFE2801B6212DB6262F370A17F48CA6CA5A0C8F369BB4478B30EA9C9E1FC0A735AA2A4720DFC2D97025A882BDD6C538508DFC18EE4F5767F9C103C33D0795DADB673F290942F198E3EF500000000,0,86400,1460065541,'',1,1,1,0); +INSERT INTO `handles` VALUES ('12345/ADMIN',301,0x48535F5345434B4559,0x61646D696E,0,86400,1460065541,'',1,1,0,0); +/*!40000 ALTER TABLE `handles` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `nas` +-- + +LOCK TABLES `nas` WRITE; +/*!40000 ALTER TABLE `nas` DISABLE KEYS */; +INSERT INTO `nas` VALUES ('0.NA/12345'); +/*!40000 ALTER TABLE `nas` ENABLE KEYS */; +UNLOCK TABLES; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2016-04-08 9:44:14 diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/sysconfig/files/handle/handle_db.sql --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/sysconfig/files/handle/handle_db.sql Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,21 @@ + +CREATE TABLE nas ( + na varchar(255) not null, + PRIMARY KEY(na) +); + +CREATE TABLE handles ( + handle varchar(255) not null, + idx int4 not null, + type blob, + data blob, + ttl_type int2, + ttl int4, + timestamp int4, + refs blob, + admin_read bool, + admin_write bool, + pub_read bool, + pub_write bool, + PRIMARY KEY(handle, idx) +); diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/sysconfig/files/handle/mysql-connector-java-5.1.38-bin.jar Binary file dev/provisioning/modules/sysconfig/files/handle/mysql-connector-java-5.1.38-bin.jar has changed diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/sysconfig/files/handle/start_handle --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/sysconfig/files/handle/start_handle Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +/opt/handle/bin/hdl-server /var/lib/handle <<<"$1" diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/sysconfig/manifests/handle.pp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/sysconfig/manifests/handle.pp Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,232 @@ +class sysconfig::handle ( + $hdl_host = hiera('sysconfig::params::hdl_host', $sysconfig::params::hdl_host), + $hdl_user = hiera('sysconfig::params::hdl_user', $sysconfig::params::hdl_user), + $hdl_srv_port = hiera('sysconfig::params::hdl_srv_port', $sysconfig::params::hdl_srv_port), + $hdl_web_port = hiera('sysconfig::params::hdl_web_port', $sysconfig::params::hdl_web_port), + $hdl_key_pswd = hiera('sysconfig::params::hdl_key_pswd', $sysconfig::params::hdl_key_pswd), + $hdl_prefix = hiera('sysconfig::params::hdl_prefix', $sysconfig::params::hdl_prefix), + $hdl_db_name = hiera('sysconfig::params::hdl_db_name', $sysconfig::params::hdl_db_name), + $db_user = hiera('sysconfig::params::db_user', $sysconfig::params::db_user), + $db_pw = hiera('sysconfig::params::db_pw', $sysconfig::params::db_pw), + $db_host = hiera('sysconfig::params::db_host', $sysconfig::params::db_host) +) inherits sysconfig::params { + + # iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 1080 + + notify {'handle': name => "\$hdl_host : ${hdl_host}, \$hdl_srv_port : ${hdl_srv_port}, \$hdl_web_port : ${hdl_web_port}", withpath => true } + + $handle_dirs = [ + "/opt/handle", + "/opt/handle/sbin", + "/tmp/handle" + ] + + group { "$hdl_user": + ensure => present, + }-> + user { "handle user": + name => $hdl_user, + ensure => present, + gid => $hdl_user, + system => true, + home => '/var/lib/handle', + managehome => false, + shell => '/sbin/nologin' + }-> + file { "/var/lib/handle": + ensure => directory, + owner => "$hdl_user", + group => "$hdl_user" + }-> + file { $handle_dirs: + ensure => directory, + }-> + archive { 'handle-8.1': + ensure => present, + url => "http://www.handle.net/hnr-source/hsj-8.1.0.tar.gz", + checksum => false, + follow_redirects => true, + strip_components => 1, + target => "/opt/handle", + src_target => '/tmp', + timeout => 500, + }-> + file { "/opt/handle/sbin/start_handle": + owner => "$hdl_user", + group => "$hdl_user", + mode => "0750", + source => "puppet:///modules/sysconfig/handle/start_handle", + }-> + file { '/opt/handle/lib/mysql-connector-java-5.1.38-bin.jar': + ensure => file, + source => "puppet:///modules/sysconfig/handle/mysql-connector-java-5.1.38-bin.jar", + mode => "0644" + }-> + file { '/tmp/handle/handle_db.sql': + ensure => file, + source => "puppet:///modules/sysconfig/handle/handle_db.sql", + owner => "$hdl_user", + group => "$hdl_user", + mode => "0750" + }-> + mysql::db { "handle_db": + dbname => $hdl_db_name, + user => $db_user, + password => $db_pw, + host => $db_host, + sql => '/tmp/handle/handle_db.sql', + charset => 'utf8', + collate => 'utf8_general_ci', + notify => Exec['rm-tmp-handle-db'], + require => Service["mariadb"], + }-> + file { "/tmp/handle/handle_init_script.exp": + ensure => file, + content => template("sysconfig/handle/handle_script.exp.erb"), + owner => "$hdl_user", + group => "$hdl_user", + mode => "0750" + }-> + exec { "init-handle": + command => "/tmp/handle/handle_init_script.exp", + cwd => "/opt/handle/bin", + provider => 'shell', + creates => "/var/lib/handle/sitebndl.zip", + user => $hdl_user, + notify => Exec['rm-tmp-handle'], + require => [Package['java-install'], Package['expect']] + }-> + file { "/var/lib/handle/config.dct": + ensure => file, + owner => "$hdl_user", + group => "$hdl_user", + content => template("sysconfig/handle/handle_config.dct.erb"), + replace => true + }-> + exec { "handle-first-start": + command => "/usr/bin/echo \"${HANDLE_KEY_PSWD}\" | /opt/handle/bin/hdl-server /var/lib/handle &", + provider => 'shell', + creates => "/var/lib/handle/.handle_initialized", + user => $hdl_user, + require => File['/etc/sysconfig/handle'] + }-> + exec { "handle-first-stop": + command => "/usr/bin/sleep 10 && rm -f /var/lib/handle/delete_this_to_stop_server && touch /var/lib/handle/.handle_initialized", + provider => 'shell', + creates => "/var/lib/handle/.handle_initialized", + user => $hdl_user, + require => File['/etc/sysconfig/handle'] + }-> + file_line { "handle-detached-prefix": + path => "/var/lib/handle/config.dct", + match => "\s*\"300:0.NA/$hdl_prefix\"", + line => " \"300:$hdl_prefix/ADMIN\"", + multiple => true, + } + + # file { "/tmp/handle/handle_answers.txt": + # ensure => file, + # content => template("sysconfig/handle/handle_answers.tmp.erb"), + # }#-> + # exec { "init-handle": + # command => "/opt/handle/bin/hdl-setup-server /var/lib/handle < /tmp/handle/handle_answers.txt", + # cwd => "/opt/handle/bin", + # provider => 'shell', + # creates => "/var/lib/handle/sitebndl.zip", + # user => $hdl_user, + # notify => Exec['rm-tmp-handle'], + # require => Package['java-install'] + # }-> + # file { "/var/lib/handle/config.dct": + # ensure => file, + # owner => "$hdl_user", + # group => "$hdl_user", + # content => template("sysconfig/handle/handle_config.dct.erb"), + # replace => true + # }-> + # exec { "open-handle-web-port": + # command => "firewall-cmd --permanent --add-port=8000/tcp", + # path => [ '/bin', '/usr/bin', '/usr/local/bin' ] + # }-> + # exec { "open-handle-srv-port": + # command => "firewall-cmd --permanent --add-port=2641/tcp", + # path => [ '/bin', '/usr/bin', '/usr/local/bin' ] + # }-> + # exec { "open-handle-port-reload": + # command => "firewall-cmd --reload", + # path => [ '/bin', '/usr/bin', '/usr/local/bin' ] + # }-> + # exec { "handle-first-start": + # command => "/usr/bin/echo \"${HANDLE_KEY_PSWD}\" | /opt/handle/bin/hdl-server /var/lib/handle &", + # provider => 'shell', + # creates => "/var/lib/handle/.handle_initialized", + # user => $hdl_user, + # require => File['/etc/sysconfig/handle'] + # }-> + # exec { "handle-first-stop": + # command => "/usr/bin/sleep 10 && rm -f /var/lib/handle/delete_this_to_stop_server && touch /var/lib/handle/.handle_initialized", + # provider => 'shell', + # creates => "/var/lib/handle/.handle_initialized", + # user => $hdl_user, + # require => File['/etc/sysconfig/handle'] + # }#-> + # file_line { "handle-detached-prefix": + # path => "/var/lib/handle/config.dct", + # match => "\s*\"300:0.NA/$hdl_prefix\"", + # line => " \"300:$hdl_prefix/ADMIN\"", + # multiple => true, + # } + + + file { "/etc/sysconfig/handle": + ensure => file, + owner => "root", + group => "$hdl_user", + content => template("sysconfig/handle/handle_sysconfig.erb"), + replace => true, + mode => "0640" + }-> + file { "/etc/systemd/system/handle.service": + ensure => file, + owner => "root", + group => "root", + source => "puppet:///modules/sysconfig/handle/handle.service", + require => File['/opt/handle/sbin/start_handle'], + notify => Exec['systemctl-daemon-reload'] + } + + exec { "handle-enable-on-boot": + command => "/usr/bin/systemctl enable handle", + subscribe => [ Exec['systemctl-daemon-reload'], File['/etc/systemd/system/handle.service'] ], + unless => "/usr/bin/systemctl is-enabled handle.service" + } + + # exec { "rm-tmp-handle": + # command => "/usr/bin/rm /tmp/handle/handle_answers.txt", + # refreshonly => true + # } + + exec { "rm-tmp-handle": + command => "/usr/bin/rm /tmp/handle/handle_init_script.exp", + refreshonly => true + } + + exec { "rm-tmp-handle-db": + command => "/usr/bin/rm /tmp/handle/handle_db.sql", + refreshonly => true + } + + exec { "open-handle-web-port": + command => "firewall-cmd --permanent --add-port=8000/tcp", + path => [ '/bin', '/usr/bin', '/usr/local/bin' ] + }-> + exec { "open-handle-srv-port": + command => "firewall-cmd --permanent --add-port=2641/tcp", + path => [ '/bin', '/usr/bin', '/usr/local/bin' ] + }-> + exec { "open-handle-port-reload": + command => "firewall-cmd --reload", + path => [ '/bin', '/usr/bin', '/usr/local/bin' ] + } + +} diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/sysconfig/manifests/init.pp --- a/dev/provisioning/modules/sysconfig/manifests/init.pp Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/modules/sysconfig/manifests/init.pp Fri Apr 08 17:53:56 2016 +0200 @@ -1,3 +1,4 @@ class sysconfig { - include augeas + include ::augeas + include ::systemd } diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/sysconfig/manifests/mariadb.pp --- a/dev/provisioning/modules/sysconfig/manifests/mariadb.pp Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/modules/sysconfig/manifests/mariadb.pp Fri Apr 08 17:53:56 2016 +0200 @@ -5,6 +5,7 @@ $db_pw = hiera('sysconfig::params::db_pw', $sysconfig::params::db_pw), $db_host = hiera('sysconfig::params::db_host', $sysconfig::params::db_host), $db_port = hiera('sysconfig::params::db_port', $sysconfig::params::db_port), + $hdl_db_name = hiera('sysconfig::params::hdl_db_name', $sysconfig::params::hdl_db_name), ) inherits sysconfig::params { $mariadb_packages = [ @@ -80,6 +81,7 @@ require => Service["mariadb"], } + #TODO: create user #TODO: create databases diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/sysconfig/manifests/memcached.pp --- a/dev/provisioning/modules/sysconfig/manifests/memcached.pp Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/modules/sysconfig/manifests/memcached.pp Fri Apr 08 17:53:56 2016 +0200 @@ -19,10 +19,8 @@ file { "/etc/systemd/system/memcached.service.d/memcached_socket_dir.conf": mode => 755, source => "puppet:///modules/sysconfig/memcached_socket_dir.conf", - require => Package['memcached'] - }-> - exec { 'systemctl-daemon-reload': - command => '/usr/bin/systemctl daemon-reload', + require => Package['memcached'], + notify => Exec['systemctl-daemon-reload'] }-> augeas { 'etc-sysconfig/memcached': context => "/files/etc/sysconfig/memcached", diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/sysconfig/manifests/packages.pp --- a/dev/provisioning/modules/sysconfig/manifests/packages.pp Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/modules/sysconfig/manifests/packages.pp Fri Apr 08 17:53:56 2016 +0200 @@ -3,10 +3,14 @@ $package_list = [ 'scl-utils', 'libmcrypt', - 'java-1.8.0-openjdk-headless', + 'expect' ] package { $package_list: ensure => present, } + package { 'java-install': + name => 'java-1.8.0-openjdk-headless', + ensure => present, + } } diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/sysconfig/manifests/params.pp --- a/dev/provisioning/modules/sysconfig/manifests/params.pp Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/modules/sysconfig/manifests/params.pp Fri Apr 08 17:53:56 2016 +0200 @@ -11,6 +11,14 @@ $es_port = hiera('sysconfig::params::es_port', '9200') $es_instance = hiera('sysconfig::params::es_instance', 'es_01') + $hdl_host = hiera('sysconfig::params::hdl_host', $::ipaddress) + $hdl_user = hiera('sysconfig::params::hdl_user', 'handle') + $hdl_srv_port = hiera('sysconfig::params::hdl_srv_port', '2641') + $hdl_web_port = hiera('sysconfig::params::hdl_web_port', '8000') + $hdl_key_pswd = hiera('sysconfig::params::hdl_key_pswd', 'corpus') + $hdl_prefix = hiera('sysconfig::params::hdl_prefix', '12345') + $hdl_db_name = hiera('sysconfig::params::hdl_db_name', 'handle') + $tomcat_open_port = hiera('sysconfig::params::tomcat_open_port', false) $vhost = hiera('sysconfig::params::vhost', $::ipaddress) diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/sysconfig/manifests/sesame.pp --- a/dev/provisioning/modules/sysconfig/manifests/sesame.pp Fri Apr 08 17:50:49 2016 +0200 +++ b/dev/provisioning/modules/sysconfig/manifests/sesame.pp Fri Apr 08 17:53:56 2016 +0200 @@ -25,10 +25,15 @@ exec { "lexvo_console": command => "/opt/sesame/bin/console.sh < /tmp/lexvo/console_commands.txt", cwd => "/opt/sesame/bin", + creates => "/opt/sesame/.lexvo_loaded", unless => $unless }-> exec { "lexvo_data_archive_delete": command => "/usr/bin/rm -fr /tmp/lexvo" + }-> + file { "/opt/sesame/.lexvo_loaded": + ensure => present, + content => "", } #-> diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/sysconfig/templates/handle/handle_answers.tmp.erb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/sysconfig/templates/handle/handle_answers.tmp.erb Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,21 @@ +y +n +<%= @hdl_host %> +<%= @hdl_host %> +<%= @hdl_srv_port %> +<%= @hdl_web_port %> +y +M +1 +Corpus de la parole +I.R.I. +Handle admin +0123456789 +contact@iri.centrepompidou.fr +y +y +<%= @hdl_key_pswd %> +<%= @hdl_key_pswd %> +y +<%= @hdl_key_pswd %> +<%= @hdl_key_pswd %> diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/sysconfig/templates/handle/handle_config.dct.erb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/sysconfig/templates/handle/handle_config.dct.erb Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,67 @@ +{ + "hdl_http_config" = { + "bind_address" = "<%= @hdl_host %>" + "num_threads" = "15" + "bind_port" = "<%= @hdl_web_port %>" + "log_accesses" = "yes" + } + + "server_type" = "server" + "hdl_udp_config" = { + "bind_address" = "<%= @hdl_host %>" + "num_threads" = "15" + "bind_port" = "<%= @hdl_srv_port %>" + "log_accesses" = "yes" + } + + "hdl_tcp_config" = { + "bind_address" = "<%= @hdl_host %>" + "num_threads" = "15" + "bind_port" = "<%= @hdl_srv_port %>" + "log_accesses" = "yes" + } + + "log_save_config" = { + "log_save_directory" = "logs" + "log_save_interval" = "Monthly" + } + + "no_udp_resolution" = "yes" + "interfaces" = ( + "hdl_udp" + "hdl_tcp" + "hdl_http" + ) + + "server_config" = { + "server_admins" = ( + "300:0.NA/<%= @hdl_prefix %>" + ) + + "replication_admins" = ( + "300:0.NA/<%= @hdl_prefix %>" + ) + + "max_session_time" = "86400000" + "this_server_id" = "1" + "max_auth_time" = "60000" + "server_admin_full_access" = "yes" + "allow_na_admins" = "no" + "case_sensitive" = "no" + + "storage_type" = "sql" + "sql_settings" = { + "sql_url" = "jdbc:mysql://<%= @db_host %>/<%= @hdl_db_name %>?user=<%= @db_user %>&password=<%= @db_pw %>" + "sql_driver" = "com.mysql.jdbc.Driver" + "sql_login" = "<%= @db_user %>" + "sql_passwd" = "<%= @db_pw %>" + "sql_read_only" = "no" + } + + "auto_homed_prefixes" = ( + "0.NA/<%= @hdl_prefix %>" + ) + + } + +} diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/sysconfig/templates/handle/handle_script.exp.erb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/sysconfig/templates/handle/handle_script.exp.erb Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,113 @@ +#!/bin/expect -f +# +# This Expect script was generated by autoexpect on Wed Mar 23 13:16:38 2016 +# Expect and autoexpect were both written by Don Libes, NIST. +# +# Note that autoexpect does not guarantee a working script. It +# necessarily has to guess about certain things. Two reasons a script +# might fail are: +# +# 1) timing - A surprising number of programs (rn, ksh, zsh, telnet, +# etc.) and devices discard or ignore keystrokes that arrive "too +# quickly" after prompts. If you find your new script hanging up at +# one spot, try adding a short sleep just before the previous send. +# Setting "force_conservative" to 1 (see below) makes Expect do this +# automatically - pausing briefly before sending each character. This +# pacifies every program I know of. The -c flag makes the script do +# this in the first place. The -C flag allows you to define a +# character to toggle this mode off and on. + +set force_conservative 0 ;# set to 1 to force conservative mode even if + ;# script wasn't run conservatively originally +if {$force_conservative} { + set send_slow {1 .1} + proc send {ignore arg} { + sleep .1 + exp_send -s -- $arg + } +} + +# +# 2) differing output - Some programs produce different output each time +# they run. The "date" command is an obvious example. Another is +# ftp, if it produces throughput statistics at the end of a file +# transfer. If this causes a problem, delete these patterns or replace +# them with wildcards. An alternative is to use the -p flag (for +# "prompt") which makes Expect only look for the last line of output +# (i.e., the prompt). The -P flag allows you to define a character to +# toggle this mode off and on. +# +# Read the man page for more info. +# +# -Don + + +set timeout -1 +spawn /opt/handle/bin/hdl-setup-server /var/lib/handle +match_max 100000 + +expect -re "Will this be a \"primary\" server \\\(ie, not a mirror of another server\\\)\\\?\\\(y/n\\\) \\\[y\\\]: $" +# expect -re "\\\[y\\\]: $" +send -- "y\r" + +expect -re "Will this be a dual\\\-stack server \\\(accessible on both IPv6 and IPv4\\\)\\\?\\\(y/n\\\) \\\[n\\\]: $" +send -- "n\r" + +expect -re "Through what network\\\-accessible IP address should clients connect to this server\\\? \\\[127.0.0.1\\\]: $" +send -- "<%= @hdl_host %>\r" + +expect -re "If different, enter the IP address to which the server should bind\\\. \\\[172.16.1.6\\\]: $" +send -- "0.0.0.0\r" + +expect -re "Enter the \\\(TCP/UDP\\\) port number this server will listen to \\\[2641\\\]: $" +send -- "<%= @hdl_srv_port %>\r" + +expect -re "What port number will the HTTP interface be listening to\\\? \\\[8000\\\]: $" +send -- "<%= @hdl_web_port %>\r" + +expect -re "Would you like to log all accesses to this server\\\?\\\(y/n\\\) \\\[y\\\]: $" +send -- "y\r" + +expect -re "\\\(\"N\" \\\(Never\\\), \"M\" \\\(Monthly\\\), \"W\" \\\(Weekly\\\), or \"D\" \\\(Daily\\\)\\\)\\\? \\\[Monthly\\\] : $" +send -- "M\r" + +expect -re "Enter the version/serial number of this site \\\[1\\\]: $" +send -- "1\r" + +expect -re "Please enter a short description of this server/site: $" +send -- "Corpus de la parole\r" + +expect -re "Please enter the name of your organization: $" +send -- "I.R.I.\r" + +expect -re "for I.R.I. \\\(optional\\\) \\\[\\\(none\\\)\\\]: $" +send -- "Handle admin\r" + +expect -re "Please enter the telephone number of Handle admin or of I\\\.R\\\.I\\\. \\\(optional\\\) \\\[\\\(none\\\)\\\]: $" +send -- "0123456789\r" + +expect -re "Please enter the email address of Handle admin or of I\\\.R\\\.I\\\.: $" +send -- "contact@iri.centrepompidou.fr\r" + +expect -re "Do you need to disable UDP services\\\?\\\(y/n\\\) \\\[n\\\]: $" +send -- "y\r" + +expect -re "Would you like to encrypt your private key\\\?\\\(y/n\\\) \\\[y\\\]: $" +send -- "y\r" + +expect -re "Note: Your passphrase will be displayed as it is entered\r" +send -- "<%= @hdl_key_pswd %>\r" + +expect -re "Note: Your passphrase will be displayed as it is entered\r" +send -- "<%= @hdl_key_pswd %>\r" + +expect -re "Would you like to encrypt your private key\\\?\\\(y/n\\\) \\\[y\\\]: $" +send -- "y\r" + +expect -re "Note: Your passphrase will be displayed as it is entered\r" +send -- "<%= @hdl_key_pswd %>\r" + +expect -re "Note: Your passphrase will be displayed as it is entered\r" +send -- "<%= @hdl_key_pswd %>\r" + +expect eof diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/sysconfig/templates/handle/handle_sysconfig.erb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/sysconfig/templates/handle/handle_sysconfig.erb Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,1 @@ +HANDLE_KEY_PSWD=<%= @hdl_key_pswd %> diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/systemd/.gitignore --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/systemd/.gitignore Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,10 @@ +pkg/ +Gemfile.lock +vendor/ +spec/fixtures/ +.vagrant/ +.bundle/ +coverage/ +log/ +.*.swp +*~ diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/systemd/.puppet-lint.rc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/systemd/.puppet-lint.rc Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,5 @@ +--fail-on-warnings +--relative +--no-80chars +--no-documentation +--no-class_inherits_from_params_class-check diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/systemd/.sync.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/systemd/.sync.yml Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,3 @@ +--- +.travis.yml: + forge_password: "ASTRdmLjJNa1NvHy2LRGvmvUeth6W3Fh/alYWvcvI8nDDsdkweHk0iXhcXZwtMQReb0NI5vJiRNXNy7a3XySC4+SP3hfHuDU58H2FqC4Ff0EHRPRHTEiXf7xmN53RxXYXZQvrFfqUb6tIsBNVKVmsYWNe01k8NVKPyYDfQB75PQ=" diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/systemd/.travis.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/systemd/.travis.yml Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,32 @@ +--- +language: ruby +sudo: false +cache: bundler +bundler_args: --without system_tests +script: ["bundle exec rake validate", "bundle exec rake lint", "bundle exec rake spec SPEC_OPTS='--format documentation'", "bundle exec rake metadata"] +matrix: + fast_finish: true + include: + - rvm: 1.8.7 + env: PUPPET_GEM_VERSION="~> 3.0" FACTER_GEM_VERSION="~> 1.7.0" + - rvm: 1.9.3 + env: PUPPET_GEM_VERSION="~> 3.0" + - rvm: 2.0.0 + env: PUPPET_GEM_VERSION="~> 3.0" + - rvm: 2.0.0 + env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes" + - rvm: 2.1.6 + env: PUPPET_GEM_VERSION="~> 4.0" +notifications: + email: false +deploy: + provider: puppetforge + user: camptocamp + password: + secure: "ASTRdmLjJNa1NvHy2LRGvmvUeth6W3Fh/alYWvcvI8nDDsdkweHk0iXhcXZwtMQReb0NI5vJiRNXNy7a3XySC4+SP3hfHuDU58H2FqC4Ff0EHRPRHTEiXf7xmN53RxXYXZQvrFfqUb6tIsBNVKVmsYWNe01k8NVKPyYDfQB75PQ=" + on: + tags: true + # all_branches is required to use tags + all_branches: true + # Only publish if our main Ruby target builds + rvm: 1.9.3 diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/systemd/CHANGELOG.md --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/systemd/CHANGELOG.md Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,59 @@ +# Change Log + +## [0.2.2](https://forge.puppetlabs.com/camptocamp/systemd/0.2.2) (2015-08-25) +**Implemented enhancements:** + +- Add 'systemd-tmpfiles-create' [\#1](https://github.com/camptocamp/puppet-systemd/pull/1) ([roidelapluie](https://github.com/roidelapluie)) + +## [0.2.1](https://forge.puppetlabs.com/camptocamp/systemd/0.2.1) (2015-08-21) +[Full Changelog](https://github.com/camptocamp/puppet-systemd/compare/0.2.0...0.2.1) + +- Use docker for acceptance tests + +## [0.1.15](https://forge.puppetlabs.com/camptocamp/systemd/0.1.15) (2015-06-26) +[Full Changelog](https://github.com/camptocamp/puppet-systemd/compare/0.1.14...0.1.15) + +- Fix strict_variables activation with rspec-puppet 2.2 + +## [0.1.14](https://forge.puppetlabs.com/camptocamp/systemd/0.1.14) (2015-05-28) +[Full Changelog](https://github.com/camptocamp/puppet-systemd/compare/0.1.13...0.1.14) + +- Add beaker_spec_helper to Gemfile + +## [0.1.13](https://forge.puppetlabs.com/camptocamp/systemd/0.1.13) (2015-05-26) +[Full Changelog](https://github.com/camptocamp/puppet-systemd/compare/0.1.12...0.1.13) + +- Use random application order in nodeset + +## [0.1.12](https://forge.puppetlabs.com/camptocamp/systemd/0.1.12) (2015-05-26) +[Full Changelog](https://github.com/camptocamp/puppet-systemd/compare/0.1.11...0.1.12) + +- Add utopic & vivid nodesets + +## [0.1.11](https://forge.puppetlabs.com/camptocamp/systemd/0.1.11) (2015-05-25) +[Full Changelog](https://github.com/camptocamp/puppet-systemd/compare/0.1.10...0.1.11) + +- Don't allow failure on Puppet 4 + +## [0.1.10](https://forge.puppetlabs.com/camptocamp/systemd/0.1.10) (2015-05-13) +[Full Changelog](https://github.com/camptocamp/puppet-systemd/compare/0.1.9...0.1.10) + +- Add puppet-lint-file_source_rights-check gem + +## [0.1.9](https://forge.puppetlabs.com/camptocamp/systemd/0.1.9) (2015-05-12) +[Full Changelog](https://github.com/camptocamp/puppet-systemd/compare/0.1.8...0.1.9) + +- Don't pin beaker + +## [0.1.8](https://forge.puppetlabs.com/camptocamp/systemd/0.1.8) (2015-04-27) +[Full Changelog](https://github.com/camptocamp/puppet-systemd/compare/0.1.7...0.1.8) + +- Add nodeset ubuntu-12.04-x86_64-openstack + +## [0.1.7](https://forge.puppetlabs.com/camptocamp/systemd/0.1.7) (2015-04-03) +[Full Changelog](https://github.com/camptocamp/puppet-systemd/compare/0.1.6...0.1.7) + +- Confine rspec pinning to ruby 1.8 + + +\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* \ No newline at end of file diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/systemd/Gemfile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/systemd/Gemfile Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,47 @@ +source ENV['GEM_SOURCE'] || "https://rubygems.org" + +group :development, :unit_tests do + gem 'rake', :require => false + gem 'rspec', '< 3.2', :require => false if RUBY_VERSION =~ /^1.8/ + gem 'rspec-puppet', :require => false + gem 'puppetlabs_spec_helper', :require => false + gem 'metadata-json-lint', :require => false + gem 'puppet-lint', :require => false + gem 'puppet-lint-unquoted_string-check', :require => false + gem 'puppet-lint-empty_string-check', :require => false + gem 'puppet-lint-spaceship_operator_without_tag-check', :require => false + gem 'puppet-lint-variable_contains_upcase', :require => false + gem 'puppet-lint-absolute_classname-check', :require => false + gem 'puppet-lint-undef_in_function-check', :require => false + gem 'puppet-lint-leading_zero-check', :require => false + gem 'puppet-lint-trailing_comma-check', :require => false + gem 'puppet-lint-file_ensure-check', :require => false + gem 'puppet-lint-version_comparison-check', :require => false + gem 'puppet-lint-fileserver-check', :require => false + gem 'puppet-lint-file_source_rights-check', :require => false + gem 'puppet-lint-alias-check', :require => false + gem 'rspec-puppet-facts', :require => false + gem 'github_changelog_generator', :require => false, :git => 'https://github.com/raphink/github-changelog-generator.git', :branch => 'dev/all_patches' if RUBY_VERSION !~ /^1.8/ + gem 'puppet-blacksmith', :require => false if RUBY_VERSION !~ /^1.8/ +end + +group :system_tests do + gem 'beaker', :require => false + gem 'beaker-rspec', :require => false + gem 'beaker_spec_helper', :require => false + gem 'serverspec', :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 diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/systemd/HISTORY.md --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/systemd/HISTORY.md Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,59 @@ +# Change Log + +## [0.2.2](https://forge.puppetlabs.com/camptocamp/systemd/0.2.2) (2015-08-25) +**Implemented enhancements:** + +- Add 'systemd-tmpfiles-create' [\#1](https://github.com/camptocamp/puppet-systemd/pull/1) ([roidelapluie](https://github.com/roidelapluie)) + +## [0.2.1](https://forge.puppetlabs.com/camptocamp/systemd/0.2.1) (2015-08-21) +[Full Changelog](https://github.com/camptocamp/puppet-systemd/compare/0.2.0...0.2.1) + +- Use docker for acceptance tests + +## [0.1.15](https://forge.puppetlabs.com/camptocamp/systemd/0.1.15) (2015-06-26) +[Full Changelog](https://github.com/camptocamp/puppet-systemd/compare/0.1.14...0.1.15) + +- Fix strict_variables activation with rspec-puppet 2.2 + +## [0.1.14](https://forge.puppetlabs.com/camptocamp/systemd/0.1.14) (2015-05-28) +[Full Changelog](https://github.com/camptocamp/puppet-systemd/compare/0.1.13...0.1.14) + +- Add beaker_spec_helper to Gemfile + +## [0.1.13](https://forge.puppetlabs.com/camptocamp/systemd/0.1.13) (2015-05-26) +[Full Changelog](https://github.com/camptocamp/puppet-systemd/compare/0.1.12...0.1.13) + +- Use random application order in nodeset + +## [0.1.12](https://forge.puppetlabs.com/camptocamp/systemd/0.1.12) (2015-05-26) +[Full Changelog](https://github.com/camptocamp/puppet-systemd/compare/0.1.11...0.1.12) + +- Add utopic & vivid nodesets + +## [0.1.11](https://forge.puppetlabs.com/camptocamp/systemd/0.1.11) (2015-05-25) +[Full Changelog](https://github.com/camptocamp/puppet-systemd/compare/0.1.10...0.1.11) + +- Don't allow failure on Puppet 4 + +## [0.1.10](https://forge.puppetlabs.com/camptocamp/systemd/0.1.10) (2015-05-13) +[Full Changelog](https://github.com/camptocamp/puppet-systemd/compare/0.1.9...0.1.10) + +- Add puppet-lint-file_source_rights-check gem + +## [0.1.9](https://forge.puppetlabs.com/camptocamp/systemd/0.1.9) (2015-05-12) +[Full Changelog](https://github.com/camptocamp/puppet-systemd/compare/0.1.8...0.1.9) + +- Don't pin beaker + +## [0.1.8](https://forge.puppetlabs.com/camptocamp/systemd/0.1.8) (2015-04-27) +[Full Changelog](https://github.com/camptocamp/puppet-systemd/compare/0.1.7...0.1.8) + +- Add nodeset ubuntu-12.04-x86_64-openstack + +## [0.1.7](https://forge.puppetlabs.com/camptocamp/systemd/0.1.7) (2015-04-03) +[Full Changelog](https://github.com/camptocamp/puppet-systemd/compare/0.1.6...0.1.7) + +- Confine rspec pinning to ruby 1.8 + + +\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* \ No newline at end of file diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/systemd/README.md --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/systemd/README.md Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,38 @@ +# Systemd + +[![Puppet Forge](http://img.shields.io/puppetforge/v/camptocamp/systemd.svg)](https://forge.puppetlabs.com/camptocamp/systemd) +[![Build Status](https://travis-ci.org/camptocamp/puppet-systemd.png?branch=master)](https://travis-ci.org/camptocamp/puppet-systemd) + +## Overview + +This module declares exec resources that you can use when you change systemd units or configuration files. + +## Examples + +### systemctl --daemon-reload + +```puppet +include ::systemd +file { '/usr/lib/systemd/system/foo.service': + ensure => file, + owner => 'root', + group => 'root', + mode => '0644', + source => "puppet:///modules/${module_name}/foo.service", +} ~> +Exec['systemctl-daemon-reload'] +``` + +### systemd-tmpfiles --create + +```puppet +include ::systemd +file { '/etc/tmpfiles.d/foo.conf': + ensure => file, + owner => 'root', + group => 'root', + mode => '0644', + source => "puppet:///modules/${module_name}/foo.conf", +} ~> +Exec['systemd-tmpfiles-create'] +``` diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/systemd/Rakefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/systemd/Rakefile Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,23 @@ +require 'puppetlabs_spec_helper/rake_tasks' +require 'puppet-lint/tasks/puppet-lint' + +Rake::Task[:lint].clear +PuppetLint::RakeTask.new :lint do |config| + config.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp", "vendor/**/*.pp"] + config.disable_checks = ['80chars'] + config.fail_on_warnings = true +end + +PuppetSyntax.exclude_paths = ["spec/fixtures/**/*.pp", "vendor/**/*"] + +# Publishing tasks +unless RUBY_VERSION =~ /^1\.8/ + require 'puppet_blacksmith' + require 'puppet_blacksmith/rake_tasks' + require 'github_changelog_generator/task' + GitHubChangelogGenerator::RakeTask.new :changelog do |config| + m = Blacksmith::Modulefile.new + config.future_release = m.version + config.release_url = "https://forge.puppetlabs.com/#{m.author}/#{m.name}/%s" + end +end diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/systemd/manifests/init.pp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/systemd/manifests/init.pp Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,18 @@ +class systemd { + + Exec { + refreshonly => true, + path => $::path, + } + + exec { + 'systemctl-daemon-reload': + command => 'systemctl daemon-reload', + } + + exec { + 'systemd-tmpfiles-create': + command => 'systemd-tmpfiles --create', + } + +} diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/systemd/metadata.json --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/systemd/metadata.json Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,48 @@ +{ + "name": "camptocamp-systemd", + "version": "0.2.2", + "author": "camptocamp", + "summary": "Puppet Systemd module", + "license": "Apache-2.0", + "source": "https://github.com/camptocamp/puppet-systemd", + "project_page": "https://github.com/camptocamp/puppet-systemd", + "issues_url": "https://github.com/camptocamp/puppet-systemd/issues", + "dependencies": [ + + ], + "requirements": [ + { + "name": "pe", + "version_requirement": "3.x" + }, + { + "name": "puppet", + "version_requirement": "3.x" + } + ], + "operatingsystem_support": [ + { + "operatingsystem": "Debian", + "operatingsystemrelease": [ + "8" + ] + }, + { + "operatingsystem": "RedHat", + "operatingsystemrelease": [ + "7" + ] + } + ], + "puppet_version": [ + "2.7", + "3.0", + "3.1", + "3.2", + "3.3", + "3.4", + "3.5", + "3.6", + "3.7" + ] +} diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/systemd/spec/acceptance/nodesets/centos-5-x86_64-docker.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/systemd/spec/acceptance/nodesets/centos-5-x86_64-docker.yml Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,15 @@ +HOSTS: + centos-5-x64: + default_apply_opts: + order: random + strict_variables: + platform: el-5-x86_64 + hypervisor : docker + image: centos:5 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'yum install -y crontabs tar wget' +CONFIG: + type: foss + log_level: debug diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/systemd/spec/acceptance/nodesets/centos-6-x86_64-docker.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/systemd/spec/acceptance/nodesets/centos-6-x86_64-docker.yml Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,15 @@ +HOSTS: + centos-6-x64: + default_apply_opts: + order: random + strict_variables: + platform: el-6-x86_64 + hypervisor : docker + image: centos:6 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'yum install -y crontabs tar wget' +CONFIG: + type: foss + log_level: debug diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/systemd/spec/acceptance/nodesets/centos-6-x86_64-openstack.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/systemd/spec/acceptance/nodesets/centos-6-x86_64-openstack.yml Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,14 @@ +HOSTS: + centos-6-x64: + default_apply_opts: + order: random + strict_variables: + platform: el-6-x86_64 + hypervisor : openstack + flavor: m1.small + image: centos-6-latest + user: root +CONFIG: + type: foss + log_level: debug + openstack_network: default diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/systemd/spec/acceptance/nodesets/centos-6-x86_64-vagrant.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/systemd/spec/acceptance/nodesets/centos-6-x86_64-vagrant.yml Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,11 @@ +HOSTS: + centos-6-x64: + default_apply_opts: + order: random + strict_variables: + platform: el-6-x86_64 + hypervisor : vagrant + box : camptocamp/centos-6-x86_64 +CONFIG: + type: foss + log_level: debug diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/systemd/spec/acceptance/nodesets/centos-7-x86_64-docker.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/systemd/spec/acceptance/nodesets/centos-7-x86_64-docker.yml Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,15 @@ +HOSTS: + centos-7-x64: + default_apply_opts: + order: random + strict_variables: + platform: el-7-x86_64 + hypervisor : docker + image: centos:7 + docker_preserve_image: true + docker_cmd: '["/usr/sbin/init"]' + docker_image_commands: + - 'yum install -y crontabs tar wget' +CONFIG: + type: foss + log_level: debug diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/systemd/spec/acceptance/nodesets/centos-7-x86_64-openstack.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/systemd/spec/acceptance/nodesets/centos-7-x86_64-openstack.yml Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,14 @@ +HOSTS: + centos-7-x64: + default_apply_opts: + order: random + strict_variables: + platform: el-7-x86_64 + hypervisor : openstack + flavor: m1.small + image: centos-7-latest + user: centos +CONFIG: + type: foss + log_level: debug + openstack_network: default diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/systemd/spec/acceptance/nodesets/centos-7-x86_64-vagrant.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/systemd/spec/acceptance/nodesets/centos-7-x86_64-vagrant.yml Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,11 @@ +HOSTS: + centos-7-x64: + default_apply_opts: + order: random + strict_variables: + platform: el-7-x86_64 + hypervisor : vagrant + box : camptocamp/centos-7-x86_64 +CONFIG: + type: foss + log_level: debug diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/systemd/spec/acceptance/nodesets/debian-6-x86_64-docker.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/systemd/spec/acceptance/nodesets/debian-6-x86_64-docker.yml Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,15 @@ +HOSTS: + debian-6-x64: + default_apply_opts: + order: random + strict_variables: + platform: debian-6-amd64 + hypervisor : docker + image: debian:6 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'apt-get install -y wget' +CONFIG: + type: foss + log_level: debug diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/systemd/spec/acceptance/nodesets/debian-6-x86_64-openstack.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/systemd/spec/acceptance/nodesets/debian-6-x86_64-openstack.yml Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,14 @@ +HOSTS: + debian-6-x64: + default_apply_opts: + order: random + strict_variables: + platform: debian-6-amd64 + hypervisor : openstack + flavor: m1.small + image: debian-6-latest + user: debian +CONFIG: + type: foss + log_level: debug + openstack_network: default diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/systemd/spec/acceptance/nodesets/debian-6-x86_64-vagrant.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/systemd/spec/acceptance/nodesets/debian-6-x86_64-vagrant.yml Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,11 @@ +HOSTS: + debian-6-x64: + default_apply_opts: + order: random + strict_variables: + platform: debian-6-amd64 + hypervisor : vagrant + box : puppetlabs/debian-6.0.10-64-nocm +CONFIG: + type: foss + log_level: debug diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/systemd/spec/acceptance/nodesets/debian-7-x86_64-docker.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/systemd/spec/acceptance/nodesets/debian-7-x86_64-docker.yml Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,15 @@ +HOSTS: + debian-7-x64: + default_apply_opts: + order: random + strict_variables: + platform: debian-7-amd64 + hypervisor : docker + image: debian:7 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'apt-get install -y cron wget' +CONFIG: + type: foss + log_level: debug diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/systemd/spec/acceptance/nodesets/debian-7-x86_64-openstack.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/systemd/spec/acceptance/nodesets/debian-7-x86_64-openstack.yml Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,14 @@ +HOSTS: + debian-7-x64: + default_apply_opts: + order: random + strict_variables: + platform: debian-7-amd64 + hypervisor : openstack + flavor: m1.small + image: debian-7-latest + user: debian +CONFIG: + type: foss + log_level: debug + openstack_network: default diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/systemd/spec/acceptance/nodesets/debian-7-x86_64-vagrant.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/systemd/spec/acceptance/nodesets/debian-7-x86_64-vagrant.yml Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,11 @@ +HOSTS: + debian-7-x64: + default_apply_opts: + order: random + strict_variables: + platform: debian-7-amd64 + hypervisor : vagrant + box : camptocamp/debian-7-amd64 +CONFIG: + type: foss + log_level: debug diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/systemd/spec/acceptance/nodesets/debian-8-x86_64-docker.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/systemd/spec/acceptance/nodesets/debian-8-x86_64-docker.yml Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,15 @@ +HOSTS: + debian-8-x64: + default_apply_opts: + order: random + strict_variables: + platform: debian-8-amd64 + hypervisor : docker + image: debian:8 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'apt-get install -y cron wget' +CONFIG: + type: foss + log_level: debug diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/systemd/spec/acceptance/nodesets/debian-8-x86_64-openstack.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/systemd/spec/acceptance/nodesets/debian-8-x86_64-openstack.yml Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,14 @@ +HOSTS: + debian-8-x64: + default_apply_opts: + order: random + strict_variables: + platform: debian-8-amd64 + hypervisor : openstack + flavor: m1.small + image: debian-8-latest + user: debian +CONFIG: + type: foss + log_level: debug + openstack_network: default diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/systemd/spec/acceptance/nodesets/debian-8-x86_64-vagrant.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/systemd/spec/acceptance/nodesets/debian-8-x86_64-vagrant.yml Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,11 @@ +HOSTS: + debian-8-x64: + default_apply_opts: + order: random + strict_variables: + platform: debian-8-amd64 + hypervisor : vagrant + box : camptocamp/debian-8-amd64 +CONFIG: + type: foss + log_level: debug diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/systemd/spec/acceptance/nodesets/ubuntu-10.04-x86_64-docker.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/systemd/spec/acceptance/nodesets/ubuntu-10.04-x86_64-docker.yml Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,13 @@ +HOSTS: + ubuntu-1004-x64: + default_apply_opts: + order: random + strict_variables: + platform: ubuntu-10.04-amd64 + hypervisor : docker + image: ubuntu:10.04 + # This stops the image from being deleted on completion, speeding up the process. + docker_preserve_image: true +CONFIG: + type: foss + log_level: debug diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/systemd/spec/acceptance/nodesets/ubuntu-12.04-x86_64-docker.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/systemd/spec/acceptance/nodesets/ubuntu-12.04-x86_64-docker.yml Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,15 @@ +HOSTS: + ubuntu-1204-x64: + default_apply_opts: + order: random + strict_variables: + platform: ubuntu-12.04-amd64 + hypervisor : docker + image: ubuntu:12.04 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'apt-get install -y wget' +CONFIG: + type: foss + log_level: debug diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/systemd/spec/acceptance/nodesets/ubuntu-12.04-x86_64-openstack.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/systemd/spec/acceptance/nodesets/ubuntu-12.04-x86_64-openstack.yml Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,14 @@ +HOSTS: + ubuntu-1204-x64: + default_apply_opts: + order: random + strict_variables: + platform: ubuntu-12.04-amd64 + hypervisor : openstack + flavor: m1.small + image: ubuntu-1204-latest + user: ubuntu +CONFIG: + type: foss + log_level: debug + openstack_network: default diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/systemd/spec/acceptance/nodesets/ubuntu-14.04-x86_64-docker.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/systemd/spec/acceptance/nodesets/ubuntu-14.04-x86_64-docker.yml Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,15 @@ +HOSTS: + ubuntu-1404-x64: + default_apply_opts: + order: random + strict_variables: + platform: ubuntu-14.04-amd64 + hypervisor : docker + image: ubuntu:14.04 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'apt-get install -y wget' +CONFIG: + type: foss + log_level: debug diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/systemd/spec/acceptance/nodesets/ubuntu-14.04-x86_64-openstack.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/systemd/spec/acceptance/nodesets/ubuntu-14.04-x86_64-openstack.yml Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,14 @@ +HOSTS: + ubuntu-1404-x64: + default_apply_opts: + order: random + strict_variables: + platform: ubuntu-14.04-amd64 + hypervisor : openstack + flavor: m1.small + image: ubuntu-1404-latest + user: ubuntu +CONFIG: + type: foss + log_level: debug + openstack_network: default diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/systemd/spec/acceptance/nodesets/ubuntu-14.04-x86_64-vagrant.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/systemd/spec/acceptance/nodesets/ubuntu-14.04-x86_64-vagrant.yml Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,11 @@ +HOSTS: + ubuntu-1404-x64: + default_apply_opts: + order: random + strict_variables: + platform: ubuntu-14.04-amd64 + hypervisor : vagrant + box : puppetlabs/ubuntu-14.04-64-nocm +CONFIG: + type: foss + log_level: debug diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/systemd/spec/acceptance/nodesets/ubuntu-14.10-x86_64-docker.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/systemd/spec/acceptance/nodesets/ubuntu-14.10-x86_64-docker.yml Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,15 @@ +HOSTS: + ubuntu-1410-x64: + default_apply_opts: + order: random + strict_variables: + platform: ubuntu-14.10-amd64 + hypervisor : docker + image: ubuntu:14.10 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'apt-get install -y wget' +CONFIG: + type: foss + log_level: debug diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/systemd/spec/acceptance/nodesets/ubuntu-14.10-x86_64-openstack.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/systemd/spec/acceptance/nodesets/ubuntu-14.10-x86_64-openstack.yml Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,14 @@ +HOSTS: + ubuntu-1410-x64: + default_apply_opts: + order: random + strict_variables: + platform: ubuntu-14.10-amd64 + hypervisor : openstack + flavor: m1.small + image: ubuntu-1410-latest + user: ubuntu +CONFIG: + type: foss + log_level: debug + openstack_network: default diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/systemd/spec/acceptance/nodesets/ubuntu-15.04-x86_64-docker.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/systemd/spec/acceptance/nodesets/ubuntu-15.04-x86_64-docker.yml Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,15 @@ +HOSTS: + ubuntu-1504-x64: + default_apply_opts: + order: random + strict_variables: + platform: ubuntu-15.04-amd64 + hypervisor : docker + image: ubuntu:15.04 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'apt-get install -y wget' +CONFIG: + type: foss + log_level: debug diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/systemd/spec/acceptance/nodesets/ubuntu-15.04-x86_64-openstack.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/systemd/spec/acceptance/nodesets/ubuntu-15.04-x86_64-openstack.yml Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,14 @@ +HOSTS: + ubuntu-1504-x64: + default_apply_opts: + order: random + strict_variables: + platform: ubuntu-15.04-amd64 + hypervisor : openstack + flavor: m1.small + image: ubuntu-1504-latest + user: ubuntu +CONFIG: + type: foss + log_level: debug + openstack_network: default diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/systemd/spec/spec.opts --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/systemd/spec/spec.opts Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,6 @@ +--format +s +--colour +--loadby +mtime +--backtrace diff -r 49b75287c30b -r dc4d1cdc47e0 dev/provisioning/modules/systemd/spec/spec_helper.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dev/provisioning/modules/systemd/spec/spec_helper.rb Fri Apr 08 17:53:56 2016 +0200 @@ -0,0 +1,42 @@ +require 'puppetlabs_spec_helper/module_spec_helper' +require 'rspec-puppet-facts' +include RspecPuppetFacts + + +RSpec.configure do |c| + c.include PuppetlabsSpec::Files + + c.before :each do + # Store any environment variables away to be restored later + @old_env = {} + ENV.each_key {|k| @old_env[k] = ENV[k]} + + c.strict_variables = Gem::Version.new(Puppet.version) >= Gem::Version.new('3.5') + Puppet.features.stubs(:root?).returns(true) + end + + c.after :each do + PuppetlabsSpec::Files.cleanup + end +end + +require 'pathname' +dir = Pathname.new(__FILE__).parent +Puppet[:modulepath] = File.join(dir, 'fixtures', 'modules') + +# There's no real need to make this version dependent, but it helps find +# regressions in Puppet +# +# 1. Workaround for issue #16277 where default settings aren't initialised from +# a spec and so the libdir is never initialised (3.0.x) +# 2. Workaround for 2.7.20 that now only loads types for the current node +# environment (#13858) so Puppet[:modulepath] seems to get ignored +# 3. Workaround for 3.5 where context hasn't been configured yet, +# ticket https://tickets.puppetlabs.com/browse/MODULES-823 +# +ver = Gem::Version.new(Puppet.version.split('-').first) +if Gem::Requirement.new("~> 2.7.20") =~ ver || Gem::Requirement.new("~> 3.0.0") =~ ver || Gem::Requirement.new("~> 3.5") =~ ver || Gem::Requirement.new("~> 4.0") + puts "augeasproviders: setting Puppet[:libdir] to work around broken type autoloading" + # libdir is only a single dir, so it can only workaround loading of one external module + Puppet[:libdir] = "#{Puppet[:modulepath]}/augeasproviders_core/lib" +end