Skip to content

Commit

Permalink
Merge pull request #148 from efoft/fix35f87c9
Browse files Browse the repository at this point in the history
galera::status must be conditionally included
  • Loading branch information
fraenki authored Feb 9, 2020
2 parents 308b3f4 + 9dec5b3 commit 6f8bdf3
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions manifests/validate.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,38 @@
# This is used because after returning success,
# the service is still not quite ready.
#
# We can validate connection either with
# 1) root password if given or
# 2) status password if status_check is true
#
class galera::validate(
String $action,
String $catch,
Integer $delay,
String $host = $galera::status_host,
String $password = $galera::status_password,
Integer $retries,
String $user = $galera::status_user,
Optional[String] $inv_catch,
Optional[String] $host = undef,
Optional[String] $user = undef,
Optional[String] $password = undef,
) {
include galera::status

if $galera::root_password =~ String {
$validate_host = 'localhost'
$validate_user = 'root'
$validate_password = $galera::root_password
$validate_require = Class['mysql::server::root_password']
}
elsif $galera::status_check {
include galera::status

$validate_host = $galera::status_host
$validate_user = $galera::status_user
$validate_password = $galera::status_password
$validate_require = Class['galera::status']
}
else {
fail('Cannot validate connection without root_password or status_check')
}

if $catch {
$truecatch = $catch
Expand All @@ -27,7 +48,7 @@
fail('No catch method specified in galera validation script')
}

$cmd = "mysql --host=${host} --user=${user} --password=${password} -e '${action}'"
$cmd = "mysql --host=${validate_host} --user=${validate_user} --password=${validate_password} -e '${action}'"
exec { 'validate_connection':
path => '/usr/bin:/bin:/usr/sbin:/sbin',
provider => shell,
Expand All @@ -37,7 +58,7 @@
subscribe => Service['mysqld'],
refreshonly => true,
before => Anchor['mysql::server::end'],
require => Class['galera::status']
require => $validate_require,
}

Exec<| title == 'bootstrap_galera_cluster' |> ~> Exec['validate_connection']
Expand Down

0 comments on commit 6f8bdf3

Please sign in to comment.