Puppet Plan: cd4peadm::preflight::migration_version_check

Defined in:
plans/preflight/migration_version_check.pp

Overview

A plan to check whether the 4.x target machine has a version of CD4PE that is supported for a v5 migration. Must be at least 4.26.0

Parameters:

  • cd4pe_4_target (Target)

    Target 4.x installation

Returns:

  • Hash A hash with pass and/or fail messages



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'plans/preflight/migration_version_check.pp', line 9

plan cd4peadm::preflight::migration_version_check (
  Target $cd4pe_4_target,
) {
  $min_version = '4.26.0'

  $cd4pe_image = cd4peadm::kubectl(
    $cd4pe_4_target,
    'get deployment cd4pe -o jsonpath=\'{.spec.template.spec.containers[0].image}\''
  )[0].value['stdout']

  $version = $cd4pe_image ? {
    /continuous-delivery-for-puppet-enterprise:(\d+\.\d+\.\d+)/ => $1,
    default => '',
  }

  $results = versioncmp($version, $min_version) >= 0 ? {
    true => {
      'passed' => ["${cd4pe_4_target} : found version ${version}"],
      'failed' => [],
    },
    false => {
      'failed' => ["${cd4pe_4_target} : version ${version} cannot be migrated. CD4PE must be at least ${min_version}"],
      'passed' => [],
    },
  }

  return $results
}