From e7bfb689d346fa487821aae32ff0284aeb978caf Mon Sep 17 00:00:00 2001 From: Dolf Schimmel Date: Wed, 18 Dec 2013 15:17:10 +0100 Subject: [PATCH 1/4] Mariadb support --- manifests/init.pp | 28 ++++++++++++++++++++---- manifests/mariadb.pp | 52 ++++++++++++++++++++++++++++++++++++++++++++ manifests/params.pp | 5 +++++ 3 files changed, 81 insertions(+), 4 deletions(-) create mode 100644 manifests/mariadb.pp 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..5968b78 --- /dev/null +++ b/manifests/mariadb.pp @@ -0,0 +1,52 @@ +# +# [*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 +) { + + 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://mirrors.supportex.net/mariadb/repo/${minor_version}/${distro_lc}" + + apt::repository { 'mariadb': + url => $distro_url, + distro => $::lsbdistcodename, + repository => 'main', + key => '1024D/1BB943DB', + keyserver => 'keyserver.ubuntu.com', + before => Package['mysql'] + } + + if any2bool($firewall) { + firewall { 'mysql-repo-mariadb': + destination => [ 'keyserver.ubuntu.com', 'mirrors.supportex.net' ], + destination_v6 => [ 'keyserver.ubuntu.com', 'mirrors.supportex.net' ], + protocol => 'tcp', + port => 80, + direction => 'output', + } + } + + } + + 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 ? { From 65b1ed008dccfc5e369f9cb9292d5ec093612ce3 Mon Sep 17 00:00:00 2001 From: Dolf Schimmel Date: Wed, 18 Dec 2013 15:40:16 +0100 Subject: [PATCH 2/4] Making mariadb mirror configurable --- manifests/mariadb.pp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/manifests/mariadb.pp b/manifests/mariadb.pp index 5968b78..ba16507 100644 --- a/manifests/mariadb.pp +++ b/manifests/mariadb.pp @@ -7,8 +7,11 @@ # Whether or not to configure the firewall for the repo and key server # class mysql::mariadb ( - $version = $::mysql::version, - $firewall = $::mysql::bool_firewall + $version = $::mysql::version, + $firewall = $::mysql::bool_firewall, + $apt_mirror_url = 'http://mirrors.supportex.net', + $apt_key = '1024D/1BB943DB', + $apt_keyserver = 'keyserver.ubuntu.com', ) { case $::operatingsystem { @@ -21,14 +24,14 @@ } $distro_lc = inline_template("<%= scope.lookupvar('::operatingsystem').downcase %>") - $distro_url = "http://mirrors.supportex.net/mariadb/repo/${minor_version}/${distro_lc}" + $distro_url = "${apt_mirror_url}/mariadb/repo/${minor_version}/${distro_lc}" apt::repository { 'mariadb': url => $distro_url, distro => $::lsbdistcodename, repository => 'main', - key => '1024D/1BB943DB', - keyserver => 'keyserver.ubuntu.com', + key => $apt_key, + keyserver => $apt_keyserver, before => Package['mysql'] } From 0714f3df68a24f77a7bf281c37e5b6113dc0fc14 Mon Sep 17 00:00:00 2001 From: Dolf Schimmel Date: Wed, 18 Dec 2013 15:49:49 +0100 Subject: [PATCH 3/4] Order and key definition --- manifests/mariadb.pp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/manifests/mariadb.pp b/manifests/mariadb.pp index ba16507..04dbc1e 100644 --- a/manifests/mariadb.pp +++ b/manifests/mariadb.pp @@ -10,7 +10,7 @@ $version = $::mysql::version, $firewall = $::mysql::bool_firewall, $apt_mirror_url = 'http://mirrors.supportex.net', - $apt_key = '1024D/1BB943DB', + $apt_key = '1BB943DB', $apt_keyserver = 'keyserver.ubuntu.com', ) { @@ -43,6 +43,9 @@ port => 80, direction => 'output', } + + Service['iptables'] -> Apt::Key[$apt_key] + Service['iptables'] -> Apt::Repository['mariadb'] } } From 28ed73fce64dfdde7f59a93e6c6d075b3af6d936 Mon Sep 17 00:00:00 2001 From: Dolf Schimmel Date: Wed, 18 Dec 2013 15:57:48 +0100 Subject: [PATCH 4/4] Keyserver uses port 11371 --- manifests/mariadb.pp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/manifests/mariadb.pp b/manifests/mariadb.pp index 04dbc1e..4d1708f 100644 --- a/manifests/mariadb.pp +++ b/manifests/mariadb.pp @@ -9,7 +9,7 @@ class mysql::mariadb ( $version = $::mysql::version, $firewall = $::mysql::bool_firewall, - $apt_mirror_url = 'http://mirrors.supportex.net', + $apt_mirror = 'mirrors.supportex.net', $apt_key = '1BB943DB', $apt_keyserver = 'keyserver.ubuntu.com', ) { @@ -24,7 +24,7 @@ } $distro_lc = inline_template("<%= scope.lookupvar('::operatingsystem').downcase %>") - $distro_url = "${apt_mirror_url}/mariadb/repo/${minor_version}/${distro_lc}" + $distro_url = "http://${apt_mirror}/mariadb/repo/${minor_version}/${distro_lc}" apt::repository { 'mariadb': url => $distro_url, @@ -37,13 +37,21 @@ if any2bool($firewall) { firewall { 'mysql-repo-mariadb': - destination => [ 'keyserver.ubuntu.com', 'mirrors.supportex.net' ], - destination_v6 => [ 'keyserver.ubuntu.com', 'mirrors.supportex.net' ], + 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'] }