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

Add EL8 & EL9 support and claim compatibility #553

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
3,749 changes: 1,879 additions & 1,870 deletions REFERENCE.md

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions data/os/CentOS/9.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
corosync::config_validate_cmd: "/usr/sbin/corosync -c % -t"
corosync::highavailability_repo: "highavailability"
3 changes: 3 additions & 0 deletions data/os/RedHat/8.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
corosync::config_validate_cmd: "/usr/sbin/corosync -c % -t"
corosync::highavailability_repo: "rhel-8-for-x86_64-highavailability-rpms"
3 changes: 3 additions & 0 deletions data/os/RedHat/9.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
corosync::config_validate_cmd: "/usr/sbin/corosync -c % -t"
corosync::highavailability_repo: "rhel-9-for-x86_64-highavailability-rpms"
2 changes: 1 addition & 1 deletion lib/puppet/provider/cs_clone/pcs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def change_clone_id(type, primitive, id, cib)
return unless doc.root.attributes['id'] != id

doc.root.attributes['id'] = id
cmd = [command(:cibadmin), '--replace', '--xpath', xpath, '--xml-text', doc.to_s.chop]
cmd = [command(:cibadmin), '--replace', '--xpath', xpath, '--xml-text', doc.to_s.chomp]
self.class.run_command_in_cib(cmd, cib)
end

Expand Down
27 changes: 27 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@
# Additional install-options for the pcs package resource.
# Default: undef
#
# @param highavailability_repo
# Whether the module should enable the corosync service.
#
# @param ensure_corosync
# Define what version of the corosync package should be installed.
# Default: 'present'
Expand Down Expand Up @@ -404,6 +407,7 @@
Optional[Variant[Stdlib::Absolutepath, Enum['off']]] $watchdog_device = undef,
Enum['pcs', 'crm'] $provider = 'pcs',
String $pcs_version = '', # lint:ignore:params_empty_string_assignment
Optional[String] $highavailability_repo = undef,
) inherits corosync::params {
if $set_votequorum and (empty($quorum_members) and empty($multicast_address) and !$cluster_name) {
fail('set_votequorum is true, so you must set either quorum_members, or one of multicast_address or cluster_name.')
Expand All @@ -417,6 +421,29 @@
fail('quorum_members_ids may not be used without the quorum_members.')
}

# Enable High Availability repository
case $facts['os']['name'] {
'RedHat': {
if $facts['os']['release']['major'] > '7' {
exec { 'enable_highavailability_repo':
command => "subscription-manager repos --enable=${highavailability_repo}",
path => '/usr/bin:/usr/sbin:/bin:/sbin',
unless => "yum repolist enabled | grep -q ${highavailability_repo}",
}
}
}
'CentOS': {
if $facts['os']['release']['major'] == '9' {
exec { 'enable_highavailability_repo':
command => "yum config-manager --set-enabled ${highavailability_repo}",
path => '/usr/bin:/usr/sbin:/bin:/sbin',
unless => "yum repolist enabled | grep -q ${highavailability_repo}",
}
}
}
default: {}
}

if $package_corosync {
package { 'corosync':
ensure => $ensure_corosync,
Expand Down
3 changes: 2 additions & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"7"
"7",
"8"
]
},
{
Expand Down
136 changes: 75 additions & 61 deletions spec/classes/corosync_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@
)
end

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

context 'validates the corosncy configuration when config_validate_cmd is set' do
let(:params) do
super().merge(
Expand Down Expand Up @@ -68,13 +62,13 @@
%r{nodelist}
)
is_expected.to contain_file('/etc/corosync/corosync.conf').with_content(
%r{ring0_addr: node1\.test\.org\n\s*nodeid: 1}
%r{^\s*ring0_addr:\s*node1\.test\.org\s*(?:\r\n|\n)\s*nodeid:\s*1\s*}
)
is_expected.to contain_file('/etc/corosync/corosync.conf').with_content(
%r{ring0_addr: node2\.test\.org\n\s*nodeid: 2}
%r{^\s*ring0_addr:\s*node2\.test\.org\s*(?:\r\n|\n)\s*nodeid:\s*2\s*}
)
is_expected.to contain_file('/etc/corosync/corosync.conf').with_content(
%r{two_node: 1\n}
%r{^\s*two_node:\s*1}
)
end

Expand All @@ -86,10 +80,10 @@
%r{nodelist}
)
is_expected.to contain_file('/etc/corosync/corosync.conf').with_content(
%r{ring0_addr: node1\.test\.org\n\s*nodeid: 3}
%r{^\s*ring0_addr:\s*node1\.test\.org\s*(?:\r\n|\n)\s*nodeid:\s*3}
)
is_expected.to contain_file('/etc/corosync/corosync.conf').with_content(
%r{ring0_addr: node2\.test\.org\n\s*nodeid: 11}
%r{^\s*ring0_addr:\s*node2\.test\.org\s*(?:\r\n|\n)\s*nodeid:\s*11}
)
end
end
Expand All @@ -107,10 +101,10 @@
%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}
%r{^\s*ring0_addr:\s*192\.168\.0\.1(?:\r\n|\n)\s*nodeid:\s*1(?:\r\n|\n)\s*name:\s*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}
%r{^\s*ring0_addr:\s*192\.168\.0\.2(?:\r\n|\n)\s*nodeid:\s*2(?:\r\n|\n)\s*name:\s*node2\.test\.org}
)
end
end
Expand All @@ -126,7 +120,7 @@

