diff --git a/lib/facter/galera_bootstrapped.rb b/lib/facter/galera_bootstrapped.rb new file mode 100644 index 00000000..6a786304 --- /dev/null +++ b/lib/facter/galera_bootstrapped.rb @@ -0,0 +1,22 @@ +# +# Copyright (C) 2014 eNovance SAS +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# Fact: galera_bootstrapped +# +Facter.add('galera_bootstrapped') do + setcode do + FileTest.exists?('/var/lib/mysql/grastate.dat') + end +end diff --git a/manifests/database/sql/mysql.pp b/manifests/database/sql/mysql.pp index b0140fec..29517de5 100644 --- a/manifests/database/sql/mysql.pp +++ b/manifests/database/sql/mysql.pp @@ -339,6 +339,11 @@ class cloud::database::sql::mysql ( if $::hostname == $galera_master_name { $mysql_service_name = 'mysql-bootstrap' + if !str2bool($::galera_bootstrapped) { + $wsrep_new_cluster = '--wsrep-new-cluster' + } else { + $wsrep_new_cluster = '' + } } else { $mysql_service_name = 'mariadb' } @@ -424,12 +429,17 @@ class cloud::database::sql::mysql ( # To check that the mysqld support the options you can : # strings `which mysqld` | grep wsrep-new-cluster # TODO: to be remove as soon as the API 25 is packaged, ie galera 3 ... + if $::osfamily == 'RedHat' and $::operatingsystemmajrelease >= 7 { + $mysql_service_notify = Exec['mariadb-sysctl-daemon-reload'] + } else { + $mysql_service_notify = Service['mysqld'] + } file { $mysql_init_file : content => template("cloud/database/etc_initd_mysql_${::osfamily}"), owner => 'root', mode => '0755', group => 'root', - notify => Service['mysqld'], + notify => $mysql_service_notify, before => Package[$mysql_server_package_name], } diff --git a/templates/database/etc_initd_mysql_RedHat b/templates/database/etc_initd_mysql_RedHat index ec2a168a..79a8b36e 100755 --- a/templates/database/etc_initd_mysql_RedHat +++ b/templates/database/etc_initd_mysql_RedHat @@ -32,7 +32,7 @@ Group=mysql ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n # Note: we set --basedir to prevent probes that might trigger SELinux alarms, # per bug #547485 -ExecStart=/usr/bin/mysqld_safe --wsrep-new-cluster --basedir=/usr +ExecStart=/usr/bin/mysqld_safe <%= @wsrep_new_cluster %> --basedir=/usr ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID # Give a reasonable amount of time for the server to start up/shut down