Skip to content

Commit

Permalink
Test corosync config where appropriate
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
  • Loading branch information
roidelapluie committed Jun 27, 2016
1 parent bb34bf9 commit 7f1b6c1
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 11 deletions.
35 changes: 28 additions & 7 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@
# to 256000 / netmtu to prevent overflow of the kernel transmit buffers.
# Defaults to 17
#
# [*test_corosync_config*]
# Wheter we should test new configuration files with `corosync -t`.
# Defaults to true on OS that allows that (requires corosync 2.3.4).
#
# === Examples
#
# class { 'corosync':
Expand Down Expand Up @@ -251,6 +255,7 @@
$join = $::corosync::params::join,
$consensus = $::corosync::params::consensus,
$max_messages = $::corosync::params::max_messages,
$test_corosync_config = $::corosync::params::test_corosync_config,
) inherits ::corosync::params {

if $set_votequorum and !$quorum_members {
Expand Down Expand Up @@ -370,13 +375,29 @@
# - $join
# - $consensus
# - $max_messages
file { '/etc/corosync/corosync.conf':
ensure => file,
mode => '0644',
owner => 'root',
group => 'root',
content => template($corosync_conf),
require => Package['corosync'],
if $test_corosync_config {
# corosync -t is only included since 2.3.4
file { '/etc/corosync/corosync.conf':
ensure => file,
mode => '0644',
owner => 'root',
group => 'root',
content => template($corosync_conf),
validate_cmd => '/usr/bin/env COROSYNC_MAIN_CONFIG_FILE=% /usr/sbin/corosync -t',
require => [
File['/etc/corosync/authkey'],
Package['corosync'],
],
}
} else {
file { '/etc/corosync/corosync.conf':
ensure => file,
mode => '0644',
owner => 'root',
group => 'root',
content => template($corosync_conf),
require => Package['corosync'],
}
}

file { '/etc/corosync/service.d':
Expand Down
21 changes: 17 additions & 4 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@
$compatibility = 'whitetank'
if versioncmp($::operatingsystemrelease, '7') >= 0 {
$manage_pacemaker_service = true
$test_corosync_config = true
} else {
$manage_pacemaker_service = false
$test_corosync_config = false
}
$package_install_options = undef
}
Expand All @@ -54,15 +56,23 @@
$set_votequorum = true
$manage_pacemaker_service = true

file {'/etc/default/cman':
ensure => present,
content => template('corosync/cman.erb'),
}
if versioncmp($::operatingsystemrelease, '16.04') >= 0 {
$test_corosync_config = true
} else {

#FIXME should be moved in another place
file {'/etc/default/cman':
ensure => present,
content => template('corosync/cman.erb'),
}

$test_corosync_config = false
}
} else {
$compatibility = 'whitetank'
$set_votequorum = false
$manage_pacemaker_service = false
$test_corosync_config = false
}
$package_install_options = undef
}
Expand All @@ -72,18 +82,21 @@
$compatibility = false
$manage_pacemaker_service = true
$package_install_options = ['-t', 'jessie-backports']
$test_corosync_config = true
} else {
$set_votequorum = false
$compatibility = 'whitetank'
$manage_pacemaker_service = false
$package_install_options = undef
$test_corosync_config = false
}
}
default : {
$compatibility = 'whitetank'
$set_votequorum = false
$manage_pacemaker_service = false
$package_install_options = undef
$test_corosync_config = false
}
}
}
Expand Down
16 changes: 16 additions & 0 deletions spec/classes/corosync_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,12 @@
}
end

it 'validates the corosync configuration' do
should contain_file('/etc/corosync/corosync.conf').with_validate_cmd(
'/usr/bin/env COROSYNC_MAIN_CONFIG_FILE=% /usr/sbin/corosync -t'
)
end

it_configures 'corosync'
end

Expand All @@ -269,6 +275,10 @@
it 'does not manage the pacemaker service' do
should_not contain_service('pacemaker')
end

it 'does not validate the corosync configuration' do
should contain_file('/etc/corosync/corosync.conf').without_validate_cmd
end
end

context 'major version is 7' do
Expand All @@ -283,6 +293,12 @@
ensure: 'running'
)
end

it 'validates the corosync configuration' do
should contain_file('/etc/corosync/corosync.conf').with_validate_cmd(
'/usr/bin/env COROSYNC_MAIN_CONFIG_FILE=% /usr/sbin/corosync -t'
)
end
end
end
end

0 comments on commit 7f1b6c1

Please sign in to comment.