it 'does not configure two_nodes option' do
is_expected.not_to contain_file('/etc/corosync/corosync.conf').with_content(
%r{two_node: 1\n}
%r{^\s*two_node:\s*1}
)
end
end
Expand All @@ -140,7 +134,7 @@

it 'configures two_node' do
is_expected.to contain_file('/etc/corosync/corosync.conf').with_content(
%r{two_node: 1\n}
%r{^\s*two_node:\s*1}
)
end
end
Expand All @@ -158,13 +152,13 @@
%r{nodelist}
)
is_expected.to contain_file('/etc/corosync/corosync.conf').with_content(
%r{ring0_addr: node1\.test\.org\n\s*nodeid: 1}
%r{^\s*ring0_addr:\s*node1\.test\.org(?:\r\n|\n)\s*nodeid:\s*1}
)
is_expected.to contain_file('/etc/corosync/corosync.conf').with_content(
%r{ring0_addr: node2\.test\.org\n\s*nodeid: 2}
%r{^\s*ring0_addr:\s*node2\.test\.org(?:\r\n|\n)\s*nodeid:\s*2}
)
is_expected.to contain_file('/etc/corosync/corosync.conf').with_content(
%r{two_node: 1\n}
%r{^\s*two_node:\s*1}
)
end
end
Expand All @@ -184,14 +178,14 @@
(1..4).each do |node_id|
it "configures rings for host #{node_id} correctly" do
is_expected.to contain_file('/etc/corosync/corosync.conf').with_content(
%r{ring0_addr: 172.31.10.#{node_id}\n\s*ring1_addr: 172.31.11.#{node_id}\n\s*ring2_addr: 172.31.12.#{node_id}\n\s*nodeid: #{node_id}}
%r{ring0_addr: 172.31.10.#{node_id}(?:\r\n|\n)\s*ring1_addr: 172.31.11.#{node_id}(?:\r\n|\n)\s*ring2_addr: 172.31.12.#{node_id}(?:\r\n|\n)\s*nodeid: #{node_id}}
)
end
end

it 'does not configure two_nodes option' do
is_expected.not_to contain_file('/etc/corosync/corosync.conf').with_content(
%r{two_node: 1\n}
%r{^\s*two_node:\s*1}
)
end
end
Expand All @@ -209,14 +203,14 @@
(1..2).each do |node_id|
it "configures rings for host #{node_id} correctly" do
is_expected.to contain_file('/etc/corosync/corosync.conf').with_content(
%r{ring0_addr: 172.31.10.#{node_id}\n\s*ring1_addr: 172.31.11.#{node_id}\n\s*ring2_addr: 172.31.12.#{node_id}\n\s*nodeid: #{node_id}}
%r{ring0_addr: 172.31.10.#{node_id}(?:\r\n|\n)\s*ring1_addr: 172.31.11.#{node_id}(?:\r\n|\n)\s*ring2_addr: 172.31.12.#{node_id}(?:\r\n|\n)\s*nodeid: #{node_id}}
)
end
end

it 'configures two_node' do
is_expected.to contain_file('/etc/corosync/corosync.conf').with_content(
%r{two_node: 1\n}
%r{^\s*two_node:\s*1}
)
end
end
Expand All @@ -243,13 +237,13 @@
%r{nodelist}
)
is_expected.to contain_file('/etc/corosync/corosync.conf').with_content(
%r{ring0_addr: node1\.test\.org\n\s*nodeid: 1}
%r{^\s*ring0_addr: node1\.test\.org(?:\r\n|\n)\s*nodeid:\s*1}
)
is_expected.to contain_file('/etc/corosync/corosync.conf').with_content(
%r{ring0_addr: node2\.test\.org\n\s*nodeid: 2}
%r{^\s*ring0_addr: node2\.test\.org(?:\r\n|\n)\s*nodeid:\s*2}
)
is_expected.to contain_file('/etc/corosync/corosync.conf').with_content(
%r{two_node: 1\n}
%r{^\s*two_node:\s*1}
)
end

Expand All @@ -259,10 +253,10 @@
%r{nodelist}
)
is_expected.to contain_file('/etc/corosync/corosync.conf').with_content(
%r{ring0_addr: node1\.test\.org\n\s*nodeid: 3}
%r{^\s*ring0_addr:\s*node1\.test\.org(?:\r\n|\n)\s*nodeid:\s*3}
)
is_expected.to contain_file('/etc/corosync/corosync.conf').with_content(
%r{ring0_addr: node2\.test\.org\n\s*nodeid: 11}
%r{^\s*ring0_addr:\s*node2\.test\.org(?:\r\n|(?:\r\n|\n))\s*nodeid:\s*11}
)
end

Expand All @@ -273,10 +267,10 @@
%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}
%r{^\s*ring0_addr: 192\.168\.0\.1(?:\r\n|\n)\s*nodeid:\s*1(?:\r\n|\n)\s*name:\s*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}
%r{^\s*ring0_addr: 192\.168\.0\.2(?:\r\n|\n)\s*nodeid:\s*2(?:\r\n|\n)\s*name:\s*node2\.test\.org}
)
end
end
Expand Down Expand Up @@ -337,7 +331,7 @@

