(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:
juniorsysadmin 2014-12-07 19:23:18 +11:00
parent b64ca51cfb
commit f5a693b826
8 changed files with 70 additions and 30 deletions

View file

@ -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'.
#####`package_manage`
Whether to manage the mysql server package. Defaults to true.
#####`package_name`
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'.
#####`package_manage`
Whether to manage the mysql client package. Defaults to true.
#####`package_name`
What is the name of the mysql client package to install.

View file

@ -3,6 +3,7 @@ class mysql::client (
$bindings_enable = $mysql::params::bindings_enable,
$install_options = undef,
$package_ensure = $mysql::params::client_package_ensure,
$package_manage = $mysql::params::client_package_manage,
$package_name = $mysql::params::client_package_name,
) inherits mysql::params {

View file

@ -1,5 +1,7 @@
class mysql::client::install {
if $mysql::client::package_manage {
package { 'mysql_client':
ensure => $mysql::client::package_ensure,
install_options => $mysql::client::install_options,
@ -7,3 +9,5 @@ class mysql::client::install {
}
}
}

View file

@ -7,9 +7,11 @@ class mysql::params {
$restart = false
$root_password = 'UNSET'
$server_package_ensure = 'present'
$server_package_manage = true
$server_service_manage = true
$server_service_enabled = true
$client_package_ensure = 'present'
$client_package_manage = true
$create_root_user = true
$create_root_my_cnf = true
# mysql::bindings

View file

@ -7,6 +7,7 @@ class mysql::server (
$old_root_password = $mysql::params::old_root_password,
$override_options = {},
$package_ensure = $mysql::params::server_package_ensure,
$package_manage = $mysql::params::server_package_manage,
$package_name = $mysql::params::server_package_name,
$purge_conf_dir = $mysql::params::purge_conf_dir,
$remove_default_accounts = false,

View file

@ -1,6 +1,8 @@
#
class mysql::server::install {
if $mysql::server::package_manage {
package { 'mysql-server':
ensure => $mysql::server::package_ensure,
install_options => $mysql::server::install_options,
@ -32,5 +34,6 @@ class mysql::server::install {
notify => Class['mysql::server::service'],
}
}
}
}

View file

@ -17,6 +17,19 @@ describe 'mysql::client' do
it { is_expected.to contain_class('mysql::bindings') }
it { is_expected.to contain_package('mysql_client') }
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

View file

@ -20,11 +20,19 @@ describe 'mysql::server' do
end
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({
:ensure => :present,
})
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
let(:params) {{ :override_options => { 'mysqld' => { 'datadir' => '/tmp' }} }}
it { is_expected.to contain_exec('mysql_install_db') }