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

Define the names of the quorum members #407

Merged
merged 1 commit into from
Oct 26, 2017
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
10 changes: 10 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@
# Should be used only with the quorum_members parameter.
# Defaults to undef
#
# [*quorum_members_names*]
# Array of quorum member names. Persistent names are required when you
# define IP addresses in quorum_members.
# Defaults to undef
#
# [*token*]
# Time (in ms) to wait for a token
#
Expand Down Expand Up @@ -266,6 +271,7 @@
$votequorum_expected_votes = $::corosync::params::votequorum_expected_votes,
$quorum_members = ['localhost'],
$quorum_members_ids = undef,
$quorum_members_names = undef,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though we haven't switched to data types yet for the whole module, should probably add this as Optional[Array] $quorum_members_names

$token = $::corosync::params::token,
$token_retransmits_before_loss_const = $::corosync::params::token_retransmits_before_loss_const,
$compatibility = $::corosync::params::compatibility,
Expand All @@ -282,6 +288,10 @@
fail('set_votequorum is true, but no quorum_members have been passed.')
}

if $quorum_members_names and !$quorum_members {
fail('quorum_members_names may not be used without the quorum_members.')
}

if $quorum_members_ids and !$quorum_members {
fail('quorum_members_ids may not be used without the quorum_members.')
}
Expand Down
28 changes: 28 additions & 0 deletions spec/classes/corosync_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,20 @@
%r{ring0_addr\: node2\.test\.org\n\s*nodeid: 11}
)
end

it 'supports persistent node names' do
params[:quorum_members] = ['192.168.0.1', '192.168.0.2']
params[:quorum_members_names] = ['node1.test.org', 'node2.test.org']
is_expected.to contain_file('/etc/corosync/corosync.conf').with_content(
%r{nodelist}
)
is_expected.to contain_file('/etc/corosync/corosync.conf').with_content(
%r{ring0_addr\: 192\.168\.0\.1\n\s*nodeid: 1\n\s*name: node1\.test\.org}
)
is_expected.to contain_file('/etc/corosync/corosync.conf').with_content(
%r{ring0_addr\: 192\.168\.0\.2\n\s*nodeid: 2\n\s*name: node2\.test\.org}
)
end
end

context 'when quorum_members is set to an array with 3 items' do
Expand Down Expand Up @@ -201,6 +215,20 @@
%r{ring0_addr\: node2\.test\.org\n\s*nodeid: 11}
)
end

it 'supports persistent node names' do
params[:quorum_members] = ['192.168.0.1', '192.168.0.2']
params[:quorum_members_names] = ['node1.test.org', 'node2.test.org']
is_expected.to contain_file('/etc/corosync/corosync.conf').with_content(
%r{nodelist}
)
is_expected.to contain_file('/etc/corosync/corosync.conf').with_content(
%r{ring0_addr\: 192\.168\.0\.1\n\s*nodeid: 1\n\s*name: node1\.test\.org}
)
is_expected.to contain_file('/etc/corosync/corosync.conf').with_content(
%r{ring0_addr\: 192\.168\.0\.2\n\s*nodeid: 2\n\s*name: node2\.test\.org}
)
end
end

context 'witout secauth' do
Expand Down
3 changes: 3 additions & 0 deletions templates/corosync.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ nodelist {
nodeid: <%= i+1 %>
<% else -%>
nodeid: <%= [@quorum_members_ids].flatten[i] %>
<% end -%>
<% if not @quorum_members_names.nil? -%>
name: <%= [@quorum_members_names].flatten[i] %>
<% end -%>
}
<% end -%>
Expand Down