Skip to content

Commit 27485f4

Browse files
authored
(PE-39352) Add version to get peadm config (#527)
* (maint) Fix GetPEAdmConfig node group test for peadm cluster The 'PE HA Replica' node group is present in all PE installations, installed with or without PEADM. Switched this to check for the 'PE Primary A' node group that a PEADM installation specifically creates. * (PE-39352,PE-39351) Gather PE version in get_peadm_config task Adds a lookup of the pe_build file to provide the PE version in the hash returned by the get_peadm_config task. We will use this in add_database and backup/restore plans as a version gate for handling the newer host_action_collector database that is only present in PE 2023.7+, for example.
1 parent bbc1487 commit 27485f4

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

tasks/get_peadm_config.rb

+10-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ class GetPEAdmConfig
1111
def initialize(params); end
1212

1313
def execute!
14-
# if there is no 'PE HA Replica' node group, it's not a peadm-configured cluster.
15-
replica_group = groups.data.find { |obj| obj['name'] == 'PE HA Replica' }
16-
if replica_group
14+
# if there is no 'PE Primary A' node group, it's not a peadm-configured cluster.
15+
peadm_primary_a_group = groups.data.find { |obj| obj['name'] == 'PE Primary A' }
16+
if peadm_primary_a_group
1717
puts config.to_json
1818
else
1919
puts({ 'error' => 'This is not a peadm-compatible cluster. Use peadm::convert first.' }).to_json
@@ -41,6 +41,7 @@ def config
4141

4242
# Build and return the task output
4343
{
44+
'pe_version' => pe_version,
4445
'params' => {
4546
'primary_host' => primary,
4647
'replica_host' => replica,
@@ -73,6 +74,12 @@ def config
7374
}
7475
end
7576

77+
# @return [String] Local PE version string.
78+
def pe_version
79+
pe_build_file = '/opt/puppetlabs/server/pe_build'
80+
File.read(pe_build_file).strip if File.exist?(pe_build_file)
81+
end
82+
7683
# Returns a GetPEAdmConfig::NodeGroups object created from the /groups object
7784
# returned by the classifier
7885
def groups

0 commit comments

Comments
 (0)