commit
aa96a82f67
|
@ -50,26 +50,26 @@ Puppet::Type.type(:service).provide :pacemaker, :parent => Puppet::Provider::Cor
|
|||
@service={}
|
||||
default_start_timeout = 30
|
||||
default_stop_timeout = 30
|
||||
resource = XPath.first(@@resources, "//primitive[@id='#{@resource[:name]}']")
|
||||
@service[:msname] = ['master','clone'].include?(resource.parent.name) ? resource.parent.attributes['id'] : nil
|
||||
cib_resource = XPath.match(@@resources, "//primitive[@id=\'#{@resource[:name]}\']").first
|
||||
@service[:msname] = ['master','clone'].include?(cib_resource.parent.name) ? cib_resource.parent.attributes['id'] : nil
|
||||
@service[:name] = @resource[:name]
|
||||
@service[:class] = resource.attributes['class']
|
||||
@service[:provider] = resource.attributes['provider']
|
||||
@service[:type] = resource.attributes['type']
|
||||
@service[:class] = cib_resource.attributes['class']
|
||||
@service[:provider] = cib_resource.attributes['provider']
|
||||
@service[:type] = cib_resource.attributes['type']
|
||||
@service[:metadata] = {}
|
||||
if !resource.elements['meta_attributes'].nil?
|
||||
resource.elements['meta_attributes'].each_element do |m|
|
||||
if !cib_resource.elements['meta_attributes'].nil?
|
||||
cib_resource.elements['meta_attributes'].each_element do |m|
|
||||
@service[:metadata][m.attributes['name'].to_sym] = m.attributes['value']
|
||||
end
|
||||
end
|
||||
if @service[:class] == 'ocf'
|
||||
stdin, stdout, stderr = Open3.popen3("/bin/bash -c 'OCF_ROOT=/usr/lib/ocf /usr/lib/ocf/resource.d/#{@service[:provider]}/#{@service[:type]} meta-data'")
|
||||
metadata = REXML::Document.new(stdout)
|
||||
default_start_timeout = XPath.first(metadata, "//actions/action[@name=\'start\']").attributes['timeout'].to_i
|
||||
default_stop_timeout = XPath.first(metadata, "//actions/action[@name=\'stop\']").attributes['timeout'].to_i
|
||||
default_start_timeout = XPath.match(metadata, "//actions/action[@name=\'start\']").first.attributes['timeout'].to_i
|
||||
default_stop_timeout = XPath.match(metadata, "//actions/action[@name=\'stop\']").first.attributes['timeout'].to_i
|
||||
end
|
||||
op_start=XPath.first(resource,"//operations/op[@name=\'start\']")
|
||||
op_stop=XPath.first(resource,"//operations/op[@name=\'stop\']")
|
||||
op_start=XPath.match(REXML::Document.new(cib_resource.to_s),"//operations/op[@name='start']").first
|
||||
op_stop=XPath.match(REXML::Document.new(cib_resource.to_s),"//operations/op[@name='stop']").first
|
||||
@service[:start_timeout] = default_start_timeout
|
||||
@service[:stop_timeout] = default_stop_timeout
|
||||
if !op_start.nil?
|
||||
|
@ -201,12 +201,12 @@ Puppet::Type.type(:service).provide :pacemaker, :parent => Puppet::Provider::Cor
|
|||
if ['promote','start','stop'].include?(last_op.attributes['operation'])
|
||||
last_successful_op = last_op.attributes['operation']
|
||||
else
|
||||
if last_op.attributes['rc-code'].to_i == 7
|
||||
last_successful_op = 'stop'
|
||||
elsif last_op.attributes['rc-code'].to_i == 0
|
||||
if last_op.attributes['rc-code'].to_i == 0
|
||||
last_successful_op = 'start'
|
||||
elsif last_op.attributes['rc-code'].to_i == 8
|
||||
last_successful_op = 'start'
|
||||
else
|
||||
last_successful_op = 'stop'
|
||||
end
|
||||
end
|
||||
debug("LAST SUCCESSFUL OP :\n\n #{last_successful_op.inspect}")
|
||||
|
|
|
@ -302,7 +302,6 @@ case "$mode" in
|
|||
fi
|
||||
else
|
||||
if [ "$(crm_attribute -t crm_config --name mysqlprimaryinit --query 2> /dev/null | awk -F\= '{print $4}')" = 'done' ] ; then
|
||||
CRM_ONLINE_NODES=( $(crm node list | grep -v \(offline\) | sed 's/\://g') )
|
||||
$bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $other_args >/dev/null 2>&1 &
|
||||
wait_for_pid created "$!" "$mysqld_pid_file_path"; return_value=$?
|
||||
sleep 90
|
||||
|
@ -322,6 +321,7 @@ case "$mode" in
|
|||
# Check if someone already decided to declare himself master...
|
||||
RAISED_MASTER=$(crm_attribute -t crm_config --name mysqlmaster --query 2> /dev/null | awk -F\= '{print $4}')
|
||||
# ... and if nobody did:
|
||||
CRM_ONLINE_NODES=( $(crm node list | grep -v \(offline\) | sed 's/\://g') )
|
||||
for node in "${CRM_ONLINE_NODES[@]}" ; do
|
||||
CUR_EPOCH=$(crm_attribute -t crm_config --node $node --name mysqlepoch --query 2> /dev/null | awk -F\= '{print $4}')
|
||||
if [ -z "$CUR_EPOCH" ] ; then
|
||||
|
|
|
@ -50,6 +50,9 @@ class galera (
|
|||
) {
|
||||
include galera::params
|
||||
|
||||
$cib_name = "mysql"
|
||||
$res_name = "p_$cib_name"
|
||||
|
||||
$mysql_user = $::galera::params::mysql_user
|
||||
$mysql_password = $::galera::params::mysql_password
|
||||
$libgalera_prefix = $::galera::params::libgalera_prefix
|
||||
|
@ -59,15 +62,15 @@ class galera (
|
|||
|
||||
file { '/etc/init.d/mysql':
|
||||
ensure => present,
|
||||
mode => 755,
|
||||
mode => 644,
|
||||
require => Package['MySQL-server'],
|
||||
before => Service['mysql-galera']
|
||||
before => Service["$cib_name"]
|
||||
}
|
||||
|
||||
file { '/etc/my.cnf':
|
||||
ensure => present,
|
||||
content => template("galera/my.cnf.erb"),
|
||||
before => Service['mysql-galera']
|
||||
before => Service["$cib_name"]
|
||||
}
|
||||
|
||||
package { 'MySQL-client':
|
||||
|
@ -92,16 +95,16 @@ class galera (
|
|||
|
||||
file { '/etc/init.d/mysql':
|
||||
ensure => present,
|
||||
mode => 755,
|
||||
mode => 644,
|
||||
source => 'puppet:///modules/galera/mysql.init' ,
|
||||
require => Package['MySQL-server'],
|
||||
before => Service['mysql-galera']
|
||||
before => Service["$cib_name"]
|
||||
}
|
||||
|
||||
file { '/etc/my.cnf':
|
||||
ensure => present,
|
||||
content => template("galera/my.cnf.erb"),
|
||||
before => Service['mysql-galera']
|
||||
before => Service["$cib_name"]
|
||||
}
|
||||
|
||||
package { 'wget':
|
||||
|
@ -123,21 +126,48 @@ class galera (
|
|||
before => Package['MySQL-server']
|
||||
}
|
||||
|
||||
package { 'libc6':
|
||||
ensure => latest,
|
||||
before => Package['MySQL-server']
|
||||
}
|
||||
}
|
||||
}
|
||||
cs_shadow { $res_name: cib => $cib_name }
|
||||
cs_commit { $res_name: cib => $cib_name } ~> ::Corosync::Cleanup["$res_name"]
|
||||
::corosync::cleanup { $res_name: }
|
||||
cs_resource { "$res_name":
|
||||
ensure => present,
|
||||
cib => $cib_name,
|
||||
primitive_class => 'ocf',
|
||||
provided_by => 'mirantis',
|
||||
primitive_type => 'mysql',
|
||||
multistate_hash => {
|
||||
'type' => 'clone',
|
||||
},
|
||||
ms_metadata => {
|
||||
'interleave' => 'true',
|
||||
},
|
||||
operations => {
|
||||
'monitor' => {
|
||||
'interval' => '60',
|
||||
'timeout' => '30'
|
||||
},
|
||||
'start' => {
|
||||
'timeout' => '450'
|
||||
},
|
||||
'stop' => {
|
||||
'timeout' => '150'
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
service { "mysql-galera":
|
||||
name => "mysql",
|
||||
service { "mysql":
|
||||
name => "p_mysql",
|
||||
enable => true,
|
||||
ensure => "running",
|
||||
require => [Package["MySQL-server", "galera"]],
|
||||
hasrestart => true,
|
||||
hasstatus => true,
|
||||
provider => "pacemaker",
|
||||
}
|
||||
Package['pacemaker'] -> File['mysql-wss']
|
||||
Cs_resource["$res_name"] ->
|
||||
Cs_commit["$res_name"] ->
|
||||
Service["$cib_name"]
|
||||
|
||||
package { [$::galera::params::libssl_package, $::galera::params::libaio_package]:
|
||||
ensure => present,
|
||||
|
@ -180,10 +210,6 @@ class galera (
|
|||
content => template("galera/wsrep.cnf.erb"),
|
||||
require => [File["/etc/mysql/conf.d"], File["/etc/mysql"]],
|
||||
}
|
||||
File["/etc/mysql/conf.d/wsrep.cnf"] -> Exec['set-mysql-password']
|
||||
File["/etc/mysql/conf.d/wsrep.cnf"] ~> Exec['set-mysql-password']
|
||||
File["/etc/mysql/conf.d/wsrep.cnf"] -> Service['mysql-galera']
|
||||
File["/etc/mysql/conf.d/wsrep.cnf"] ~> Service['mysql-galera']
|
||||
File["/etc/mysql/conf.d/wsrep.cnf"] -> Package['MySQL-server']
|
||||
}
|
||||
|
||||
|
@ -197,13 +223,6 @@ class galera (
|
|||
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":
|
||||
|
@ -214,15 +233,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",
|
||||
# onlyif => "pidof mysqld",
|
||||
try_sleep => 5,
|
||||
tries => 6,
|
||||
refreshonly => true,
|
||||
exec { "rm-init-file":
|
||||
command => "/bin/rm /tmp/wsrep-init-file",
|
||||
}
|
||||
|
||||
exec { "wait-for-synced-state":
|
||||
|
@ -232,18 +244,17 @@ class galera (
|
|||
tries => 60,
|
||||
}
|
||||
|
||||
Package["MySQL-server"] -> Exec["set-mysql-password"]
|
||||
File['/tmp/wsrep-init-file'] -> Exec["set-mysql-password"] -> Exec["wait-initial-sync"]
|
||||
-> Exec["kill-initial-mysql"] -> Service["mysql-galera"] -> Exec ["wait-for-synced-state"]
|
||||
|
||||
Package["MySQL-server"] ~> Exec["set-mysql-password"] ~> Exec ["wait-initial-sync"] ~> Exec["kill-initial-mysql"]
|
||||
|
||||
exec { "raise-first-setup-flag" :
|
||||
path => "/usr/bin:/usr/sbin:/bin:/sbin",
|
||||
command => "crm_attribute -t crm_config --name mysqlprimaryinit --update done",
|
||||
refreshonly => true,
|
||||
}
|
||||
|
||||
|
||||
|
||||
File["/tmp/wsrep-init-file"] -> Service["$cib_name"] -> Exec["wait-initial-sync"] -> Exec ["wait-for-synced-state"] -> Exec ["rm-init-file"]
|
||||
Package["MySQL-server"] ~> Exec ["wait-initial-sync"]
|
||||
|
||||
# FIXME: This class is deprecated and should be removed in future releases.
|
||||
|
||||
class { 'galera::galera_master_final_config':
|
||||
|
@ -257,9 +268,8 @@ class galera (
|
|||
exec { "start-new-galera-cluster":
|
||||
path => "/usr/bin:/usr/sbin:/bin:/sbin",
|
||||
logoutput => true,
|
||||
command => '/etc/init.d/mysql stop; sleep 10; killall -w mysqld && ( killall -w -9 mysqld_safe || : ) && sleep 10; /etc/init.d/mysql start --wsrep-cluster-address=gcomm:// &',
|
||||
onlyif => "[ -f /var/lib/mysql/grastate.dat ] && (cat /var/lib/mysql/grastate.dat | awk '\$1 == \"uuid:\" {print \$2}' | awk '{if (\$0 == \"00000000-0000-0000-0000-000000000000\") exit 0; else exit 1}')",
|
||||
require => Service["mysql-galera"],
|
||||
command => 'echo Primary-controller completed',
|
||||
require => Service["$cib_name"],
|
||||
before => Exec ["wait-for-synced-state"],
|
||||
notify => Exec ["raise-first-setup-flag"],
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -39,6 +39,15 @@ file {'filter_quantum_ports.py':
|
|||
}
|
||||
File['filter_quantum_ports.py'] -> File<| title == 'quantum-ovs-agent' |>
|
||||
|
||||
file {'mysql-wss':
|
||||
path=>'/usr/lib/ocf/resource.d/mirantis/mysql',
|
||||
mode => 744,
|
||||
require =>Package['corosync'],
|
||||
owner => root,
|
||||
group => root,
|
||||
source => "puppet:///modules/openstack/mysql-wss",
|
||||
} -> Corosync::Service['pacemaker']
|
||||
|
||||
file {'quantum-ovs-agent':
|
||||
path=>'/usr/lib/ocf/resource.d/pacemaker/quantum-agent-ovs',
|
||||
mode => 744,
|
||||
|
|
Loading…
Reference in New Issue