Skip to content

Commit bc06568

Browse files
author
carabasdaniel
authored
Merge branch 'master' into allow-adapt-config-file-permissions
2 parents 36f75fc + 775bed0 commit bc06568

17 files changed

+127
-68
lines changed

.github/workflows/release.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ on:
77

88
jobs:
99
LitmusAcceptance:
10-
10+
env:
11+
HONEYCOMB_WRITEKEY: 7f3c63a70eecc61d635917de46bea4e6
12+
HONEYCOMB_DATASET: litmus tests
1113
runs-on: self-hosted
1214

1315
strategy:

.sync.yml

+10-8
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
- rubocop-i18n
99
- rubocop-rspec
1010
".travis.yml":
11+
global_env:
12+
- HONEYCOMB_WRITEKEY="7f3c63a70eecc61d635917de46bea4e6",HONEYCOMB_DATASET="litmus tests"
1113
deploy_to_forge:
1214
enabled: false
1315
branches:
@@ -67,10 +69,10 @@
6769
stage: acceptance
6870
- bundler_args:
6971
dist: trusty
70-
env: PLATFORMS=el7_puppet5
72+
env: PLATFORMS=el6_puppet5
7173
rvm: 2.5.3
7274
before_script:
73-
- bundle exec rake 'litmus:provision_list[travis_el7]'
75+
- bundle exec rake 'litmus:provision_list[travis_el6]'
7476
- bundle exec rake 'litmus:install_agent[puppet5]'
7577
- bundle exec rake litmus:install_module
7678
script:
@@ -80,10 +82,10 @@
8082
stage: acceptance
8183
- bundler_args:
8284
dist: trusty
83-
env: PLATFORM=el7_puppet6
85+
env: PLATFORM=el6_puppet6
8486
rvm: 2.5.3
8587
before_script:
86-
- bundle exec rake 'litmus:provision_list[travis_el7]'
88+
- bundle exec rake 'litmus:provision_list[travis_el6]'
8789
- bundle exec rake 'litmus:install_agent[puppet6]'
8890
- bundle exec rake litmus:install_module
8991
script:
@@ -93,10 +95,10 @@
9395
stage: acceptance
9496
- bundler_args:
9597
dist: trusty
96-
env: PLATFORMS=el6_puppet5
98+
env: PLATFORMS=el7_puppet5
9799
rvm: 2.5.3
98100
before_script:
99-
- bundle exec rake 'litmus:provision_list[travis_el6]'
101+
- bundle exec rake 'litmus:provision_list[travis_el7]'
100102
- bundle exec rake 'litmus:install_agent[puppet5]'
101103
- bundle exec rake litmus:install_module
102104
script:
@@ -106,10 +108,10 @@
106108
stage: acceptance
107109
- bundler_args:
108110
dist: trusty
109-
env: PLATFORMS=el6_puppet6
111+
env: PLATFORMS=el7_puppet6
110112
rvm: 2.5.3
111113
before_script:
112-
- bundle exec rake 'litmus:provision_list[travis_el6]'
114+
- bundle exec rake 'litmus:provision_list[travis_el7]'
113115
- bundle exec rake 'litmus:install_agent[puppet6]'
114116
- bundle exec rake litmus:install_module
115117
script:

