Refactor haproxy_ocf to use wrappers
* Refactor harproxy manifest to make use of pacemaker wrappers * It will also make it easier to switch to the upstream version of the haproxy module Related-Bug: 1494314 Change-Id: I2d11acd6f11dad9b46257c6d1d70993aa8e36568
This commit is contained in:
parent
8eb2a1d15a
commit
a9b06a1231
@ -50,7 +50,9 @@ class cluster::haproxy (
|
||||
include ::haproxy::params
|
||||
include ::rsyslog::params
|
||||
|
||||
package { 'haproxy': }
|
||||
package { 'haproxy':
|
||||
name => $::haproxy::params::package_name,
|
||||
}
|
||||
|
||||
#NOTE(bogdando) we want defaults w/o chroot
|
||||
# and this override looks the only possible if
|
||||
@ -87,6 +89,8 @@ class cluster::haproxy (
|
||||
],
|
||||
}
|
||||
|
||||
$service_name = 'p_haproxy'
|
||||
|
||||
class { 'haproxy::base':
|
||||
global_options => $global_options,
|
||||
defaults_options => $defaults_options,
|
||||
@ -94,29 +98,55 @@ class cluster::haproxy (
|
||||
use_include => true,
|
||||
}
|
||||
|
||||
class { 'cluster::haproxy_ocf':
|
||||
primary_controller => $primary_controller,
|
||||
debug => $debug,
|
||||
other_networks => $other_networks,
|
||||
sysctl::value { 'net.ipv4.ip_nonlocal_bind':
|
||||
value => '1'
|
||||
}
|
||||
|
||||
service { 'haproxy' :
|
||||
ensure => 'running',
|
||||
name => $service_name,
|
||||
enable => true,
|
||||
hasstatus => true,
|
||||
hasrestart => true,
|
||||
}
|
||||
|
||||
tweaks::ubuntu_service_override { 'haproxy' :
|
||||
service_name => 'haproxy',
|
||||
package_name => $haproxy::params::package_name,
|
||||
}
|
||||
|
||||
Package['haproxy'] ->
|
||||
Class['haproxy::base']
|
||||
|
||||
Class['haproxy::base'] ~>
|
||||
Service['haproxy']
|
||||
|
||||
Package['haproxy'] ~>
|
||||
Service['haproxy']
|
||||
|
||||
Sysctl::Value['net.ipv4.ip_nonlocal_bind'] ~>
|
||||
Service['haproxy']
|
||||
|
||||
# Rsyslog
|
||||
|
||||
file { '/etc/rsyslog.d/haproxy.conf':
|
||||
ensure => present,
|
||||
content => template("${module_name}/haproxy.conf.erb"),
|
||||
notify => Service[$::rsyslog::params::service_name],
|
||||
}
|
||||
|
||||
Package['haproxy'] -> Class['haproxy::base']
|
||||
Class['haproxy::base'] -> Class['cluster::haproxy_ocf']
|
||||
|
||||
if defined(Corosync::Service['pacemaker']) {
|
||||
Corosync::Service['pacemaker'] -> Class['cluster::haproxy_ocf']
|
||||
}
|
||||
|
||||
if !defined(Service[$::rsyslog::params::service_name]) {
|
||||
service { $::rsyslog::params::service_name:
|
||||
ensure => running,
|
||||
ensure => 'running',
|
||||
enable => true,
|
||||
}
|
||||
}
|
||||
|
||||
# Paceamker
|
||||
|
||||
class { 'cluster::haproxy_ocf':
|
||||
debug => $debug,
|
||||
other_networks => $other_networks,
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,44 +3,49 @@
|
||||
# Configure OCF service for HAProxy managed by corosync/pacemaker
|
||||
#
|
||||
class cluster::haproxy_ocf (
|
||||
$primary_controller,
|
||||
$debug = false,
|
||||
$other_networks = false,
|
||||
){
|
||||
anchor {'haproxy': }
|
||||
) inherits cluster::haproxy {
|
||||
|
||||
$service_name = 'p_haproxy'
|
||||
$primitive_type = 'ns_haproxy'
|
||||
$complex_type = 'clone'
|
||||
|
||||
cs_resource { $service_name:
|
||||
ensure => present,
|
||||
primitive_class => 'ocf',
|
||||
provided_by => 'fuel',
|
||||
primitive_type => 'ns_haproxy',
|
||||
complex_type => 'clone',
|
||||
ms_metadata => {
|
||||
'interleave' => true,
|
||||
$ms_metadata = {
|
||||
'interleave' => true,
|
||||
}
|
||||
|
||||
$metadata = {
|
||||
'migration-threshold' => '3',
|
||||
'failure-timeout' => '120',
|
||||
}
|
||||
|
||||
$parameters = {
|
||||
'ns' => 'haproxy',
|
||||
'debug' => $debug,
|
||||
'other_networks' => $other_networks,
|
||||
}
|
||||
|
||||
$operations = {
|
||||
'monitor' => {
|
||||
'interval' => '30',
|
||||
'timeout' => '60'
|
||||
},
|
||||
metadata => {
|
||||
'migration-threshold' => '3',
|
||||
'failure-timeout' => '120',
|
||||
},
|
||||
parameters => {
|
||||
'ns' => 'haproxy',
|
||||
'debug' => $debug,
|
||||
'other_networks' => "${other_networks}",
|
||||
},
|
||||
operations => {
|
||||
'monitor' => {
|
||||
'interval' => '30',
|
||||
'timeout' => '60'
|
||||
},
|
||||
'start' => {
|
||||
'timeout' => '60'
|
||||
},
|
||||
'stop' => {
|
||||
'timeout' => '60'
|
||||
},
|
||||
'timeout' => '60'
|
||||
},
|
||||
'stop' => {
|
||||
'timeout' => '60'
|
||||
},
|
||||
}
|
||||
|
||||
pacemaker_wrappers::service { $service_name :
|
||||
primitive_type => $primitive_type,
|
||||
parameters => $parameters,
|
||||
metadata => $metadata,
|
||||
operations => $operations,
|
||||
ms_metadata => $ms_metadata,
|
||||
complex_type => $complex_type,
|
||||
prefix => false,
|
||||
}
|
||||
|
||||
cs_rsc_colocation { 'vip_public-with-haproxy':
|
||||
@ -51,7 +56,6 @@ class cluster::haproxy_ocf (
|
||||
"clone_${service_name}"
|
||||
],
|
||||
}
|
||||
|
||||
cs_rsc_colocation { 'vip_management-with-haproxy':
|
||||
ensure => present,
|
||||
score => 'INFINITY',
|
||||
@ -64,37 +68,6 @@ class cluster::haproxy_ocf (
|
||||
Cs_resource[$service_name] -> Cs_rsc_colocation['vip_public-with-haproxy'] -> Service[$service_name]
|
||||
Cs_resource[$service_name] -> Cs_rsc_colocation['vip_management-with-haproxy'] -> Service[$service_name]
|
||||
|
||||
if ($::osfamily == 'Debian') {
|
||||
file { '/etc/default/haproxy':
|
||||
content => 'ENABLED=0',
|
||||
} -> Service <| title == $service_name |>
|
||||
if $::operatingsystem == 'Ubuntu' {
|
||||
file { '/etc/init/haproxy.override':
|
||||
ensure => 'present',
|
||||
replace => 'no',
|
||||
content => 'manual',
|
||||
mode => '0644'
|
||||
} -> Service <| title == $service_name |>
|
||||
}
|
||||
}
|
||||
|
||||
service { 'haproxy-init-stopped':
|
||||
ensure => 'stopped',
|
||||
name => 'haproxy',
|
||||
enable => false,
|
||||
} -> Service <| title == $service_name |>
|
||||
|
||||
sysctl::value { 'net.ipv4.ip_nonlocal_bind':
|
||||
value => '1'
|
||||
} ->
|
||||
service { $service_name:
|
||||
ensure => 'running',
|
||||
name => $service_name,
|
||||
enable => true,
|
||||
hasstatus => true,
|
||||
hasrestart => true,
|
||||
provider => 'pacemaker',
|
||||
} -> Anchor['haproxy-done']
|
||||
|
||||
anchor {'haproxy-done': }
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user