Skip to content
Merged
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
13 changes: 10 additions & 3 deletions tasks/get_peadm_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ class GetPEAdmConfig
def initialize(params); end

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

# Build and return the task output
{
'pe_version' => pe_version,
'params' => {
'primary_host' => primary,
'replica_host' => replica,
Expand Down Expand Up @@ -73,6 +74,12 @@ def config
}
end

# @return [String] Local PE version string.
def pe_version
pe_build_file = '/opt/puppetlabs/server/pe_build'
File.read(pe_build_file).strip if File.exist?(pe_build_file)
end

# Returns a GetPEAdmConfig::NodeGroups object created from the /groups object
# returned by the classifier
def groups
Expand Down
Loading