it 'configures cluster_name' do
is_expected.to contain_file('/etc/corosync/corosync.conf').with_content(
%r{cluster_name:\s*hacell$}
%r{^\s*cluster_name:\s*hacell}
)
end
end
Expand Down Expand Up @@ -541,9 +535,7 @@
end

it 'is set in corosync.conf' do
is_expected.to contain_file('/etc/corosync/corosync.conf').with_content(
%r{#{optional_parameter}:\s*#{possible_value}\n}
)
is_expected.to contain_file('/etc/corosync/corosync.conf').with_content(%r{#{optional_parameter}:\s*#{Regexp.escape(possible_value.to_s)}\s*\n})
end
end
end
Expand Down Expand Up @@ -730,6 +722,27 @@

it_configures 'corosync'

# Check the correct validation command is used for each OS
it 'validates the corosync configuration' do
case os_facts[:os]['family']
when 'RedHat'
case os_facts[:os]['release']['major'].to_i
when 0..7
is_expected.to contain_file('/etc/corosync/corosync.conf').with_validate_cmd(
'/usr/bin/env COROSYNC_MAIN_CONFIG_FILE=% /usr/sbin/corosync -t'
)
else
is_expected.to contain_file('/etc/corosync/corosync.conf').with_validate_cmd(
'/usr/sbin/corosync -c % -t'
)
end
else
is_expected.to contain_file('/etc/corosync/corosync.conf').with_validate_cmd(
'/usr/bin/env COROSYNC_MAIN_CONFIG_FILE=% /usr/sbin/corosync -t'
)
end
end

# Check default package installations per platform
case os_facts[:os]['family']
when 'RedHat'
Expand Down Expand Up @@ -942,9 +955,7 @@

it 'does not contain the quorum device config in corosync.conf' do
is_expected.to contain_file('/etc/corosync/corosync.conf').with_content(
%r!quorum {
provider: corosync_votequorum
}$!m
%r{quorum\s*\{\s*provider:\s*corosync_votequorum\s*\}\s*}
)
end

Expand All @@ -963,18 +974,20 @@

it 'contains the quorum configuration' do
is_expected.to contain_file('/etc/corosync/corosync.conf').with_content(
%r!quorum {
provider: corosync_votequorum
device {
model: net
votes: 1

net {
algorithm: ffsplit
host: quorum1[.]test[.]org
}
}
}!m
%r{
quorum\s*\{
\s*provider:\s*corosync_votequorum
\s*device\s*\{
\s*model:\s*net
\s*votes:\s*1
\s*
\s*net\s*\{
\s*algorithm:\s*ffsplit
\s*host:\s*quorum1\.test\.org
\s*\}
\s*\}
\s*\}
}x
)
end

Expand Down Expand Up @@ -1050,18 +1063,19 @@

it 'contains the quorum configuration' do
is_expected.to contain_file('/etc/corosync/corosync.conf').with_content(
%r!quorum {
provider: corosync_votequorum
device {
model: net
votes: 1

net {
algorithm: ffsplit
host: quorum1[.]test[.]org
}
}
}!m
%r{
quorum\s*\{
\s*provider:\s*corosync_votequorum # Match 'provider: corosync_votequorum'
\s*device\s*\{
\s*model:\s*net
\s*votes:\s*1
\s*net\s*\{
\s*algorithm:\s*ffsplit
\s*host:\s*quorum1\.test\.org
\s*\}
\s*\}
\s*\}
}x
)
end
end
Expand All @@ -1079,7 +1093,7 @@

it 'does not configure two node' do
is_expected.not_to contain_file('/etc/corosync/corosync.conf').with_content(
%r{two_node: 1\n}
%r{^\s*two_node:\s*1}
)
end
# else - to implement
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/puppet/provider/cs_clone_pcs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def clone_xml(name)
Puppet::Util::Execution.expects(:execute).with(['cibadmin', '--query', '--xpath', xpath], failonfail: true, combine: true).at_least_once.returns(
Puppet::Util::Execution::ProcessOutput.new(clone_xml('apache_service-clone'), 0)
)
Puppet::Util::Execution.expects(:execute).with(['cibadmin', '--replace', '--xpath', xpath, '--xml-text', clone_xml('apache_service-newclone').chop], failonfail: true, combine: true).at_least_once.returns(
Puppet::Util::Execution.expects(:execute).with(['cibadmin', '--replace', '--xpath', xpath, '--xml-text', clone_xml('apache_service-newclone').chomp], failonfail: true, combine: true).at_least_once.returns(
Puppet::Util::Execution::ProcessOutput.new('', 0)
)
instance.change_clone_id('primitive', 'apache_service', 'apache_service-newclone', nil)
Expand Down
Loading