Skip to content

Commit 14aef71

Browse files
authored
Merge pull request #1551 from bastelfreak/server
mysql::server: Implement reload_on_config_change
2 parents 38b258e + 85db2af commit 14aef71

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ To implement version specific parameters, specify the version, such as [mysqld-5
9999
If you don’t want to use the default configuration, you can also supply your options to the `$options` parameter instead of `$override_options`.
100100
Please note that `$options` and `$override_options` are mutually exclusive, you can only use one of them.
101101

102+
By default, the puppet won't reload/restart mysqld when you change an existing
103+
configuration. If you want to do that, you can set
104+
`mysql::server::reload_on_config_change` to true.
105+
102106
### Create a database
103107

104108
To create a database with a user and some assigned privileges:

manifests/server.pp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@
8282
# Optional hash of grants, which are passed to [mysql_grant](#mysql_grant).
8383
# @param databases
8484
# Optional hash of databases to create, which are passed to [mysql_database](#mysql_database).
85+
# @param reload_on_config_change
86+
# By default, a my.cnf change won't reload/restart the database. Turn this flag to true to enable it
8587
# @param enabled
8688
# _Deprecated_
8789
# @param manage_service
@@ -123,6 +125,7 @@
123125
Hash $users = {},
124126
Hash $grants = {},
125127
Hash $databases = {},
128+
Boolean $reload_on_config_change = false,
126129
# Deprecated parameters
127130
Optional[Variant[String[1], Boolean]] $enabled = undef,
128131
Optional[Variant[String[1], Boolean]] $manage_service = undef,

manifests/server/service.pp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@
4242
# only establish ordering between config file and service if
4343
# we're managing the config file.
4444
if $mysql::server::manage_config_file {
45-
File['mysql-config-file'] -> Service['mysqld']
45+
if $mysql::server::reload_on_config_change {
46+
File['mysql-config-file'] ~> Service['mysqld']
47+
} else {
48+
File['mysql-config-file'] -> Service['mysqld']
49+
}
4650
}
4751

4852
if $mysql::server::override_options and $mysql::server::override_options['mysqld']

spec/classes/mysql_server_spec.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
it { is_expected.to contain_class('mysql::server::service') }
1616
it { is_expected.to contain_class('mysql::server::root_password') }
1717
it { is_expected.to contain_class('mysql::server::providers') }
18+
it { is_expected.to contain_file('mysql-config-file').that_comes_before('Service[mysqld]') }
19+
it { is_expected.not_to contain_file('mysql-config-file').that_notifies('Service[mysqld]') }
1820
end
1921

2022
context 'with remove_default_accounts set' do
@@ -152,6 +154,11 @@
152154

153155
it { is_expected.to contain_file('mysql-config-file').without_content(%r{^bind-address}) }
154156
end
157+
context 'with reload_on_config_change' do
158+
let(:params) { { 'reload_on_config_change' => true } }
159+
160+
it { is_expected.to contain_file('mysql-config-file').that_notifies('Service[mysqld]') }
161+
end
155162
end
156163

157164
context 'mysql::server::root_password' do

0 commit comments

Comments
 (0)