.travis.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,18 @@ before_install:
77
- rm -f Gemfile.lock
88
- "# Update system gems if requested. This is useful to temporarily workaround troubles in the test runner"
99
- "# See https://github.com/puppetlabs/pdk-templates/commit/705154d5c437796b821691b707156e1b056d244f for an example of how this was used"
10-
- '[ -z "$RUBYGEMS_VERSION" ] || gem update --system $RUBYGEMS_VERSION'
10+
- "# Ignore exit code of SIGPIPE'd yes to not fail with shell's pipefail set"
11+
- '[ -z "$RUBYGEMS_VERSION" ] || (yes || true) | gem update --system $RUBYGEMS_VERSION'
1112
- gem --version
1213
- bundle -v
1314
script:
1415
- 'SIMPLECOV=yes bundle exec rake $CHECK'
1516
bundler_args: --without system_tests
1617
rvm:
1718
- 2.5.3
19+
env:
20+
global:
21+
- HONEYCOMB_WRITEKEY="7f3c63a70eecc61d635917de46bea4e6",HONEYCOMB_DATASET="litmus tests"
1822
stages:
1923
- static
2024
- spec
@@ -107,7 +111,7 @@ matrix:
107111
before_script: ["bundle exec rake 'litmus:provision_list[travis_el7]'", "bundle exec rake 'litmus:install_agent[puppet6]'", "bundle exec rake litmus:install_module"]
108112
bundler_args:
109113
dist: trusty
110-
env: PLATFORM=el7_puppet6
114+
env: PLATFORMS=el7_puppet6
111115
rvm: 2.5.3
112116
script: ["bundle exec rake litmus:acceptance:parallel"]
113117
services: docker

Gemfile

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ group :development do
2424
gem "json", '= 2.0.4', require: false if Gem::Requirement.create('~> 2.4.2').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
2525
gem "json", '= 2.1.0', require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
2626
gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw]
27-
gem "puppet-module-posix-default-r#{minor_version}", '~> 0.3', require: false, platforms: [:ruby]
28-
gem "puppet-module-posix-dev-r#{minor_version}", '~> 0.3', require: false, platforms: [:ruby]
29-
gem "puppet-module-win-default-r#{minor_version}", '~> 0.3', require: false, platforms: [:mswin, :mingw, :x64_mingw]
30-
gem "puppet-module-win-dev-r#{minor_version}", '~> 0.3', require: false, platforms: [:mswin, :mingw, :x64_mingw]
27+
gem "puppet-module-posix-default-r#{minor_version}", '~> 0.4', require: false, platforms: [:ruby]
28+
gem "puppet-module-posix-dev-r#{minor_version}", '~> 0.4', require: false, platforms: [:ruby]
29+
gem "puppet-module-win-default-r#{minor_version}", '~> 0.4', require: false, platforms: [:mswin, :mingw, :x64_mingw]
30+
gem "puppet-module-win-dev-r#{minor_version}", '~> 0.4', require: false, platforms: [:mswin, :mingw, :x64_mingw]
3131
gem "puppet-lint-i18n", require: false
3232
gem "github_changelog_generator", require: false, git: 'https://github.com/skywinder/github-changelog-generator', ref: '20ee04ba1234e9e83eb2ffb5056e23d641c7a018' if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.2.2')
3333
end

README.md

+10-7
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ replicate-do-db = base2
9595

9696
To implement version specific parameters, specify the version, such as [mysqld-5.5]. This allows one config for different versions of MySQL.
9797

98+
If you don’t want to use the default configuration, you can also supply your options to the `$options` parameter instead of `$override_options`.
99+
Please note that `$options` and `$override_options` are mutually exclusive, you can only use one of them.
100+
98101
### Create a database
99102

100103
To create a database with a user and some assigned privileges:
@@ -250,19 +253,19 @@ Class['mysql::bindings']
250253

251254
#### Optional: Install the MariaDB official repo
252255

253-
In this example, we'll use the latest stable (currently 10.1) from the official MariaDB repository, not the one from the distro repository. You could instead use the package from the Ubuntu repository. Make sure you use the repository corresponding to the version you want.
256+
In this example, we'll use the latest stable (currently 10.3) from the official MariaDB repository, not the one from the distro repository. You could instead use the package from the Ubuntu repository. Make sure you use the repository corresponding to the version you want.
254257

255258
**Note:** `sfo1.mirrors.digitalocean.com` is one of many mirrors available. You can use any official mirror.
256259

