Puppet Class: galera::validate
- Defined in:
- manifests/validate.pp
Summary
Validate that the cluster can accept connections.Overview
This validation is done at the point where the ‘mysql::server` resource is marked as complete. This is used because after returning success, the service is still not quite ready.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'manifests/validate.pp', line 20
class galera::validate (
String $action,
String $catch,
Integer $delay,
Integer $retries,
Optional[String] $inv_catch,
) {
if $galera::status_check {
$validate_host = $galera::status_host
$validate_user = $galera::status_user
$validate_password = $galera::status_password
} elsif $galera::root_password =~ String {
$validate_host = 'localhost'
$validate_user = 'root'
$validate_password = $galera::root_password
}
else {
fail('Cannot validate connection without $root_password or $status_check')
}
if $catch {
$truecatch = " -v ${catch}"
} elsif $inv_catch {
$truecatch = $inv_catch
} else {
fail('No catch method specified in galera validation script')
}
$cmd = "mysql --host=${validate_host} --user=${validate_user} --password=${validate_password} -e '${action}' | grep -q ${truecatch}"
exec { 'validate_connection':
path => '/usr/bin:/bin:/usr/local/bin:/usr/sbin:/sbin:/usr/local/sbin',
provider => shell,
command => $cmd,
tries => $retries,
try_sleep => $delay,
subscribe => Service[$galera::mysql_service_name],
refreshonly => true,
}
# Ensure that the cluster was bootstrapped, then notify to trigger a validation.
Exec<| title == 'bootstrap_galera_cluster' |> ~> Exec['validate_connection']
}
|