Merge pull request #500 from enovance/puppet-pacemaker
cloud::spof: add red hat support
This commit is contained in:
@@ -39,6 +39,15 @@ fixtures:
|
|||||||
'concat':
|
'concat':
|
||||||
repo: 'git://github.com/enovance/puppet-concat.git'
|
repo: 'git://github.com/enovance/puppet-concat.git'
|
||||||
ref: '04356974f72b90a1d0f57346a00e95a717924e43'
|
ref: '04356974f72b90a1d0f57346a00e95a717924e43'
|
||||||
|
'corosync':
|
||||||
|
repo: 'git://github.com/enovance/puppetlabs-corosync.git'
|
||||||
|
ref: '79b61302b07fef30b65a42f3b55229616018aacf'
|
||||||
|
'firewall':
|
||||||
|
repo: 'git://github.com/enovance/puppetlabs-firewall.git'
|
||||||
|
ref: '6540b31b0ca0727094ddf44436274436d2853d6d'
|
||||||
|
'pacemaker':
|
||||||
|
repo: 'git://github.com/enovance/puppet-pacemaker.git'
|
||||||
|
ref: '3e64c61c205376885ba537fb3c0d37ced0fb53ac'
|
||||||
'elasticsearch':
|
'elasticsearch':
|
||||||
repo: 'git://github.com/enovance/puppet-elasticsearch.git'
|
repo: 'git://github.com/enovance/puppet-elasticsearch.git'
|
||||||
ref: '042720d52a3879786c2f9d9f67961c4f42004fae'
|
ref: '042720d52a3879786c2f9d9f67961c4f42004fae'
|
||||||
|
|||||||
@@ -74,6 +74,9 @@ mod 'dnsclient',
|
|||||||
mod 'elasticsearch',
|
mod 'elasticsearch',
|
||||||
:git => 'git://github.com/enovance/puppet-elasticsearch.git',
|
:git => 'git://github.com/enovance/puppet-elasticsearch.git',
|
||||||
:ref => '042720d52a3879786c2f9d9f67961c4f42004fae'
|
:ref => '042720d52a3879786c2f9d9f67961c4f42004fae'
|
||||||
|
mod 'firewall',
|
||||||
|
:git => 'git@github.com:enovance/puppetlabs-firewall.git',
|
||||||
|
:ref => '6540b31b0ca0727094ddf44436274436d2853d6d'
|
||||||
mod 'fluentd',
|
mod 'fluentd',
|
||||||
:git => 'git://github.com/enovance/puppet-fluentd.git',
|
:git => 'git://github.com/enovance/puppet-fluentd.git',
|
||||||
:ref => '474ad6d2b84f3d1e03000c2fc340ec1e3408488d'
|
:ref => '474ad6d2b84f3d1e03000c2fc340ec1e3408488d'
|
||||||
@@ -110,6 +113,9 @@ mod 'mysql',
|
|||||||
mod 'ntp',
|
mod 'ntp',
|
||||||
:git => 'git://github.com/enovance/puppetlabs-ntp.git',
|
:git => 'git://github.com/enovance/puppetlabs-ntp.git',
|
||||||
:ref => 'eb02ba2937ce86fb609ae41499767244b78ec58d'
|
:ref => 'eb02ba2937ce86fb609ae41499767244b78ec58d'
|
||||||
|
mod 'pacemaker',
|
||||||
|
:git => 'git://github.com/enovance/puppet-pacemaker.git',
|
||||||
|
:ref => '7e304243b5bd2dced5f54d5146ecc58d0b5a51f1'
|
||||||
mod 'rabbitmq',
|
mod 'rabbitmq',
|
||||||
:git => 'git://github.com/enovance/puppetlabs-rabbitmq.git',
|
:git => 'git://github.com/enovance/puppetlabs-rabbitmq.git',
|
||||||
:ref => '25420cb3c26c9a8432ab519d43c094d614d4fec4'
|
:ref => '25420cb3c26c9a8432ab519d43c094d614d4fec4'
|
||||||
|
|||||||
@@ -22,6 +22,9 @@
|
|||||||
# [*cluster_ip*]
|
# [*cluster_ip*]
|
||||||
# (optional) Interface used by Corosync to send multicast traffic
|
# (optional) Interface used by Corosync to send multicast traffic
|
||||||
# Defaults to '127.0.0.1'
|
# Defaults to '127.0.0.1'
|
||||||
|
# [*cluster_members*]
|
||||||
|
# (required on Red Hat) A space-separted list of cluster IP's or names
|
||||||
|
# Defaults to false
|
||||||
#
|
#
|
||||||
# [*multicast_address*]
|
# [*multicast_address*]
|
||||||
# (optionnal) IP address used to send multicast traffic
|
# (optionnal) IP address used to send multicast traffic
|
||||||
@@ -30,73 +33,120 @@
|
|||||||
|
|
||||||
class cloud::spof(
|
class cloud::spof(
|
||||||
$cluster_ip = '127.0.0.1',
|
$cluster_ip = '127.0.0.1',
|
||||||
$multicast_address = '239.1.1.2'
|
$cluster_members = false,
|
||||||
|
$multicast_address = '239.1.1.2',
|
||||||
|
$cluster_password = 'secrete'
|
||||||
) {
|
) {
|
||||||
|
|
||||||
class { 'corosync':
|
if $::osfamily == 'RedHat' {
|
||||||
enable_secauth => false,
|
if ! $cluster_members {
|
||||||
authkey => '/var/lib/puppet/ssl/certs/ca.pem',
|
fail('cluster_members is a required parameter.')
|
||||||
bind_address => $cluster_ip,
|
|
||||||
multicast_address => $multicast_address
|
|
||||||
}
|
|
||||||
|
|
||||||
corosync::service { 'pacemaker':
|
|
||||||
version => '0',
|
|
||||||
}
|
|
||||||
|
|
||||||
Package['corosync'] ->
|
|
||||||
cs_property {
|
|
||||||
'no-quorum-policy': value => 'ignore';
|
|
||||||
'stonith-enabled': value => 'false';
|
|
||||||
'pe-warn-series-max': value => 1000;
|
|
||||||
'pe-input-series-max': value => 1000;
|
|
||||||
'cluster-recheck-interval': value => '5min';
|
|
||||||
} ->
|
|
||||||
file { '/usr/lib/ocf/resource.d/heartbeat/ceilometer-agent-central':
|
|
||||||
source => 'puppet:///modules/cloud/heartbeat/ceilometer-agent-central',
|
|
||||||
mode => '0755',
|
|
||||||
owner => 'root',
|
|
||||||
group => 'root',
|
|
||||||
} ->
|
|
||||||
cs_primitive { 'ceilometer-agent-central':
|
|
||||||
primitive_class => 'ocf',
|
|
||||||
primitive_type => 'ceilometer-agent-central',
|
|
||||||
provided_by => 'heartbeat',
|
|
||||||
operations => {
|
|
||||||
'monitor' => {
|
|
||||||
interval => '10s',
|
|
||||||
timeout => '30s'
|
|
||||||
},
|
|
||||||
'start' => {
|
|
||||||
interval => '0',
|
|
||||||
timeout => '30s',
|
|
||||||
on-fail => 'restart'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} ->
|
|
||||||
file { '/usr/lib/ocf/resource.d/heartbeat/heat-engine':
|
class { 'pacemaker':
|
||||||
source => 'puppet:///modules/cloud/heartbeat/heat-engine',
|
hacluster_pwd => $cluster_password
|
||||||
mode => '0755',
|
}
|
||||||
owner => 'root',
|
|
||||||
group => 'root',
|
class { 'pacemaker::corosync':
|
||||||
} ->
|
cluster_name => 'openstack',
|
||||||
cs_primitive { 'heat-engine':
|
cluster_members => $cluster_members
|
||||||
primitive_class => 'ocf',
|
}
|
||||||
primitive_type => 'heat-engine',
|
|
||||||
provided_by => 'heartbeat',
|
class {'pacemaker::stonith':
|
||||||
operations => {
|
disable => true
|
||||||
'monitor' => {
|
} ->
|
||||||
interval => '10s',
|
file { '/usr/lib/ocf/resource.d/heartbeat/ceilometer-agent-central':
|
||||||
timeout => '30s'
|
source => 'puppet:///modules/cloud/heartbeat/ceilometer-agent-central',
|
||||||
},
|
mode => '0755',
|
||||||
'start' => {
|
owner => 'root',
|
||||||
interval => '0',
|
group => 'root',
|
||||||
timeout => '30s',
|
} ->
|
||||||
on-fail => 'restart'
|
exec {'pcmk_ceilometer_agent_central':
|
||||||
|
command => 'pcs resource create ceilometer-agent-central ocf:heartbeat:ceilometer-agent-central',
|
||||||
|
path => ['/usr/bin','/usr/sbin','/sbin/','/bin'],
|
||||||
|
user => 'root',
|
||||||
|
unless => '/usr/sbin/pcs resource | /bin/grep ceilometer-agent-central | /bin/grep Started'
|
||||||
|
}
|
||||||
|
file { '/usr/lib/ocf/resource.d/heartbeat/heat-engine':
|
||||||
|
source => 'puppet:///modules/cloud/heartbeat/heat-engine',
|
||||||
|
mode => '0755',
|
||||||
|
owner => 'root',
|
||||||
|
group => 'root',
|
||||||
|
} ->
|
||||||
|
exec {'pcmk_heat_engine':
|
||||||
|
command => 'pcs resource create heat-engine ocf:heartbeat:heat-engine',
|
||||||
|
path => ['/usr/bin','/usr/sbin','/sbin/','/bin'],
|
||||||
|
user => 'root',
|
||||||
|
unless => '/usr/sbin/pcs resource | /bin/grep heat-engine | /bin/grep Started'
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
|
class { 'corosync':
|
||||||
|
enable_secauth => false,
|
||||||
|
authkey => '/var/lib/puppet/ssl/certs/ca.pem',
|
||||||
|
bind_address => $cluster_ip,
|
||||||
|
multicast_address => $multicast_address
|
||||||
|
}
|
||||||
|
|
||||||
|
corosync::service { 'pacemaker':
|
||||||
|
version => '0',
|
||||||
|
}
|
||||||
|
|
||||||
|
Package['corosync'] ->
|
||||||
|
cs_property {
|
||||||
|
'no-quorum-policy': value => 'ignore';
|
||||||
|
'stonith-enabled': value => 'false';
|
||||||
|
'pe-warn-series-max': value => 1000;
|
||||||
|
'pe-input-series-max': value => 1000;
|
||||||
|
'cluster-recheck-interval': value => '5min';
|
||||||
|
} ->
|
||||||
|
file { '/usr/lib/ocf/resource.d/heartbeat/ceilometer-agent-central':
|
||||||
|
source => 'puppet:///modules/cloud/heartbeat/ceilometer-agent-central',
|
||||||
|
mode => '0755',
|
||||||
|
owner => 'root',
|
||||||
|
group => 'root',
|
||||||
|
} ->
|
||||||
|
cs_primitive { 'ceilometer-agent-central':
|
||||||
|
primitive_class => 'ocf',
|
||||||
|
primitive_type => 'ceilometer-agent-central',
|
||||||
|
provided_by => 'heartbeat',
|
||||||
|
operations => {
|
||||||
|
'monitor' => {
|
||||||
|
interval => '10s',
|
||||||
|
timeout => '30s'
|
||||||
|
},
|
||||||
|
'start' => {
|
||||||
|
interval => '0',
|
||||||
|
timeout => '30s',
|
||||||
|
on-fail => 'restart'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} ->
|
||||||
|
file { '/usr/lib/ocf/resource.d/heartbeat/heat-engine':
|
||||||
|
source => 'puppet:///modules/cloud/heartbeat/heat-engine',
|
||||||
|
mode => '0755',
|
||||||
|
owner => 'root',
|
||||||
|
group => 'root',
|
||||||
|
} ->
|
||||||
|
cs_primitive { 'heat-engine':
|
||||||
|
primitive_class => 'ocf',
|
||||||
|
primitive_type => 'heat-engine',
|
||||||
|
provided_by => 'heartbeat',
|
||||||
|
operations => {
|
||||||
|
'monitor' => {
|
||||||
|
interval => '10s',
|
||||||
|
timeout => '30s'
|
||||||
|
},
|
||||||
|
'start' => {
|
||||||
|
interval => '0',
|
||||||
|
timeout => '30s',
|
||||||
|
on-fail => 'restart'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Run OpenStack SPOF service and disable them since they will be managed by Corosync.
|
# Run OpenStack SPOF service and disable them since they will be managed by Corosync.
|
||||||
class { 'cloud::orchestration::engine':
|
class { 'cloud::orchestration::engine':
|
||||||
enabled => false,
|
enabled => false,
|
||||||
|
|||||||
130
spec/classes/cloud_spof_spec.rb
Normal file
130
spec/classes/cloud_spof_spec.rb
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
#
|
||||||
|
# Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
# Unit tests for cloud::spof class
|
||||||
|
#
|
||||||
|
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe 'cloud::spof' do
|
||||||
|
|
||||||
|
shared_examples_for 'cloud spof' do
|
||||||
|
|
||||||
|
let :params do
|
||||||
|
{ :cluster_ip => '10.0.0.1',
|
||||||
|
:multicast_address => '239.1.1.2',
|
||||||
|
:cluster_members => false,
|
||||||
|
:cluster_password => 'verysecrete' }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with Pacemaker on Debian' do
|
||||||
|
before :each do
|
||||||
|
facts.merge!( :osfamily => 'Debian' )
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'configure pacemaker/corosync' do
|
||||||
|
should contain_class('corosync').with(
|
||||||
|
:enable_secauth => false,
|
||||||
|
:authkey => '/var/lib/puppet/ssl/certs/ca.pem',
|
||||||
|
:bind_address => '10.0.0.1',
|
||||||
|
:multicast_address => '239.1.1.2',
|
||||||
|
)
|
||||||
|
should contain_file('/usr/lib/ocf/resource.d/heartbeat/ceilometer-agent-central').with(
|
||||||
|
:source => 'puppet:///modules/cloud/heartbeat/ceilometer-agent-central',
|
||||||
|
:mode => '0755',
|
||||||
|
:owner => 'root',
|
||||||
|
:group => 'root'
|
||||||
|
)
|
||||||
|
should contain_file('/usr/lib/ocf/resource.d/heartbeat/heat-engine').with(
|
||||||
|
:source => 'puppet:///modules/cloud/heartbeat/heat-engine',
|
||||||
|
:mode => '0755',
|
||||||
|
:owner => 'root',
|
||||||
|
:group => 'root'
|
||||||
|
)
|
||||||
|
should contain_class('cloud::orchestration::engine').with(:enabled => false)
|
||||||
|
should contain_class('cloud::telemetry::centralagent').with(:enabled => false)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with Pacemaker on Red-Hat' do
|
||||||
|
before :each do
|
||||||
|
facts.merge!( :osfamily => 'RedHat' )
|
||||||
|
params.merge!( :cluster_members => 'srv1 srv2 srv3')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'configure pacemaker/corosync' do
|
||||||
|
should contain_class('pacemaker').with(:hacluster_pwd => 'verysecrete')
|
||||||
|
should contain_class('pacemaker::stonith').with(:disable => true)
|
||||||
|
should contain_class('pacemaker::corosync').with(
|
||||||
|
:cluster_name => 'openstack',
|
||||||
|
:cluster_members => 'srv1 srv2 srv3')
|
||||||
|
should contain_file('/usr/lib/ocf/resource.d/heartbeat/ceilometer-agent-central').with(
|
||||||
|
:source => 'puppet:///modules/cloud/heartbeat/ceilometer-agent-central',
|
||||||
|
:mode => '0755',
|
||||||
|
:owner => 'root',
|
||||||
|
:group => 'root'
|
||||||
|
)
|
||||||
|
should contain_file('/usr/lib/ocf/resource.d/heartbeat/heat-engine').with(
|
||||||
|
:source => 'puppet:///modules/cloud/heartbeat/heat-engine',
|
||||||
|
:mode => '0755',
|
||||||
|
:owner => 'root',
|
||||||
|
:group => 'root'
|
||||||
|
)
|
||||||
|
should contain_exec('pcmk_ceilometer_agent_central').with(
|
||||||
|
:command => 'pcs resource create ceilometer-agent-central ocf:heartbeat:ceilometer-agent-central',
|
||||||
|
:path => ['/usr/bin','/usr/sbin','/sbin/','/bin'],
|
||||||
|
:user => 'root',
|
||||||
|
:unless => '/usr/sbin/pcs resource | /bin/grep ceilometer-agent-central | /bin/grep Started'
|
||||||
|
)
|
||||||
|
should contain_exec('pcmk_heat_engine').with(
|
||||||
|
:command => 'pcs resource create heat-engine ocf:heartbeat:heat-engine',
|
||||||
|
:path => ['/usr/bin','/usr/sbin','/sbin/','/bin'],
|
||||||
|
:user => 'root',
|
||||||
|
:unless => '/usr/sbin/pcs resource | /bin/grep heat-engine | /bin/grep Started'
|
||||||
|
)
|
||||||
|
should contain_class('cloud::orchestration::engine').with(:enabled => false)
|
||||||
|
should contain_class('cloud::telemetry::centralagent').with(:enabled => false)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with Pacemaker on Red-Hat with missing parameters' do
|
||||||
|
before :each do
|
||||||
|
facts.merge!( :osfamily => 'RedHat' )
|
||||||
|
params.merge!( :cluster_members => false)
|
||||||
|
end
|
||||||
|
it { should compile.and_raise_error(/cluster_members is a required parameter./) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'on Debian platforms' do
|
||||||
|
let :facts do
|
||||||
|
{ :osfamily => 'Debian',
|
||||||
|
:concat_basedir => '/var/lib/puppet/concat',
|
||||||
|
:uniqueid => '123' }
|
||||||
|
end
|
||||||
|
|
||||||
|
it_configures 'cloud spof'
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'on RedHat platforms' do
|
||||||
|
let :facts do
|
||||||
|
{ :osfamily => 'RedHat',
|
||||||
|
:concat_basedir => '/var/lib/puppet/concat',
|
||||||
|
:uniqueid => '123' }
|
||||||
|
end
|
||||||
|
it_configures 'cloud spof'
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user