diff --git a/manifests/init.pp b/manifests/init.pp index 14d351d..a4cca05 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -203,6 +203,12 @@ # This is used by monitor, firewall and puppi (optional) components # Can be defined also by the (top scope) variable $mysql_protocol # +# [*install_mariadb*] +# Bool (default false). Not all distro's ship mariadb by default yet. +# Setting this directive to true forces the installation of mariadb. +# +# [*mariadb_package*] +# If mariadb is to be installed what package name to use. # # == Examples # @@ -258,7 +264,9 @@ $log_dir = params_lookup( 'log_dir' ), $log_file = params_lookup( 'log_file' ), $port = params_lookup( 'port' ), - $protocol = params_lookup( 'protocol' ) + $protocol = params_lookup( 'protocol' ), + $install_mariadb = params_lookup( 'install_mariadb' ), + $mariadb_package = params_lookup( 'mariadb_package' ), ) inherits mysql::params { $bool_source_dir_purge=any2bool($source_dir_purge) @@ -270,6 +278,7 @@ $bool_puppi=any2bool($puppi) $bool_firewall=any2bool($firewall) $bool_debug=any2bool($debug) + $bool_install_mariadb=any2bool($install_mariadb) $bool_audit_only=any2bool($audit_only) ### Root password setup @@ -354,9 +363,20 @@ if $mysql::real_root_password != '' { include mysql::password } ### Managed resources - package { 'mysql': - ensure => $mysql::manage_package, - name => $mysql::package, + if $bool_install_mariadb { + + include ::mysql::mariadb + + package { 'mysql': + ensure => $mysql::manage_package, + name => $mysql::mariadb_package, + } + + } else { + package { 'mysql': + ensure => $mysql::manage_package, + name => $mysql::package, + } } if $mysql::bool_absent == false { diff --git a/manifests/mariadb.pp b/manifests/mariadb.pp new file mode 100644 index 0000000..4d1708f --- /dev/null +++ b/manifests/mariadb.pp @@ -0,0 +1,66 @@ +# +# [*version*] +# The minor version (X.Y) to install. Defaults to one of the +# latest if none is specified (this may be changed without notice). +# +# [*firewall*] +# Whether or not to configure the firewall for the repo and key server +# +class mysql::mariadb ( + $version = $::mysql::version, + $firewall = $::mysql::bool_firewall, + $apt_mirror = 'mirrors.supportex.net', + $apt_key = '1BB943DB', + $apt_keyserver = 'keyserver.ubuntu.com', +) { + + case $::operatingsystem { + /^(Debian|Ubuntu|Mint)$/: { + + if ( ( $version == '' ) or ( $version == undef ) ) { + $minor_version = '10.0' + } else { + $minor_version = inline_template('<%=@version.to_s.match(/\d+.\d+/)[0] %>') + } + + $distro_lc = inline_template("<%= scope.lookupvar('::operatingsystem').downcase %>") + $distro_url = "http://${apt_mirror}/mariadb/repo/${minor_version}/${distro_lc}" + + apt::repository { 'mariadb': + url => $distro_url, + distro => $::lsbdistcodename, + repository => 'main', + key => $apt_key, + keyserver => $apt_keyserver, + before => Package['mysql'] + } + + if any2bool($firewall) { + firewall { 'mysql-repo-mariadb': + destination => $apt_mirror, + destination_v6 => $apt_mirror, + protocol => 'tcp', + port => 80, + direction => 'output', + } + + firewall { 'mysql-repo-mariadb-keyserver': + destination => $apt_keyserver, + destination_v6 => $apt_keyserver, + protocol => 'tcp', + port => 11371, + direction => 'output', + } + + Service['iptables'] -> Apt::Key[$apt_key] + Service['iptables'] -> Apt::Repository['mariadb'] + } + + } + + default: { + fail('mysql::mariadb currently only supports debian-based systems') + } + + } +} diff --git a/manifests/params.pp b/manifests/params.pp index 5b71444..a461dd9 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -18,6 +18,11 @@ $root_password = '' $password_salt = '' + $install_mariadb = false + $mariadb_package = $::operatingsystem ? { + default => 'mariadb-server', + } + ### Application related parameters $package = $::operatingsystem ? {