Skip to content

Commit

Permalink
Allow multiple rings in nodelist and validate rrp_mode
Browse files Browse the repository at this point in the history
Closes #262
  • Loading branch information
rhamon committed Jun 23, 2016
1 parent bb34bf9 commit fc9f330
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
10 changes: 10 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@
# [*quorum_members*]
# Array of quorum member hostname. This is required if set_votequorum
# is set to true.
# You can also have an array of arrays to have multiple rings. In that case,
# each subarray matches a member IP addresses.
# Defaults to ['localhost']
#
# [*quorum_members_ids*]
Expand Down Expand Up @@ -312,6 +314,14 @@
fail('You must provide a value for multicast_address')
}

# $rrp_mode value of 'none' isn't allowed with multiple rings
if ( ( is_array($multicast_address) and size($multicast_address) > 1 )
or ( is_array($unicast_addresses) and is_array($unicast_addresses[0]) and size($unicast_addresses[0]) > 1 )
or ( is_array($quorum_members) and is_array($quorum_members[0]) and size($quorum_members[0]) > 1 ) )
and $rrp_mode == 'none' {
fail('You must set rrp_mode to active or passive with multiple rings')
}

case $enable_secauth {
true: { $enable_secauth_real = 'on' }
false: { $enable_secauth_real = 'off' }
Expand Down
8 changes: 5 additions & 3 deletions templates/corosync.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,19 @@ quorum {
two_node: 1
<% end -%>
<% else -%>
<% if [@quorum_members].flatten.count == 2 -%>
<% if Array(@quorum_members).length == 2 -%>
two_node: 1
<% end -%>
<% end -%>
}

<% unless @votequorum_expected_votes -%>
nodelist {
<% [@quorum_members].flatten.each_index do |i| -%>
<% Array(@quorum_members).each_index do |i| -%>
node {
ring0_addr: <%= [@quorum_members].flatten[i] %>
<% Array(Array(@quorum_members.map{|node| Array(node).flatten})[i]).each_with_index do |addr,ring| -%>
ring<%= ring %>_addr: <%= addr %>
<% end -%>
<% if @quorum_members_ids.nil? -%>
nodeid: <%= i+1 %>
<% else -%>
Expand Down
14 changes: 8 additions & 6 deletions templates/corosync.conf.udpu.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ totem {
secauth: <%= @enable_secauth_real %>
threads: <%= @threads %>
transport: udpu
<% (0..Array(@unicast_addresses.first).length-1).each do |interface| -%>
<% Array(@unicast_addresses.first).each_index do |interface| -%>
interface {
<% @unicast_addresses.each do |addr| -%>
<% Array(Array(@unicast_addresses.map{|x| Array(x).flatten}).transpose[interface]).each do |addr| -%>
member {
memberaddr: <%= Array(addr)[interface] %>
memberaddr: <%= addr %>
}
<% end -%>
ringnumber: <%= interface %>
Expand Down Expand Up @@ -86,17 +86,19 @@ quorum {
two_node: 1
<% end -%>
<% else -%>
<% if [@quorum_members].flatten.count == 2 -%>
<% if Array(@quorum_members).length == 2 -%>
two_node: 1
<% end -%>
<% end -%>
}

<% unless @votequorum_expected_votes -%>
nodelist {
<% [@quorum_members].flatten.each_index do |i| -%>
<% Array(@quorum_members).each_index do |i| -%>
node {
ring0_addr: <%= [@quorum_members].flatten[i] %>
<% Array(Array(@quorum_members.map{|node| Array(node).flatten})[i]).each_with_index do |addr,ring| -%>
ring<%= ring %>_addr: <%= addr %>
<% end -%>
<% if @quorum_members_ids.nil? -%>
nodeid: <%= i+1 %>
<% else -%>
Expand Down

0 comments on commit fc9f330

Please sign in to comment.