(MODULES-1143) Add package_manage parameter
This patch adds a package_manage parameter for both mysql::server and mysql::client
This commit is contained in:
parent
b64ca51cfb
commit
f5a693b826
8 changed files with 70 additions and 30 deletions
|
@ -217,6 +217,10 @@ What is the group used for root?
|
||||||
|
|
||||||
What to set the package to. Can be 'present', 'absent', or 'x.y.z'.
|
What to set the package to. Can be 'present', 'absent', or 'x.y.z'.
|
||||||
|
|
||||||
|
#####`package_manage`
|
||||||
|
|
||||||
|
Whether to manage the mysql server package. Defaults to true.
|
||||||
|
|
||||||
#####`package_name`
|
#####`package_name`
|
||||||
|
|
||||||
The name of the mysql server package to install.
|
The name of the mysql server package to install.
|
||||||
|
@ -471,6 +475,10 @@ Pass install_options array to managed package resources. You must be sure to pas
|
||||||
|
|
||||||
What to set the package to. Can be 'present', 'absent', or 'x.y.z'.
|
What to set the package to. Can be 'present', 'absent', or 'x.y.z'.
|
||||||
|
|
||||||
|
#####`package_manage`
|
||||||
|
|
||||||
|
Whether to manage the mysql client package. Defaults to true.
|
||||||
|
|
||||||
#####`package_name`
|
#####`package_name`
|
||||||
|
|
||||||
What is the name of the mysql client package to install.
|
What is the name of the mysql client package to install.
|
||||||
|
|
|
@ -3,6 +3,7 @@ class mysql::client (
|
||||||
$bindings_enable = $mysql::params::bindings_enable,
|
$bindings_enable = $mysql::params::bindings_enable,
|
||||||
$install_options = undef,
|
$install_options = undef,
|
||||||
$package_ensure = $mysql::params::client_package_ensure,
|
$package_ensure = $mysql::params::client_package_ensure,
|
||||||
|
$package_manage = $mysql::params::client_package_manage,
|
||||||
$package_name = $mysql::params::client_package_name,
|
$package_name = $mysql::params::client_package_name,
|
||||||
) inherits mysql::params {
|
) inherits mysql::params {
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
class mysql::client::install {
|
class mysql::client::install {
|
||||||
|
|
||||||
package { 'mysql_client':
|
if $mysql::client::package_manage {
|
||||||
ensure => $mysql::client::package_ensure,
|
|
||||||
install_options => $mysql::client::install_options,
|
package { 'mysql_client':
|
||||||
name => $mysql::client::package_name,
|
ensure => $mysql::client::package_ensure,
|
||||||
|
install_options => $mysql::client::install_options,
|
||||||
|
name => $mysql::client::package_name,
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,9 +7,11 @@ class mysql::params {
|
||||||
$restart = false
|
$restart = false
|
||||||
$root_password = 'UNSET'
|
$root_password = 'UNSET'
|
||||||
$server_package_ensure = 'present'
|
$server_package_ensure = 'present'
|
||||||
|
$server_package_manage = true
|
||||||
$server_service_manage = true
|
$server_service_manage = true
|
||||||
$server_service_enabled = true
|
$server_service_enabled = true
|
||||||
$client_package_ensure = 'present'
|
$client_package_ensure = 'present'
|
||||||
|
$client_package_manage = true
|
||||||
$create_root_user = true
|
$create_root_user = true
|
||||||
$create_root_my_cnf = true
|
$create_root_my_cnf = true
|
||||||
# mysql::bindings
|
# mysql::bindings
|
||||||
|
|
|
@ -7,6 +7,7 @@ class mysql::server (
|
||||||
$old_root_password = $mysql::params::old_root_password,
|
$old_root_password = $mysql::params::old_root_password,
|
||||||
$override_options = {},
|
$override_options = {},
|
||||||
$package_ensure = $mysql::params::server_package_ensure,
|
$package_ensure = $mysql::params::server_package_ensure,
|
||||||
|
$package_manage = $mysql::params::server_package_manage,
|
||||||
$package_name = $mysql::params::server_package_name,
|
$package_name = $mysql::params::server_package_name,
|
||||||
$purge_conf_dir = $mysql::params::purge_conf_dir,
|
$purge_conf_dir = $mysql::params::purge_conf_dir,
|
||||||
$remove_default_accounts = false,
|
$remove_default_accounts = false,
|
||||||
|
|
|
@ -1,35 +1,38 @@
|
||||||
#
|
#
|
||||||
class mysql::server::install {
|
class mysql::server::install {
|
||||||
|
|
||||||
package { 'mysql-server':
|
if $mysql::server::package_manage {
|
||||||
ensure => $mysql::server::package_ensure,
|
|
||||||
install_options => $mysql::server::install_options,
|
|
||||||
name => $mysql::server::package_name,
|
|
||||||
}
|
|
||||||
|
|
||||||
# Build the initial databases.
|
package { 'mysql-server':
|
||||||
$mysqluser = $mysql::server::options['mysqld']['user']
|
ensure => $mysql::server::package_ensure,
|
||||||
$datadir = $mysql::server::options['mysqld']['datadir']
|
install_options => $mysql::server::install_options,
|
||||||
$basedir = $mysql::server::options['mysqld']['basedir']
|
name => $mysql::server::package_name,
|
||||||
$config_file = $mysql::server::config_file
|
}
|
||||||
|
|
||||||
if $mysql::server::manage_config_file {
|
# Build the initial databases.
|
||||||
$install_db_args = "--basedir=${basedir} --defaults-extra-file=${config_file} --datadir=${datadir} --user=${mysqluser}"
|
$mysqluser = $mysql::server::options['mysqld']['user']
|
||||||
} else {
|
$datadir = $mysql::server::options['mysqld']['datadir']
|
||||||
$install_db_args = "--basedir=${basedir} --datadir=${datadir} --user=${mysqluser}"
|
$basedir = $mysql::server::options['mysqld']['basedir']
|
||||||
}
|
$config_file = $mysql::server::config_file
|
||||||
|
|
||||||
exec { 'mysql_install_db':
|
if $mysql::server::manage_config_file {
|
||||||
command => "mysql_install_db ${install_db_args}",
|
$install_db_args = "--basedir=${basedir} --defaults-extra-file=${config_file} --datadir=${datadir} --user=${mysqluser}"
|
||||||
creates => "${datadir}/mysql",
|
} else {
|
||||||
logoutput => on_failure,
|
$install_db_args = "--basedir=${basedir} --datadir=${datadir} --user=${mysqluser}"
|
||||||
path => '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin',
|
}
|
||||||
require => Package['mysql-server'],
|
|
||||||
}
|
|
||||||
|
|
||||||
if $mysql::server::restart {
|
exec { 'mysql_install_db':
|
||||||
Exec['mysql_install_db'] {
|
command => "mysql_install_db ${install_db_args}",
|
||||||
notify => Class['mysql::server::service'],
|
creates => "${datadir}/mysql",
|
||||||
|
logoutput => on_failure,
|
||||||
|
path => '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin',
|
||||||
|
require => Package['mysql-server'],
|
||||||
|
}
|
||||||
|
|
||||||
|
if $mysql::server::restart {
|
||||||
|
Exec['mysql_install_db'] {
|
||||||
|
notify => Class['mysql::server::service'],
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,19 @@ describe 'mysql::client' do
|
||||||
it { is_expected.to contain_class('mysql::bindings') }
|
it { is_expected.to contain_class('mysql::bindings') }
|
||||||
it { is_expected.to contain_package('mysql_client') }
|
it { is_expected.to contain_package('mysql_client') }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'with package_manage set to true' do
|
||||||
|
let(:params) {{ :package_manage => true }}
|
||||||
|
|
||||||
|
it { is_expected.to contain_package('mysql_client') }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with package_manage set to false' do
|
||||||
|
let(:params) {{ :package_manage => false }}
|
||||||
|
|
||||||
|
it { is_expected.not_to contain_package('mysql_client') }
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,11 +20,19 @@ describe 'mysql::server' do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'mysql::server::install' do
|
context 'mysql::server::install' do
|
||||||
it 'contains the package' do
|
it 'contains the package by default' do
|
||||||
is_expected.to contain_package('mysql-server').with({
|
is_expected.to contain_package('mysql-server').with({
|
||||||
:ensure => :present,
|
:ensure => :present,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
context 'with package_manage set to true' do
|
||||||
|
let(:params) {{ :package_manage => true }}
|
||||||
|
it { is_expected.to contain_package('mysql-server') }
|
||||||
|
end
|
||||||
|
context 'with package_manage set to false' do
|
||||||
|
let(:params) {{ :package_manage => false }}
|
||||||
|
it { is_expected.not_to contain_package('mysql-server') }
|
||||||
|
end
|
||||||
context 'with datadir overridden' do
|
context 'with datadir overridden' do
|
||||||
let(:params) {{ :override_options => { 'mysqld' => { 'datadir' => '/tmp' }} }}
|
let(:params) {{ :override_options => { 'mysqld' => { 'datadir' => '/tmp' }} }}
|
||||||
it { is_expected.to contain_exec('mysql_install_db') }
|
it { is_expected.to contain_exec('mysql_install_db') }
|
||||||
|
|
Loading…
Reference in a new issue