diff --git a/manifests/server/root_password.pp b/manifests/server/root_password.pp index d7e031442..845857056 100644 --- a/manifests/server/root_password.pp +++ b/manifests/server/root_password.pp @@ -16,7 +16,9 @@ content => template('mysql/my.cnf.pass.erb'), owner => 'root', mode => '0600', - require => Mysql_user['root@localhost'], + } + if $mysql::server::create_root_user == true { + Mysql_user['root@localhost'] -> File["${::root_home}/.my.cnf"] } } diff --git a/spec/classes/mysql_server_spec.rb b/spec/classes/mysql_server_spec.rb index 2058e5f89..ce29550e7 100644 --- a/spec/classes/mysql_server_spec.rb +++ b/spec/classes/mysql_server_spec.rb @@ -55,7 +55,7 @@ describe 'when root_password set' do let(:params) {{:root_password => 'SET' }} it { is_expected.to contain_mysql_user('root@localhost') } - it { is_expected.to contain_file('/root/.my.cnf') } + it { is_expected.to contain_file('/root/.my.cnf').that_requires('Mysql_user[root@localhost]') } end describe 'when root_password set, create_root_user set to false' do let(:params) {{ :root_password => 'SET', :create_root_user => false }}