diff --git a/deployment/puppet/galera/.project b/deployment/puppet/galera/.project
index 71c819e536..84bb022435 100644
--- a/deployment/puppet/galera/.project
+++ b/deployment/puppet/galera/.project
@@ -1,24 +1,30 @@
-
-
- galera
-
-
- selinux
-
-
-
- org.cloudsmith.geppetto.pp.dsl.ui.modulefileBuilder
-
-
-
-
- org.eclipse.xtext.ui.shared.xtextBuilder
-
-
-
-
-
- org.cloudsmith.geppetto.pp.dsl.ui.puppetNature
- org.eclipse.xtext.ui.shared.xtextNature
-
-
+
+
+ galera
+
+
+ selinux
+
+
+
+ com.aptana.ide.core.unifiedBuilder
+
+
+
+
+ org.cloudsmith.geppetto.pp.dsl.ui.modulefileBuilder
+
+
+
+
+ org.eclipse.xtext.ui.shared.xtextBuilder
+
+
+
+
+
+ org.cloudsmith.geppetto.pp.dsl.ui.puppetNature
+ com.aptana.ruby.core.rubynature
+ org.eclipse.xtext.ui.shared.xtextNature
+
+
diff --git a/deployment/puppet/galera/lib/facter/galera_gcomm_empty.rb b/deployment/puppet/galera/lib/facter/galera_gcomm_empty.rb
index 5132cea9b9..b01c6822ae 100644
--- a/deployment/puppet/galera/lib/facter/galera_gcomm_empty.rb
+++ b/deployment/puppet/galera/lib/facter/galera_gcomm_empty.rb
@@ -1,7 +1,22 @@
-# galera_gcomm.rb
+# Fact: galera_gcomm_empty
+#
+# Purpose: Return 'true' if gcomm:// cluster address is empty for Galera MySQL master-master replication engine
+#
+# Resolution:
+# Greps mysql config files for wsrep_cluster_address option
+#
+# Caveats:
+#
+
+## Cfkey.rb
+## Facts related to cfengine
+##
result = "true"
-if File.exists?("/etc/mysql/conf.d/wsrep.cnf")
+#FIXME: do not hardcode wsrep config file location. We need to start from
+#FIXME: mysql config file and go through all the include directives
+
+if File.exists?("/etc/mysql/conf.d/wsrep.cnf")
if open("/etc/mysql/conf.d/wsrep.cnf").read.split("\n").grep(/^\s*wsrep_cluster_address=[\"\']gcomm:\/\/\s*[\"\']\s*/).any?
result="true"
else
diff --git a/deployment/puppet/galera/lib/puppet/provider/package/rpmforce.rb b/deployment/puppet/galera/lib/puppet/provider/package/rpmforce.rb
deleted file mode 100644
index e63ccb94c6..0000000000
--- a/deployment/puppet/galera/lib/puppet/provider/package/rpmforce.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-# At this point, it's an exact copy of the Blastwave stuff.
-Puppet::Type.type(:package).provide :rpmforce, :parent => :rpm, :source => :rpm do
- desc "Package management using rpm --force option"
-
- commands :rpm => "rpm"
-
- def install
- super
- rescue Puppet::ExecutionFailure
- rpm "-U", "--force", @resource[:source]
- end
-
-end
diff --git a/deployment/puppet/galera/manifests/galera_master_final_config.pp b/deployment/puppet/galera/manifests/galera_master_final_config.pp
index e032ce1f28..d7e2984b39 100644
--- a/deployment/puppet/galera/manifests/galera_master_final_config.pp
+++ b/deployment/puppet/galera/manifests/galera_master_final_config.pp
@@ -1,19 +1,41 @@
-class galera::galera_master_final_config($primary_controller, $node_addresses, $node_address) {
-# This class changes config file on first Galera node to allow safe restart of this node without leaving cluster.
+# == Define: galera_master_final_config
+#
+# Class for final configuring of galera master node.
+#
+# === Parameters
+#
+# [*primary_controller*]
+# Set to true if the node is primary controller/master of galera cluster.
+# [*node_addresses*]
+# Array of galera cluster node members IPs/hostnames.
+#
+# [*node_address*]
+# Name of the node used in galera cluster config. Can be IP/hostname.
+#
+# === Authors
+#
+# Mirantis Inc.
+#
+# === Copyright
+#
+# FIXME: Insert copyrights and licenses
+#
- if $primary_controller {
- $galera_gcomm_string = inline_template("<%= @node_addresses.reject{|ip| ip == hostname || ip == @node_address || ip == l3_fqdn_hostname }.collect {|ip| ip + ':' + 4567.to_s }.join ',' %>")
- $check_galera = "show status like 'wsrep_cluster_size';"
- $mysql_user = $::galera::params::mysql_user
- $mysql_password = $::galera::params::mysql_password
+class galera::galera_master_final_config ($primary_controller, $node_addresses, $node_address) {
- exec {"first-galera-node-final-config":
- path => "/usr/bin:/usr/sbin:/bin:/sbin",
- command => "sed -i 's/wsrep_cluster_address=\"gcomm:\\/\\/\"\$/wsrep_cluster_address=\"gcomm:\\/\\/${galera_gcomm_string}\"/' /etc/mysql/conf.d/wsrep.cnf; sleep 15",
- onlyif => "sleep 15; mysql -u${mysql_user} -p${mysql_password} -e \"${check_galera}\" && (mysql -u${mysql_user} -p${mysql_password} -e \"${check_galera}\" | awk '\$1 == \"wsrep_cluster_size\" {print \$2}' | awk '{if (\$0 > 1) exit 0; else exit 1}')",
- logoutput => true,
- }
+ if $primary_controller {
+ $galera_gcomm_string = inline_template("<%= @node_addresses.reject{|ip| ip == hostname || ip == @node_address || ip == l3_fqdn_hostname }.collect {|ip| ip + ':' + 4567.to_s }.join ',' %>"
+ )
+ $check_galera = "show status like 'wsrep_cluster_size';"
+ $mysql_user = $::galera::params::mysql_user
+ $mysql_password = $::galera::params::mysql_password
+
+ exec { "first-galera-node-final-config":
+ path => "/usr/bin:/usr/sbin:/bin:/sbin",
+ command => "sed -i 's/wsrep_cluster_address=\"gcomm:\\/\\/\"\$/wsrep_cluster_address=\"gcomm:\\/\\/${galera_gcomm_string}\"/' /etc/mysql/conf.d/wsrep.cnf; sleep 15",
+ onlyif => "sleep 15; mysql -u${mysql_user} -p${mysql_password} -e \"${check_galera}\" && (mysql -u${mysql_user} -p${mysql_password} -e \"${check_galera}\" | awk '\$1 == \"wsrep_cluster_size\" {print \$2}' | awk '{if (\$0 > 1) exit 0; else exit 1}')",
+ logoutput => true,
}
+ }
}
-
diff --git a/deployment/puppet/galera/manifests/init.pp b/deployment/puppet/galera/manifests/init.pp
index 22fba23311..a2f0420aca 100644
--- a/deployment/puppet/galera/manifests/init.pp
+++ b/deployment/puppet/galera/manifests/init.pp
@@ -1,13 +1,44 @@
-#
-# wget https://launchpad.net/codership-mysql/5.5/5.5.23-23.6/+download/mysql-server-wsrep-5.5.23-23.6-amd64.deb
-# wget https://launchpad.net/galera/2.x/23.2.1/+download/galera-23.2.1-amd64.deb
-# aptitude install mysql-client libdbd-mysql-perl libdbi-perl
-# aptitude install libssl0.9.8
-# dpkg -i mysql-server-wsrep-5.5.23-23.6-amd64.deb
-# dpkg -i galera-23.2.1-amd64.deb
-# vi /etc/mysql/conf.d/wsrep.cnf
-# /etc/init.d/mysql start
+# == Define: galera
#
+# Class for installation and configuration of galer Master/Master cluster.
+#
+# === Parameters
+#
+# [*cluster_name*]
+# Cluster name for `wsrep_cluster_name` variable.
+#
+# [*primary_controller*]
+# Set to true if current node is the initial master/primary
+# controller.
+#
+# [*node_address*]
+# Which value to use as node address for filtering in gcomm address.
+# This is done due to some bugs in galera configuration. Thus we are
+# filtering this address from `wsrep_cluster_address` to avoid these
+# problems.
+#
+# [*setup_multiple_gcomm*]
+# Should gcomm address contain multiple nodes or not.
+#
+# [*skip_name_resolve*]
+# By default, MySQL tries to do reverse name mapping IP->hostname. In this
+# case MySQL requests can be timed out by clients in case of broken name
+# resolving system. If you are not sure that your DNS/NIS/whatever are configured
+# correctly, set this value to true.
+#
+# [*node_addresses*]
+# Array with IPs/hostnames of cluster members.
+#
+# === Authors
+#
+# Mirantis Inc.
+#
+# === Copyright
+#
+# FIXME: Insert copyrights and licenses
+#
+
+
class galera (
$cluster_name,
$primary_controller = false,
@@ -141,11 +172,6 @@ class galera (
# logoutput => true,
# }
- # exec { "download-galera" :
- # command => "/usr/bin/wget -P/tmp ${galera_prefix}/${::galera::params::galera_package}",
- # creates => "/tmp/${::galera::params::galera_package}",
- # }
-
file { ["/etc/mysql", "/etc/mysql/conf.d"]: ensure => directory, }
if $::galera_gcomm_empty == "true" {
@@ -161,17 +187,25 @@ class galera (
File["/etc/mysql/conf.d/wsrep.cnf"] -> Package['MySQL-server']
}
+#TODO: find another way of mysql initial replication users creation
+
+
+# This file contains initial sql requests for creating replication users.
+
file { "/tmp/wsrep-init-file":
ensure => present,
content => template("galera/wsrep-init-file.erb"),
}
+# This exec calls mysqld_safe with aforementioned file as --init-file argument, thus creating replication user.
exec { "set-mysql-password":
unless => "/usr/bin/mysql -u${mysql_user} -p${mysql_password}",
command => "/usr/bin/mysqld_safe --init-file=/tmp/wsrep-init-file --port=3307 &",
refreshonly => true,
}
+# This exec waits for initial sync of galera cluster after mysql replication user creation.
+
exec { "wait-initial-sync":
logoutput => true,
command => "/usr/bin/mysql -Nbe \"show status like 'wsrep_local_state_comment'\" | /bin/grep -q -e Synced -e Initialized && sleep 10",
@@ -180,6 +214,8 @@ class galera (
refreshonly => true,
}
+# This exec kills initialized mysql to allow its management with generic service providers (init/upstart/pacemaker/etc.)
+
exec { "kill-initial-mysql":
path => "/usr/bin:/usr/sbin:/bin:/sbin",
command => "killall -w mysqld && ( killall -w -9 mysqld_safe || : ) && sleep 10",
@@ -206,6 +242,8 @@ class galera (
Exec["kill-initial-mysql"] -> Exec["rm-init-file"]
Package["MySQL-server"] ~> Exec["set-mysql-password"] ~> Exec ["wait-initial-sync"] ~> Exec["kill-initial-mysql"]
+# FIXME: This class is deprecated and should be removed in future releases.
+
class { 'galera::galera_master_final_config':
require => Exec["wait-for-haproxy-mysql-backend"],
primary_controller => $primary_controller,
diff --git a/deployment/puppet/galera/manifests/params.pp b/deployment/puppet/galera/manifests/params.pp
index 16be41bfc8..a0c5b9c710 100644
--- a/deployment/puppet/galera/manifests/params.pp
+++ b/deployment/puppet/galera/manifests/params.pp
@@ -8,28 +8,19 @@ class galera::params {
case $::osfamily {
'RedHat': {
$pkg_provider = 'yum'
- #$pkg_provider = 'rpmforce'
$libssl_package = 'openssl098e'
$libaio_package = 'libaio'
- # $mysql_client_package = 'mysql'
$mysql_version = '5.5.28_wsrep_23.7-12'
-# $mysql_server_package = 'MySQL-server-wsrep-5.5.28_wsrep_23.7-11.x86_64.rpm'
$mysql_server_name = 'MySQL-server-wsrep'
-# $galera_package = 'galera-23.2.2-1.rhel5.x86_64.rpm'
$galera_version = '23.2.2-1.rhel5'
$libgalera_prefix = '/usr/lib64'
}
'Debian': {
$pkg_provider = 'apt'
- #$pkg_provider = 'dpkg'
$libssl_package = 'libssl0.9.8'
$libaio_package = 'libaio1'
- # $mysql_client_package = 'mysql-client'
-# $mysql_version = '5.5.28-23.7'
-# $mysql_server_package = 'mysql-server-wsrep-5.5.28-23.7-amd64.deb'
$mysql_server_name = 'mysql-server-wsrep'
$galera_version = '23.2.2'
-# $galera_package = 'galera-23.2.2-amd64.deb'
$libgalera_prefix = '/usr/lib'
}
default: {
diff --git a/deployment/puppet/galera/manifests/pkg_add.pp b/deployment/puppet/galera/manifests/pkg_add.pp
deleted file mode 100644
index 7dbddc2453..0000000000
--- a/deployment/puppet/galera/manifests/pkg_add.pp
+++ /dev/null
@@ -1,25 +0,0 @@
-define galera::pkg_add(
- $pkg_version,
- $pkg_prefix = '/tmp'
-) {
-
- include galera::params
- case $::osfamily {
- 'RedHat': {
-
- package { $title :
- ensure => present,
- provider => $::galera::params::pkg_provider,
- source => "${pkg_prefix}/${title}-${pkg_version}.rpm",
- }
- }
- 'Debian': {
-
- package { $title :
- ensure => present,
- provider => $::galera::params::pkg_provider,
- source => "${pkg_prefix}/${title}-${pkg_version}.deb",
- }
- }
- }
-}
\ No newline at end of file