commit
aa96a82f67
@ -50,26 +50,26 @@ Puppet::Type.type(:service).provide :pacemaker, :parent => Puppet::Provider::Cor
|
|||||||
@service={}
|
@service={}
|
||||||
default_start_timeout = 30
|
default_start_timeout = 30
|
||||||
default_stop_timeout = 30
|
default_stop_timeout = 30
|
||||||
resource = XPath.first(@@resources, "//primitive[@id='#{@resource[:name]}']")
|
cib_resource = XPath.match(@@resources, "//primitive[@id=\'#{@resource[:name]}\']").first
|
||||||
@service[:msname] = ['master','clone'].include?(resource.parent.name) ? resource.parent.attributes['id'] : nil
|
@service[:msname] = ['master','clone'].include?(cib_resource.parent.name) ? cib_resource.parent.attributes['id'] : nil
|
||||||
@service[:name] = @resource[:name]
|
@service[:name] = @resource[:name]
|
||||||
@service[:class] = resource.attributes['class']
|
@service[:class] = cib_resource.attributes['class']
|
||||||
@service[:provider] = resource.attributes['provider']
|
@service[:provider] = cib_resource.attributes['provider']
|
||||||
@service[:type] = resource.attributes['type']
|
@service[:type] = cib_resource.attributes['type']
|
||||||
@service[:metadata] = {}
|
@service[:metadata] = {}
|
||||||
if !resource.elements['meta_attributes'].nil?
|
if !cib_resource.elements['meta_attributes'].nil?
|
||||||
resource.elements['meta_attributes'].each_element do |m|
|
cib_resource.elements['meta_attributes'].each_element do |m|
|
||||||
@service[:metadata][m.attributes['name'].to_sym] = m.attributes['value']
|
@service[:metadata][m.attributes['name'].to_sym] = m.attributes['value']
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if @service[:class] == 'ocf'
|
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'")
|
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)
|
metadata = REXML::Document.new(stdout)
|
||||||
default_start_timeout = XPath.first(metadata, "//actions/action[@name=\'start\']").attributes['timeout'].to_i
|
default_start_timeout = XPath.match(metadata, "//actions/action[@name=\'start\']").first.attributes['timeout'].to_i
|
||||||
default_stop_timeout = XPath.first(metadata, "//actions/action[@name=\'stop\']").attributes['timeout'].to_i
|
default_stop_timeout = XPath.match(metadata, "//actions/action[@name=\'stop\']").first.attributes['timeout'].to_i
|
||||||
end
|
end
|
||||||
op_start=XPath.first(resource,"//operations/op[@name=\'start\']")
|
op_start=XPath.match(REXML::Document.new(cib_resource.to_s),"//operations/op[@name='start']").first
|
||||||
op_stop=XPath.first(resource,"//operations/op[@name=\'stop\']")
|
op_stop=XPath.match(REXML::Document.new(cib_resource.to_s),"//operations/op[@name='stop']").first
|
||||||
@service[:start_timeout] = default_start_timeout
|
@service[:start_timeout] = default_start_timeout
|
||||||
@service[:stop_timeout] = default_stop_timeout
|
@service[:stop_timeout] = default_stop_timeout
|
||||||
if !op_start.nil?
|
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'])
|
if ['promote','start','stop'].include?(last_op.attributes['operation'])
|
||||||
last_successful_op = last_op.attributes['operation']
|
last_successful_op = last_op.attributes['operation']
|
||||||
else
|
else
|
||||||
if last_op.attributes['rc-code'].to_i == 7
|
if last_op.attributes['rc-code'].to_i == 0
|
||||||
last_successful_op = 'stop'
|
|
||||||
elsif last_op.attributes['rc-code'].to_i == 0
|
|
||||||
last_successful_op = 'start'
|
last_successful_op = 'start'
|
||||||
elsif last_op.attributes['rc-code'].to_i == 8
|
elsif last_op.attributes['rc-code'].to_i == 8
|
||||||
last_successful_op = 'start'
|
last_successful_op = 'start'
|
||||||
|
else
|
||||||
|
last_successful_op = 'stop'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
debug("LAST SUCCESSFUL OP :\n\n #{last_successful_op.inspect}")
|
debug("LAST SUCCESSFUL OP :\n\n #{last_successful_op.inspect}")
|
||||||
|
@ -302,7 +302,6 @@ case "$mode" in
|
|||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [ "$(crm_attribute -t crm_config --name mysqlprimaryinit --query 2> /dev/null | awk -F\= '{print $4}')" = 'done' ] ; then
|
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 &
|
$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=$?
|
wait_for_pid created "$!" "$mysqld_pid_file_path"; return_value=$?
|
||||||
sleep 90
|
sleep 90
|
||||||
@ -322,6 +321,7 @@ case "$mode" in
|
|||||||
# Check if someone already decided to declare himself master...
|
# 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}')
|
RAISED_MASTER=$(crm_attribute -t crm_config --name mysqlmaster --query 2> /dev/null | awk -F\= '{print $4}')
|
||||||
# ... and if nobody did:
|
# ... and if nobody did:
|
||||||
|
CRM_ONLINE_NODES=( $(crm node list | grep -v \(offline\) | sed 's/\://g') )
|
||||||
for node in "${CRM_ONLINE_NODES[@]}" ; do
|
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}')
|
CUR_EPOCH=$(crm_attribute -t crm_config --node $node --name mysqlepoch --query 2> /dev/null | awk -F\= '{print $4}')
|
||||||
if [ -z "$CUR_EPOCH" ] ; then
|
if [ -z "$CUR_EPOCH" ] ; then
|
||||||
|
@ -50,6 +50,9 @@ class galera (
|
|||||||
) {
|
) {
|
||||||
include galera::params
|
include galera::params
|
||||||
|
|
||||||
|
$cib_name = "mysql"
|
||||||
|
$res_name = "p_$cib_name"
|
||||||
|
|
||||||
$mysql_user = $::galera::params::mysql_user
|
$mysql_user = $::galera::params::mysql_user
|
||||||
$mysql_password = $::galera::params::mysql_password
|
$mysql_password = $::galera::params::mysql_password
|
||||||
$libgalera_prefix = $::galera::params::libgalera_prefix
|
$libgalera_prefix = $::galera::params::libgalera_prefix
|
||||||
@ -59,15 +62,15 @@ class galera (
|
|||||||
|
|
||||||
file { '/etc/init.d/mysql':
|
file { '/etc/init.d/mysql':
|
||||||
ensure => present,
|
ensure => present,
|
||||||
mode => 755,
|
mode => 644,
|
||||||
require => Package['MySQL-server'],
|
require => Package['MySQL-server'],
|
||||||
before => Service['mysql-galera']
|
before => Service["$cib_name"]
|
||||||
}
|
}
|
||||||
|
|
||||||
file { '/etc/my.cnf':
|
file { '/etc/my.cnf':
|
||||||
ensure => present,
|
ensure => present,
|
||||||
content => template("galera/my.cnf.erb"),
|
content => template("galera/my.cnf.erb"),
|
||||||
before => Service['mysql-galera']
|
before => Service["$cib_name"]
|
||||||
}
|
}
|
||||||
|
|
||||||
package { 'MySQL-client':
|
package { 'MySQL-client':
|
||||||
@ -92,16 +95,16 @@ class galera (
|
|||||||
|
|
||||||
file { '/etc/init.d/mysql':
|
file { '/etc/init.d/mysql':
|
||||||
ensure => present,
|
ensure => present,
|
||||||
mode => 755,
|
mode => 644,
|
||||||
source => 'puppet:///modules/galera/mysql.init' ,
|
source => 'puppet:///modules/galera/mysql.init' ,
|
||||||
require => Package['MySQL-server'],
|
require => Package['MySQL-server'],
|
||||||
before => Service['mysql-galera']
|
before => Service["$cib_name"]
|
||||||
}
|
}
|
||||||
|
|
||||||
file { '/etc/my.cnf':
|
file { '/etc/my.cnf':
|
||||||
ensure => present,
|
ensure => present,
|
||||||
content => template("galera/my.cnf.erb"),
|
content => template("galera/my.cnf.erb"),
|
||||||
before => Service['mysql-galera']
|
before => Service["$cib_name"]
|
||||||
}
|
}
|
||||||
|
|
||||||
package { 'wget':
|
package { 'wget':
|
||||||
@ -123,21 +126,48 @@ class galera (
|
|||||||
before => Package['MySQL-server']
|
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":
|
service { "mysql":
|
||||||
name => "mysql",
|
name => "p_mysql",
|
||||||
enable => true,
|
enable => true,
|
||||||
ensure => "running",
|
ensure => "running",
|
||||||
require => [Package["MySQL-server", "galera"]],
|
require => [Package["MySQL-server", "galera"]],
|
||||||
hasrestart => true,
|
provider => "pacemaker",
|
||||||
hasstatus => true,
|
|
||||||
}
|
}
|
||||||
|
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]:
|
package { [$::galera::params::libssl_package, $::galera::params::libaio_package]:
|
||||||
ensure => present,
|
ensure => present,
|
||||||
@ -180,10 +210,6 @@ class galera (
|
|||||||
content => template("galera/wsrep.cnf.erb"),
|
content => template("galera/wsrep.cnf.erb"),
|
||||||
require => [File["/etc/mysql/conf.d"], File["/etc/mysql"]],
|
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']
|
File["/etc/mysql/conf.d/wsrep.cnf"] -> Package['MySQL-server']
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,13 +223,6 @@ class galera (
|
|||||||
content => template("galera/wsrep-init-file.erb"),
|
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.
|
# This exec waits for initial sync of galera cluster after mysql replication user creation.
|
||||||
|
|
||||||
exec { "wait-initial-sync":
|
exec { "wait-initial-sync":
|
||||||
@ -214,15 +233,8 @@ class galera (
|
|||||||
refreshonly => true,
|
refreshonly => true,
|
||||||
}
|
}
|
||||||
|
|
||||||
# This exec kills initialized mysql to allow its management with generic service providers (init/upstart/pacemaker/etc.)
|
exec { "rm-init-file":
|
||||||
|
command => "/bin/rm /tmp/wsrep-init-file",
|
||||||
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 { "wait-for-synced-state":
|
exec { "wait-for-synced-state":
|
||||||
@ -231,12 +243,6 @@ class galera (
|
|||||||
try_sleep => 5,
|
try_sleep => 5,
|
||||||
tries => 60,
|
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" :
|
exec { "raise-first-setup-flag" :
|
||||||
path => "/usr/bin:/usr/sbin:/bin:/sbin",
|
path => "/usr/bin:/usr/sbin:/bin:/sbin",
|
||||||
@ -244,6 +250,11 @@ class galera (
|
|||||||
refreshonly => true,
|
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.
|
# FIXME: This class is deprecated and should be removed in future releases.
|
||||||
|
|
||||||
class { 'galera::galera_master_final_config':
|
class { 'galera::galera_master_final_config':
|
||||||
@ -257,11 +268,10 @@ class galera (
|
|||||||
exec { "start-new-galera-cluster":
|
exec { "start-new-galera-cluster":
|
||||||
path => "/usr/bin:/usr/sbin:/bin:/sbin",
|
path => "/usr/bin:/usr/sbin:/bin:/sbin",
|
||||||
logoutput => true,
|
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:// &',
|
command => 'echo Primary-controller completed',
|
||||||
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["$cib_name"],
|
||||||
require => Service["mysql-galera"],
|
|
||||||
before => Exec ["wait-for-synced-state"],
|
before => Exec ["wait-for-synced-state"],
|
||||||
notify => Exec ["raise-first-setup-flag"],
|
notify => Exec ["raise-first-setup-flag"],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
1331
deployment/puppet/openstack/files/mysql-wss
Normal file
1331
deployment/puppet/openstack/files/mysql-wss
Normal file
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['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':
|
file {'quantum-ovs-agent':
|
||||||
path=>'/usr/lib/ocf/resource.d/pacemaker/quantum-agent-ovs',
|
path=>'/usr/lib/ocf/resource.d/pacemaker/quantum-agent-ovs',
|
||||||
mode => 744,
|
mode => 744,
|
||||||
|
Loading…
Reference in New Issue
Block a user