Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test corosync config where appropriate #294

Merged
merged 1 commit into from
Aug 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -268,6 +268,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 @@ -288,6 +294,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 @@ -302,6 +312,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