diff --git a/manifests/server/service.pp b/manifests/server/service.pp index 92686d9..81e028e 100644 --- a/manifests/server/service.pp +++ b/manifests/server/service.pp @@ -31,7 +31,14 @@ class mysql::server::service { name => $mysql::server::service_name, enable => $mysql::server::real_service_enabled, provider => $mysql::server::service_provider, - 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::package_name], + } } # only establish ordering between config file and service if diff --git a/spec/classes/mysql_server_spec.rb b/spec/classes/mysql_server_spec.rb index bc36fe0..6bb54d2 100644 --- a/spec/classes/mysql_server_spec.rb +++ b/spec/classes/mysql_server_spec.rb @@ -43,7 +43,15 @@ describe 'mysql::server' 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 }}