From e3d74a65b07f7e3f77bd49de0ab22cabc55a27a9 Mon Sep 17 00:00:00 2001 From: Martin Magr Date: Mon, 8 Jul 2013 11:49:30 +0200 Subject: [PATCH] Use $root_home for .my.cnf --- manifests/config.pp | 4 ++-- spec/classes/mysql_config_spec.rb | 8 ++++---- spec/classes/mysql_init_spec.rb | 8 ++++---- spec/classes/mysql_java_spec.rb | 8 ++++---- spec/classes/mysql_perl_spec.rb | 8 ++++---- spec/classes/mysql_php_spec.rb | 8 ++++---- spec/classes/mysql_python_spec.rb | 8 ++++---- spec/classes/mysql_ruby_spec.rb | 8 ++++---- spec/classes/mysql_server_account_security_spec.rb | 3 ++- spec/classes/mysql_server_monitor_spec.rb | 2 +- spec/classes/mysql_server_spec.rb | 3 ++- spec/defines/mysql_server_config_spec.rb | 2 +- spec/unit/puppet/provider/database_grant/mysql_spec.rb | 2 +- 13 files changed, 37 insertions(+), 35 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index ce316d0..ccdb98f 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -183,7 +183,7 @@ class mysql::config( require => File['/etc/mysql/conf.d'], } - file { '/root/.my.cnf': + file { "${root_home}/.my.cnf": content => template('mysql/my.cnf.pass.erb'), require => Exec['set_mysql_rootpw'], notify => undef, @@ -196,7 +196,7 @@ class mysql::config( } } } else { - file { '/root/.my.cnf': + file { "${root_home}/.my.cnf": ensure => present, } } diff --git a/spec/classes/mysql_config_spec.rb b/spec/classes/mysql_config_spec.rb index ac15363..e7cfde6 100644 --- a/spec/classes/mysql_config_spec.rb +++ b/spec/classes/mysql_config_spec.rb @@ -77,7 +77,7 @@ describe 'mysql::config' do describe "when osfamily is #{osfamily}" do let :facts do - {:osfamily => osfamily} + {:osfamily => osfamily, :root_home => '/root'} end describe 'when config file should be managed' do @@ -290,7 +290,7 @@ describe 'mysql::config' do describe 'when etc_root_password is set with password' do let :facts do - {:osfamily => 'Debian'} + {:osfamily => 'Debian', :root_home => '/root'} end let :params do @@ -313,7 +313,7 @@ describe 'mysql::config' do describe 'setting etc_root_password should fail on redhat' do let :facts do - {:osfamily => 'RedHat'} + {:osfamily => 'RedHat', :root_home => '/root'} end let :params do @@ -328,7 +328,7 @@ describe 'mysql::config' do describe 'unset ssl params should fail when ssl is true on freebsd' do let :facts do - {:osfamily => 'FreeBSD'} + {:osfamily => 'FreeBSD', :root_home => '/root'} end let :params do diff --git a/spec/classes/mysql_init_spec.rb b/spec/classes/mysql_init_spec.rb index fc62cc5..e4ce308 100644 --- a/spec/classes/mysql_init_spec.rb +++ b/spec/classes/mysql_init_spec.rb @@ -4,7 +4,7 @@ describe 'mysql' do describe 'on a debian based os' do let :facts do - { :osfamily => 'Debian'} + { :osfamily => 'Debian', :root_home => '/root'} end it { should contain_package('mysql_client').with( :name => 'mysql-client', @@ -14,7 +14,7 @@ describe 'mysql' do describe 'on a freebsd based os' do let :facts do - { :osfamily => 'FreeBSD'} + { :osfamily => 'FreeBSD', :root_home => '/root'} end it { should contain_package('mysql_client').with( :name => 'databases/mysql55-client', @@ -24,7 +24,7 @@ describe 'mysql' do describe 'on a redhat based os' do let :facts do - {:osfamily => 'RedHat'} + {:osfamily => 'RedHat', :root_home => '/root'} end it { should contain_package('mysql_client').with( :name => 'mysql', @@ -43,7 +43,7 @@ describe 'mysql' do describe 'on any other os' do let :facts do - {:osfamily => 'foo'} + {:osfamily => 'foo', :root_home => '/root'} end it 'should fail' do diff --git a/spec/classes/mysql_java_spec.rb b/spec/classes/mysql_java_spec.rb index 12bbba9..428d41a 100644 --- a/spec/classes/mysql_java_spec.rb +++ b/spec/classes/mysql_java_spec.rb @@ -4,7 +4,7 @@ describe 'mysql::java' do describe 'on a debian based os' do let :facts do - { :osfamily => 'Debian'} + { :osfamily => 'Debian', :root_home => '/root'} end it { should contain_package('mysql-connector-java').with( :name => 'libmysql-java', @@ -14,7 +14,7 @@ describe 'mysql::java' do describe 'on a freebsd based os' do let :facts do - { :osfamily => 'FreeBSD'} + { :osfamily => 'FreeBSD', :root_home => '/root'} end it { should contain_package('mysql-connector-java').with( :name => 'databases/mysql-connector-java', @@ -24,7 +24,7 @@ describe 'mysql::java' do describe 'on a redhat based os' do let :facts do - {:osfamily => 'RedHat'} + {:osfamily => 'RedHat', :root_home => '/root'} end it { should contain_package('mysql-connector-java').with( :name => 'mysql-connector-java', @@ -43,7 +43,7 @@ describe 'mysql::java' do describe 'on any other os' do let :facts do - {:osfamily => 'foo'} + {:osfamily => 'foo', :root_home => '/root'} end it 'should fail' do diff --git a/spec/classes/mysql_perl_spec.rb b/spec/classes/mysql_perl_spec.rb index 34f22f6..03037a8 100644 --- a/spec/classes/mysql_perl_spec.rb +++ b/spec/classes/mysql_perl_spec.rb @@ -4,7 +4,7 @@ describe 'mysql::perl' do describe 'on a debian based os' do let :facts do - { :osfamily => 'Debian'} + { :osfamily => 'Debian', :root_home => '/root'} end it { should contain_package('perl_mysql').with( :name => 'libdbd-mysql-perl', @@ -17,7 +17,7 @@ describe 'mysql::perl' do describe 'on a freebsd based os' do let :facts do - { :osfamily => 'FreeBSD'} + { :osfamily => 'FreeBSD', :root_home => '/root'} end it { should contain_package('perl_mysql').with( :name => 'p5-DBD-mysql', @@ -28,7 +28,7 @@ describe 'mysql::perl' do describe 'on a redhat based os' do let :facts do - {:osfamily => 'Redhat'} + {:osfamily => 'Redhat', :root_home => '/root'} end it { should contain_package('perl_mysql').with( :name => 'perl-DBD-MySQL', @@ -51,7 +51,7 @@ describe 'mysql::perl' do describe 'on any other os' do let :facts do - {:osfamily => 'foo'} + {:osfamily => 'foo', :root_home => '/root'} end it 'should fail' do diff --git a/spec/classes/mysql_php_spec.rb b/spec/classes/mysql_php_spec.rb index 784ae84..2279968 100644 --- a/spec/classes/mysql_php_spec.rb +++ b/spec/classes/mysql_php_spec.rb @@ -4,7 +4,7 @@ describe 'mysql::php' do describe 'on a debian based os' do let :facts do - { :osfamily => 'Debian'} + { :osfamily => 'Debian', :root_home => '/root'} end it { should contain_package('php-mysql').with( :name => 'php5-mysql', @@ -14,7 +14,7 @@ describe 'mysql::php' do describe 'on a freebsd based os' do let :facts do - { :osfamily => 'FreeBSD'} + { :osfamily => 'FreeBSD', :root_home => '/root'} end it { should contain_package('php-mysql').with( :name => 'php5-mysql', @@ -24,7 +24,7 @@ describe 'mysql::php' do describe 'on a redhat based os' do let :facts do - {:osfamily => 'Redhat'} + {:osfamily => 'Redhat', :root_home => '/root'} end it { should contain_package('php-mysql').with( :name => 'php-mysql', @@ -43,7 +43,7 @@ describe 'mysql::php' do describe 'on any other os' do let :facts do - {:osfamily => 'foo'} + {:osfamily => 'foo', :root_home => '/root'} end it 'should fail' do diff --git a/spec/classes/mysql_python_spec.rb b/spec/classes/mysql_python_spec.rb index 8eac0a8..502e138 100644 --- a/spec/classes/mysql_python_spec.rb +++ b/spec/classes/mysql_python_spec.rb @@ -4,7 +4,7 @@ describe 'mysql::python' do describe 'on a debian based os' do let :facts do - { :osfamily => 'Debian'} + { :osfamily => 'Debian', :root_home => '/root'} end it { should contain_package('python-mysqldb').with( :name => 'python-mysqldb', @@ -14,7 +14,7 @@ describe 'mysql::python' do describe 'on a freebsd based os' do let :facts do - { :osfamily => 'FreeBSD'} + { :osfamily => 'FreeBSD', :root_home => '/root'} end it { should contain_package('python-mysqldb').with( :name => 'databases/py-MySQLdb', @@ -24,7 +24,7 @@ describe 'mysql::python' do describe 'on a redhat based os' do let :facts do - {:osfamily => 'RedHat'} + {:osfamily => 'RedHat', :root_home => '/root'} end it { should contain_package('python-mysqldb').with( :name => 'MySQL-python', @@ -43,7 +43,7 @@ describe 'mysql::python' do describe 'on any other os' do let :facts do - {:osfamily => 'foo'} + {:osfamily => 'foo', :root_home => '/root'} end it 'should fail' do diff --git a/spec/classes/mysql_ruby_spec.rb b/spec/classes/mysql_ruby_spec.rb index 3306e99..c55a757 100644 --- a/spec/classes/mysql_ruby_spec.rb +++ b/spec/classes/mysql_ruby_spec.rb @@ -4,7 +4,7 @@ describe 'mysql::ruby' do describe 'on a debian based os' do let :facts do - { :osfamily => 'Debian'} + { :osfamily => 'Debian', :root_home => '/root'} end it { should contain_package('ruby_mysql').with( :name => 'libmysql-ruby', @@ -17,7 +17,7 @@ describe 'mysql::ruby' do describe 'on a freebsd based os' do let :facts do - { :osfamily => 'FreeBSD'} + { :osfamily => 'FreeBSD', :root_home => '/root'} end it { should contain_package('ruby_mysql').with( :name => 'ruby-mysql', @@ -28,7 +28,7 @@ describe 'mysql::ruby' do describe 'on a redhat based os' do let :facts do - {:osfamily => 'RedHat'} + {:osfamily => 'RedHat', :root_home => '/root'} end it { should contain_package('ruby_mysql').with( :name => 'ruby-mysql', @@ -51,7 +51,7 @@ describe 'mysql::ruby' do describe 'on any other os' do let :facts do - {:osfamily => 'foo'} + {:osfamily => 'foo', :root_home => '/root'} end it 'should fail' do diff --git a/spec/classes/mysql_server_account_security_spec.rb b/spec/classes/mysql_server_account_security_spec.rb index 98d4bb6..10a5a5a 100644 --- a/spec/classes/mysql_server_account_security_spec.rb +++ b/spec/classes/mysql_server_account_security_spec.rb @@ -4,7 +4,8 @@ describe 'mysql::server::account_security' do let :facts do { :fqdn => 'myhost.mydomain', - :hostname => 'myhost' + :hostname => 'myhost', + :root_home => '/root' } end diff --git a/spec/classes/mysql_server_monitor_spec.rb b/spec/classes/mysql_server_monitor_spec.rb index b7591cc..e1e39f5 100644 --- a/spec/classes/mysql_server_monitor_spec.rb +++ b/spec/classes/mysql_server_monitor_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe 'mysql::server::monitor' do let :facts do - { :osfamily => 'Debian' } + { :osfamily => 'Debian', :root_home => '/root' } end let :pre_condition do "include 'mysql::server'" diff --git a/spec/classes/mysql_server_spec.rb b/spec/classes/mysql_server_spec.rb index bffabc9..cb3055b 100644 --- a/spec/classes/mysql_server_spec.rb +++ b/spec/classes/mysql_server_spec.rb @@ -13,6 +13,7 @@ describe 'mysql::server' do let :facts do { :osfamily => 'Debian', :operatingsystem => 'Ubuntu', + :root_home => '/root' } end @@ -44,7 +45,7 @@ describe 'mysql::server' do describe "when osfamily is #{osfamily}" do let :facts do - { :osfamily => osfamily } + { :osfamily => osfamily, :root_home => '/root' } end [ diff --git a/spec/defines/mysql_server_config_spec.rb b/spec/defines/mysql_server_config_spec.rb index 7d99e5b..0fd9ea4 100644 --- a/spec/defines/mysql_server_config_spec.rb +++ b/spec/defines/mysql_server_config_spec.rb @@ -4,7 +4,7 @@ describe 'mysql::server::config', :type => :define do filename = '/etc/mysql/conf.d/test_config.cnf' let :facts do - { :osfamily => 'Debian'} + { :osfamily => 'Debian', :root_home => '/root'} end let(:title) { File.basename(filename, '.cnf') } diff --git a/spec/unit/puppet/provider/database_grant/mysql_spec.rb b/spec/unit/puppet/provider/database_grant/mysql_spec.rb index 353a1ec..15d69ba 100644 --- a/spec/unit/puppet/provider/database_grant/mysql_spec.rb +++ b/spec/unit/puppet/provider/database_grant/mysql_spec.rb @@ -6,7 +6,7 @@ RSpec.configure do |config| end provider_class = Puppet::Type.type(:database_grant).provider(:mysql) describe provider_class do - let(:root_home) { '/some/root/home' } + let(:root_home) { '/root' } before :each do @resource = Puppet::Type::Database_grant.new(