Permalink
Browse files

Merge pull request #78 from branan/merge_freebsd

Add freebsd support.
  • Loading branch information...
2 parents ece11c5 + f572b90 commit d66607d21aae44afdfc8ef8da086be5411918f33 @nanliu nanliu committed May 31, 2012
View
@@ -44,16 +44,29 @@
$ssl_cert = $mysql::params::ssl_cert,
$ssl_key = $mysql::params::ssl_key,
$log_error = $mysql::params::log_error,
- $default_engine = 'UNSET'
+ $default_engine = 'UNSET',
+ $root_group = $mysql::params::root_group
) inherits mysql::params {
File {
owner => 'root',
- group => 'root',
+ group => $root_group,
mode => '0400',
notify => Exec['mysqld-restart'],
}
+ if $ssl and $ssl_ca == undef {
+ fail('The ssl_ca parameter is required when ssl is true')
+ }
+
+ if $ssl and $ssl_cert == undef {
+ fail('The ssl_cert parameter is required when ssl is true')
+ }
+
+ if $ssl and $ssl_key == undef {
+ fail('The ssl_key parameter is required when ssl is true')
+ }
+
# This kind of sucks, that I have to specify a difference resource for
# restart. the reason is that I need the service to be started before mods
# to the config file which can cause a refresh
@@ -75,7 +88,7 @@
command => "mysqladmin -u root ${old_pw} password ${root_password}",
logoutput => true,
unless => "mysqladmin -u root -p${root_password} status > /dev/null",
- path => '/usr/local/sbin:/usr/bin',
+ path => '/usr/local/sbin:/usr/bin:/usr/local/bin',
notify => Exec['mysqld-restart'],
require => File['/etc/mysql/conf.d'],
}
View
@@ -14,13 +14,8 @@
$bind_address = '127.0.0.1'
$port = 3306
- $server_package_name = 'mysql-server'
$etc_root_password = false
- $datadir = '/var/lib/mysql'
$ssl = false
- $ssl_ca = '/etc/mysql/cacert.pem'
- $ssl_cert = '/etc/mysql/server-cert.pem'
- $ssl_key = '/etc/mysql/server-key.pem'
case $::operatingsystem {
"Ubuntu": {
@@ -33,30 +28,63 @@
case $::osfamily {
'RedHat': {
+ $basedir = '/usr'
+ $datadir = '/var/lib/mysql'
$service_name = 'mysqld'
$client_package_name = 'mysql'
+ $server_package_name = 'mysql-server'
$socket = '/var/lib/mysql/mysql.sock'
$config_file = '/etc/my.cnf'
$log_error = '/var/log/mysqld.log'
$ruby_package_name = 'ruby-mysql'
$ruby_package_provider = 'gem'
$python_package_name = 'MySQL-python'
$java_package_name = 'mysql-connector-java'
+ $root_group = 'root'
+ $ssl_ca = '/etc/mysql/cacert.pem'
+ $ssl_cert = '/etc/mysql/server-cert.pem'
+ $ssl_key = '/etc/mysql/server-key.pem'
}
'Debian': {
+ $basedir = '/usr'
+ $datadir = '/var/lib/mysql'
$service_name = 'mysql'
$client_package_name = 'mysql-client'
+ $server_package_name = 'mysql-server'
$socket = '/var/run/mysqld/mysqld.sock'
$config_file = '/etc/mysql/my.cnf'
$log_error = '/var/log/mysql/error.log'
$ruby_package_name = 'libmysql-ruby'
$python_package_name = 'python-mysqldb'
$java_package_name = 'libmysql-java'
+ $root_group = 'root'
+ $ssl_ca = '/etc/mysql/cacert.pem'
+ $ssl_cert = '/etc/mysql/server-cert.pem'
+ $ssl_key = '/etc/mysql/server-key.pem'
+ }
+
+ 'FreeBSD': {
+ $basedir = '/usr/local'
+ $datadir = '/var/db/mysql'
+ $service_name = 'mysql-server'
+ $client_package_name = 'databases/mysql55-client'
+ $server_package_name = 'databases/mysql55-server'
+ $socket = '/tmp/mysql.sock'
+ $config_file = '/var/db/mysql/my.cnf'
+ $log_error = "/var/db/mysql/${::hostname}.err"
+ $ruby_package_name = 'ruby-mysql'
+ $ruby_package_provider = 'gem'
+ $python_package_name = 'databases/py-MySQLdb'
+ $java_package_name = 'databases/mysql-connector-java'
+ $root_group = 'wheel'
+ $ssl_ca = undef
+ $ssl_cert = undef
+ $ssl_key = undef
}
default: {
- fail("Unsupported osfamily: ${::osfamily} operatingsystem: ${::operatingsystem}, module ${module_name} only support osfamily RedHat and Debian")
+ fail("Unsupported osfamily: ${::osfamily} operatingsystem: ${::operatingsystem}, module ${module_name} only support osfamily RedHat Debian and FreeBSD")
}
}
@@ -11,23 +11,37 @@
:datadir => '/var/lib/mysql',
:default_engine => 'UNSET',
:ssl => false,
- :ssl_ca => '/etc/mysql/cacert.pem',
- :ssl_cert => '/etc/mysql/server-cert.pem',
- :ssl_key => '/etc/mysql/server-key.pem'
}
end
describe 'with osfamily specific defaults' do
{
'Debian' => {
+ :datadir => '/var/lib/mysql',
:service_name => 'mysql',
:config_file => '/etc/mysql/my.cnf',
- :socket => '/var/run/mysqld/mysqld.sock'
+ :socket => '/var/run/mysqld/mysqld.sock',
+ :root_group => 'root',
+ :ssl_ca => '/etc/mysql/cacert.pem',
+ :ssl_cert => '/etc/mysql/server-cert.pem',
+ :ssl_key => '/etc/mysql/server-key.pem'
+ },
+ 'FreeBSD' => {
+ :datadir => '/var/db/mysql',
+ :service_name => 'mysql-server',
+ :config_file => '/var/db/mysql/my.cnf',
+ :socket => '/tmp/mysql.sock',
+ :root_group => 'wheel',
},
'Redhat' => {
+ :datadir => '/var/lib/mysql',
:service_name => 'mysqld',
:config_file => '/etc/my.cnf',
- :socket => '/var/lib/mysql/mysql.sock'
+ :socket => '/var/lib/mysql/mysql.sock',
+ :root_group => 'root',
+ :ssl_ca => '/etc/mysql/cacert.pem',
+ :ssl_cert => '/etc/mysql/server-cert.pem',
+ :ssl_key => '/etc/mysql/server-key.pem'
}
}.each do |osfamily, osparams|
@@ -48,7 +62,7 @@
'command' => 'mysqladmin -u root password foo',
'logoutput' => true,
'unless' => "mysqladmin -u root -pfoo status > /dev/null",
- 'path' => '/usr/local/sbin:/usr/bin'
+ 'path' => '/usr/local/sbin:/usr/bin:/usr/local/bin'
)}
it { should contain_file('/root/.my.cnf').with(
@@ -67,7 +81,7 @@
'command' => 'mysqladmin -u root -pbar password foo',
'logoutput' => true,
'unless' => "mysqladmin -u root -pfoo status > /dev/null",
- 'path' => '/usr/local/sbin:/usr/bin'
+ 'path' => '/usr/local/sbin:/usr/bin:/usr/local/bin'
)}
end
@@ -116,21 +130,21 @@
it { should contain_file('/etc/mysql').with(
'owner' => 'root',
- 'group' => 'root',
+ 'group' => param_values[:root_group],
'notify' => 'Exec[mysqld-restart]',
'ensure' => 'directory',
'mode' => '0755'
)}
it { should contain_file('/etc/mysql/conf.d').with(
'owner' => 'root',
- 'group' => 'root',
+ 'group' => param_values[:root_group],
'notify' => 'Exec[mysqld-restart]',
'ensure' => 'directory',
'mode' => '0755'
)}
it { should contain_file(param_values[:config_file]).with(
'owner' => 'root',
- 'group' => 'root',
+ 'group' => param_values[:root_group],
'notify' => 'Exec[mysqld-restart]',
'mode' => '0644'
)}
@@ -175,7 +189,7 @@
'command' => 'mysqladmin -u root -pbar password foo',
'logoutput' => true,
'unless' => "mysqladmin -u root -pfoo status > /dev/null",
- 'path' => '/usr/local/sbin:/usr/bin'
+ 'path' => '/usr/local/sbin:/usr/bin:/usr/local/bin'
)}
it { should contain_file('/root/.my.cnf').with(
@@ -202,4 +216,21 @@
end
+ describe 'unset ssl params should fail when ssl is true on freebsd' do
+ let :facts do
+ {:osfamily => 'FreeBSD'}
+ end
+
+ let :params do
+ { :ssl => true }
+ end
+
+ it 'should fail' do
+ expect do
+ subject
+ end.should raise_error(Puppet::Error, /required when ssl is true/)
+ end
+
+ end
+
end
@@ -12,6 +12,16 @@
)}
end
+ describe 'on a freebsd based os' do
+ let :facts do
+ { :osfamily => 'FreeBSD'}
+ end
+ it { should contain_package('mysql_client').with(
+ :name => 'databases/mysql55-client',
+ :ensure => 'present'
+ )}
+ end
+
describe 'on a redhat based os' do
let :facts do
{:osfamily => 'Redhat'}
@@ -12,6 +12,16 @@
)}
end
+ describe 'on a freebsd based os' do
+ let :facts do
+ { :osfamily => 'FreeBSD'}
+ end
+ it { should contain_package('mysql-connector-java').with(
+ :name => 'databases/mysql-connector-java',
+ :ensure => 'present'
+ )}
+ end
+
describe 'on a redhat based os' do
let :facts do
{:osfamily => 'Redhat'}
@@ -12,6 +12,16 @@
)}
end
+ describe 'on a freebsd based os' do
+ let :facts do
+ { :osfamily => 'FreeBSD'}
+ end
+ it { should contain_package('python-mysqldb').with(
+ :name => 'databases/py-MySQLdb',
+ :ensure => 'present'
+ )}
+ end
+
describe 'on a redhat based os' do
let :facts do
{:osfamily => 'Redhat'}
@@ -15,6 +15,17 @@
)}
end
+ describe 'on a freebsd based os' do
+ let :facts do
+ { :osfamily => 'FreeBSD'}
+ end
+ it { should contain_package('ruby_mysql').with(
+ :name => 'ruby-mysql',
+ :ensure => 'present',
+ :provider => 'gem'
+ )}
+ end
+
describe 'on a redhat based os' do
let :facts do
{:osfamily => 'Redhat'}
@@ -4,7 +4,6 @@
let :constant_parameter_defaults do
{:config_hash => {},
:package_ensure => 'present',
- :package_name => 'mysql-server'
}
end
@@ -27,10 +26,16 @@
describe 'with osfamily specific defaults' do
{
'Debian' => {
- :service_name => 'mysql'
+ :service_name => 'mysql',
+ :package_name => 'mysql-server'
+ },
+ 'FreeBSD' => {
+ :service_name => 'mysql-server',
+ :package_name => 'databases/mysql55-server'
},
'Redhat' => {
- :service_name => 'mysqld'
+ :service_name => 'mysqld',
+ :package_name => 'mysql-server'
}
}.each do |osfamily, osparams|
View
@@ -8,7 +8,7 @@ nice = 0
user = mysql
socket = <%= socket %>
port = <%= port %>
-basedir = /usr
+basedir = <%= basedir %>
datadir = <%= datadir %>
tmpdir = /tmp
skip-external-locking

0 comments on commit d66607d

Please sign in to comment.