diff --git a/README.md b/README.md index 61c85aa63..8a681d960 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/manifests/server.pp b/manifests/server.pp index 7f9d7d7f8..e15d0a426 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -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 @@ -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, diff --git a/manifests/server/service.pp b/manifests/server/service.pp index 51da0a7ac..d15c05094 100644 --- a/manifests/server/service.pp +++ b/manifests/server/service.pp @@ -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'] diff --git a/spec/classes/mysql_server_spec.rb b/spec/classes/mysql_server_spec.rb index 7c8e54efb..6d7c93985 100644 --- a/spec/classes/mysql_server_spec.rb +++ b/spec/classes/mysql_server_spec.rb @@ -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 @@ -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