Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mysql::server: Implement reload_on_config_change #1551

Merged
merged 1 commit into from Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -99,6 +99,10 @@ To implement version specific parameters, specify the version, such as [mysqld-5
If you don’t want to use the default configuration, you can also supply your options to the `$options` parameter instead of `$override_options`.
Please note that `$options` and `$override_options` are mutually exclusive, you can only use one of them.

By default, the puppet won't reload/restart mysqld when you change an existing
configuration. If you want to do that, you can set
`mysql::server::reload_on_config_change` to true.

### Create a database

To create a database with a user and some assigned privileges:
Expand Down
3 changes: 3 additions & 0 deletions manifests/server.pp
Expand Up @@ -82,6 +82,8 @@
# Optional hash of grants, which are passed to [mysql_grant](#mysql_grant).
# @param databases
# Optional hash of databases to create, which are passed to [mysql_database](#mysql_database).
# @param reload_on_config_change
# By default, a my.cnf change won't reload/restart the database. Turn this flag to true to enable it
# @param enabled
# _Deprecated_
# @param manage_service
Expand Down Expand Up @@ -123,6 +125,7 @@
Hash $users = {},
Hash $grants = {},
Hash $databases = {},
Boolean $reload_on_config_change = false,
# Deprecated parameters
Optional[Variant[String[1], Boolean]] $enabled = undef,
Optional[Variant[String[1], Boolean]] $manage_service = undef,
Expand Down
6 changes: 5 additions & 1 deletion manifests/server/service.pp
Expand Up @@ -42,7 +42,11 @@
# 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::reload_on_config_change {
File['mysql-config-file'] ~> Service['mysqld']
} else {
File['mysql-config-file'] -> Service['mysqld']
}
}

if $mysql::server::override_options and $mysql::server::override_options['mysqld']
Expand Down
7 changes: 7 additions & 0 deletions spec/classes/mysql_server_spec.rb
Expand Up @@ -15,6 +15,8 @@
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_file('mysql-config-file').that_comes_before('Service[mysqld]') }
it { is_expected.not_to contain_file('mysql-config-file').that_notifies('Service[mysqld]') }
end

context 'with remove_default_accounts set' do
Expand Down Expand Up @@ -152,6 +154,11 @@

it { is_expected.to contain_file('mysql-config-file').without_content(%r{^bind-address}) }
end
context 'with reload_on_config_change' do
let(:params) { { 'reload_on_config_change' => true } }

it { is_expected.to contain_file('mysql-config-file').that_notifies('Service[mysqld]') }
end
end

context 'mysql::server::root_password' do
Expand Down