257260
```puppet
258261
include apt
259262
260263
apt::source { 'mariadb':
261-
location => 'http://sfo1.mirrors.digitalocean.com/mariadb/repo/10.1/ubuntu',
264+
location => 'http://sfo1.mirrors.digitalocean.com/mariadb/repo/10.3/ubuntu',
262265
release => $::lsbdistcodename,
263266
repos => 'main',
264267
key => {
265-
id => '199369E5404BD5FC7D2FE43BCBCB082A1BB943DB',
268+
id => '177F4010FE56CA3336300305F1656F24C74CD1D8',
266269
server => 'hkp://keyserver.ubuntu.com:80',
267270
},
268271
include => {
@@ -274,7 +277,7 @@ apt::source { 'mariadb':
274277

275278
#### Install the MariaDB server
276279

277-
This example shows MariaDB server installation on Ubuntu Trusty. Adjust the version and the parameters of `my.cnf` as needed. All parameters of the `my.cnf` can be defined using the `override_options` parameter.
280+
This example shows MariaDB server installation on Ubuntu Xenial. Adjust the version and the parameters of `my.cnf` as needed. All parameters of the `my.cnf` can be defined using the `override_options` parameter.
278281

279282
The folders `/var/log/mysql` and `/var/run/mysqld` are created automatically, but if you are using other custom folders, they should exist as prerequisites for this code.
280283

@@ -285,8 +288,8 @@ Specify the version of the package you want with the `package_ensure` parameter.
285288
```puppet
286289
class {'::mysql::server':
287290
package_name => 'mariadb-server',
288-
package_ensure => '10.1.14+maria-1~trusty',
289-
service_name => 'mysql',
291+
package_ensure => '1:10.3.21+maria~xenial',
292+
service_name => 'mysqld',
290293
root_password => 'AVeryStrongPasswordUShouldEncrypt!',
291294
override_options => {
292295
mysqld => {
@@ -316,7 +319,7 @@ Specify the version of the package you want with the `package_ensure` parameter.
316319
```puppet
317320
class {'::mysql::client':
318321
package_name => 'mariadb-client',
319-
package_ensure => '10.1.14+maria-1~trusty',
322+
package_ensure => '1:10.3.21+maria~xenial',
320323
bindings_enable => true,
321324
}
322325

Rakefile

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'puppet_litmus/rake_tasks' if Bundler.rubygems.find_name('puppet_litmus').any?
24
require 'puppetlabs_spec_helper/rake_tasks'
35
require 'puppet-syntax/tasks/puppet-syntax'

locales/puppetlabs-mysql.pot

+6
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ msgid ""
7777
"future release."
7878
msgstr ""
7979

80+
#. ./manifests/server.pp:122
81+
msgid ""
82+
"You can\'t specify $options and $override_options simultaneously, see the "
83+
"README section \'Customize server options\'!"
84+
msgstr ""
85+
8086
#: ./lib/puppet/parser/functions/mysql_deepmerge.rb:22
8187
msgid ""
8288
"mysql_deepmerge(): wrong number of arguments (%{args_length}; must be at "

manifests/server.pp

+43-34
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
# Path to secret file containing temporary root password.
2222
# @param manage_config_file
2323
# Whether the MySQL configuration file should be managed. Valid values are `true`, `false`. Defaults to `true`.
24+
# @param options
25+
# A hash of options structured like the override_options, but not merged with the default options. Use this if you don’t want your options merged with the default options.
2426
# @param override_options
2527
# Specifies override options to pass into MySQL. Structured like a hash in the my.cnf file: See above for usage details.
2628
# @param package_ensure
@@ -67,38 +69,37 @@
6769
# This parameter no longer does anything. It exists only for backwards compatibility. See the `root_password` parameter above for details on changing the root password.
6870
#
6971
class mysql::server (
70-
$config_file = $mysql::params::config_file,
71-
$config_file_mode = $mysql::params::config_file_mode,
72-
$includedir = $mysql::params::includedir,
73-
$install_options = undef,
74-
$install_secret_file = $mysql::params::install_secret_file,
75-
$manage_config_file = $mysql::params::manage_config_file,
76-
$override_options = {},
77-
$package_ensure = $mysql::params::server_package_ensure,
78-
$package_manage = $mysql::params::server_package_manage,
79-
$package_name = $mysql::params::server_package_name,
80-
$purge_conf_dir = $mysql::params::purge_conf_dir,
81-
$remove_default_accounts = false,
82-
$restart = $mysql::params::restart,
83-
$root_group = $mysql::params::root_group,
84-
$mysql_group = $mysql::params::mysql_group,
85-
$root_password = $mysql::params::root_password,
86-
$service_enabled = $mysql::params::server_service_enabled,
87-
$service_manage = $mysql::params::server_service_manage,
88-
$service_name = $mysql::params::server_service_name,
89-
$service_provider = $mysql::params::server_service_provider,
90-
$create_root_user = $mysql::params::create_root_user,
91-
$create_root_my_cnf = $mysql::params::create_root_my_cnf,
92-
$create_root_login_file = $mysql::params::create_root_login_file,
93-
$login_file = $mysql::params::login_file,
94-
$users = {},
95-
$grants = {},
96-
$databases = {},
97-
98-
# Deprecated parameters
99-
$enabled = undef,
100-
$manage_service = undef,
101-
$old_root_password = undef
72+
$config_file = $mysql::params::config_file,
73+
$includedir = $mysql::params::includedir,
74+
$install_options = undef,
75+
$install_secret_file = $mysql::params::install_secret_file,
76+
$manage_config_file = $mysql::params::manage_config_file,
77+
Mysql::Options $options = {},
78+
$override_options = {},
79+
$package_ensure = $mysql::params::server_package_ensure,
80+
$package_manage = $mysql::params::server_package_manage,
81+
$package_name = $mysql::params::server_package_name,
82+
$purge_conf_dir = $mysql::params::purge_conf_dir,
83+
$remove_default_accounts = false,
84+
$restart = $mysql::params::restart,
85+
$root_group = $mysql::params::root_group,
86+
$mysql_group = $mysql::params::mysql_group,
87+
$root_password = $mysql::params::root_password,
88+
$service_enabled = $mysql::params::server_service_enabled,
89+
$service_manage = $mysql::params::server_service_manage,
90+
$service_name = $mysql::params::server_service_name,
91+
$service_provider = $mysql::params::server_service_provider,
92+
$create_root_user = $mysql::params::create_root_user,
93+
$create_root_my_cnf = $mysql::params::create_root_my_cnf,
94+
$create_root_login_file = $mysql::params::create_root_login_file,
95+
$login_file = $mysql::params::login_file,
96+
$users = {},
97+
$grants = {},
98+
$databases = {},
99+
# Deprecated parameters
100+
$enabled = undef,
101+
$manage_service = undef,
102+
$old_root_password = undef
102103
) inherits mysql::params {
103104

104105
# Deprecated parameters.
@@ -118,8 +119,16 @@
118119
warning(translate('The `old_root_password` attribute is no longer used and will be removed in a future release.'))
119120
}
120121

121-
# Create a merged together set of options. Rightmost hashes win over left.
122-
$options = mysql::normalise_and_deepmerge($mysql::params::default_options, $override_options)
122+
if ! empty($options) and ! empty($override_options) {
123+
fail(translate('You can\'t specify $options and $override_options simultaneously, see the README section \'Customize server options\'!'))
124+
}
125+
126+
# If override_options are set, create a merged together set of options. Rightmost hashes win over left.
127+
# If options are set, just use them.
128+
$_options = empty($options) ? {
129+
true => mysql::normalise_and_deepmerge($mysql::params::default_options, $override_options),
130+
false => $options,
131+
}
123132

124133
Class['mysql::server::root_password'] -> Mysql::Db <| |>
125134

manifests/server/binarylog.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#
66
class mysql::server::binarylog {
77

8-
$options = $mysql::server::options
8+
$options = $mysql::server::_options
99
$includedir = $mysql::server::includedir
1010

1111
$logbin = pick($options['mysqld']['log-bin'], $options['mysqld']['log_bin'], false)

manifests/server/config.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#
66
class mysql::server::config {
77

8-
$options = $mysql::server::options
8+
$options = $mysql::server::_options
99
$includedir = $mysql::server::includedir
1010

1111
File {

manifests/server/installdb.pp

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
# @summary
1+
# @summary
22
# Builds initial databases on installation.
33
#
44
# @api private
55
#
66
class mysql::server::installdb {
7-
$options = $mysql::server::options
7+
$options = $mysql::server::_options
88

99
if $mysql::server::package_manage {
1010

1111
# Build the initial databases.
12-
$mysqluser = $mysql::server::options['mysqld']['user']
13-
$datadir = $mysql::server::options['mysqld']['datadir']
14-
$basedir = $mysql::server::options['mysqld']['basedir']
12+
$mysqluser = $mysql::server::_options['mysqld']['user']
13+
$datadir = $mysql::server::_options['mysqld']['datadir']
14+
$basedir = $mysql::server::_options['mysqld']['basedir']
1515
$config_file = $mysql::server::config_file
16-
$log_error = $mysql::server::options['mysqld']['log-error']
16+
$log_error = $mysql::server::_options['mysqld']['log-error']
1717

1818
if $mysql::server::manage_config_file and $config_file != $mysql::params::config_file {
1919
$_config_file=$config_file

manifests/server/root_password.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#
66
class mysql::server::root_password {
77

8-
$options = $mysql::server::options
8+
$options = $mysql::server::_options
99
$secret_file = $mysql::server::install_secret_file
1010
$login_file = $mysql::server::login_file
1111

manifests/server/service.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# @api private
55
#
66
class mysql::server::service {
7-
$options = $mysql::server::options
7+
$options = $mysql::server::_options
88

99
if $mysql::server::real_service_manage {
1010
if $mysql::server::real_service_enabled {

metadata.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,6 @@
8484
],
8585
"description": "MySQL module",
8686
"template-url": "https://github.com/puppetlabs/pdk-templates#master",
87-
"template-ref": "heads/master-0-gcaed9d7",
88-
"pdk-version": "1.15.0"
87+
"template-ref": "heads/master-0-g5d52853",
88+
"pdk-version": "1.16.0"
8989
}

spec/classes/mysql_server_spec.rb

+25
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,31 @@
3434
it { is_expected.not_to contain_service('mysqld') }
3535
end
3636

37+
context 'configuration options' do
38+
context 'when specifying both $override_options and $options' do
39+
let(:params) do
40+
{
41+
override_options: { 'mysqld' => { 'datadir' => '/tmp' } },
42+
options: { 'mysqld' => { 'max_allowed_packet' => '12M' } },
43+
}
44+
end
45+
46+
it { is_expected.to compile.and_raise_error(%r{You can't specify \$options and \$override_options simultaneously, see the README section 'Customize server options'!}) }
47+
end
48+
49+
context 'when specifying $options' do
50+
let(:params) do
51+
{
52+
options: { 'mysqld' => { 'datadir' => '/tmp' } },
53+
}
54+
end
55+
56+
it { is_expected.to compile.with_all_deps }
57+
it { is_expected.to contain_mysql_datadir('/tmp') }
58+
it { is_expected.not_to contain_mysql_bind_addr('127.0.0.1') }
59+
end
60+
end
61+
3762
context 'mysql::server::install' do
3863
it 'contains the package by default' do
3964
is_expected.to contain_package('mysql-server').with(ensure: :present)

0 commit comments

Comments
 (0)