diff --git a/tasks/get_peadm_config.rb b/tasks/get_peadm_config.rb index e4bb7ba4e..9eb3aa02a 100755 --- a/tasks/get_peadm_config.rb +++ b/tasks/get_peadm_config.rb @@ -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 @@ -41,6 +41,7 @@ def config # Build and return the task output { + 'pe_version' => pe_version, 'params' => { 'primary_host' => primary, 'replica_host' => replica, @@ -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