From 2277369e59b82a73289bf37c72f1a36950aa8617 Mon Sep 17 00:00:00 2001 From: Philip DeMonaco Date: Sat, 1 Jul 2023 10:41:27 -0400 Subject: [PATCH] feat: include name in nodelist When the member list is names, not IP addresses, and the member name array is empty use the former to populate the name: in the nodelist. This addresses a parsing issue in `pcs cluster config` described in the redhat article below. It also ensures other commands that depend on the config file work as expected. https://access.redhat.com/solutions/6992919 --- manifests/init.pp | 2 +- spec/classes/corosync_spec.rb | 20 +++++++++++++++++++- templates/corosync.conf.erb | 2 ++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index bdd88044..272c4633 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -669,7 +669,7 @@ command => $quorum_setup_cmd, path => $exec_path, onlyif => [ - 'test 0 -ne $(pcs quorum config | grep "host:" >/dev/null 2>&1; echo $?)', + "test 0 -ne $(pcs quorum config | grep 'host: ${quorum_device_host}' >/dev/null 2>&1; echo $?)", ], require => Exec['authorize_qdevice'], before => File['/etc/corosync/corosync.conf'], diff --git a/spec/classes/corosync_spec.rb b/spec/classes/corosync_spec.rb index 1076a1ed..92b957ca 100644 --- a/spec/classes/corosync_spec.rb +++ b/spec/classes/corosync_spec.rb @@ -660,6 +660,7 @@ } ) end + auth_command = if corosync_stack(os_facts)[:provider] == 'pcs' if Gem::Version.new(corosync_stack(os_facts)[:pcs_version]) < Gem::Version.new('0.10.0') 'cluster auth' @@ -1043,7 +1044,7 @@ command: 'pcs quorum device add model net host=quorum1.test.org algorithm=ffsplit', path: '/sbin:/bin:/usr/sbin:/usr/bin', onlyif: [ - 'test 0 -ne $(pcs quorum config | grep "host:" >/dev/null 2>&1; echo $?)' + "test 0 -ne $(pcs quorum config | grep 'host: quorum1.test.org' >/dev/null 2>&1; echo $?)" ], require: 'Exec[authorize_qdevice]' ) @@ -1083,6 +1084,23 @@ ) end # else - to implement + + it 'contains the quorum configuration' do + is_expected.to contain_file('/etc/corosync/corosync.conf').with_content( + %r!nodelist\s{\n + \s+node\s{\n + \s+ring0_addr:\snode1[.]test[.]org\n + \s+nodeid:\s1\n + \s+name:\snode1[.]test[.]org\n + \s+}\n + \s+node\s{\n + \s+ring0_addr:\snode2[.]test[.]org\n + \s+nodeid:\s2\n + \s+name:\snode2[.]test[.]org\n + \s+}\n + }!xm + ) + end end end end diff --git a/templates/corosync.conf.erb b/templates/corosync.conf.erb index 15b4a581..3fcc3306 100644 --- a/templates/corosync.conf.erb +++ b/templates/corosync.conf.erb @@ -160,6 +160,8 @@ nodelist { <% end -%> <% if not @quorum_members_names.nil? -%> name: <%= [@quorum_members_names].flatten[i] %> +<% elsif @quorum_members[i] !~ %r{\A([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z} -%> + name: <%= [@quorum_members].flatten[i] %> <% end -%> } <% end -%>