Puppet Plan: cd4peadm::preflight::downgrade
- Defined in:
- plans/preflight/downgrade.pp
Overview
Checks whether the version of CD4PE that is running is newer than the version the user is attempting to install. If it is, fail this pre-check because we don’t want to allow downgrades. Not only is this behavior users are used to from 4.x, but downgrading the application, if done across a database migration can put the application in a bad state.
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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'plans/preflight/downgrade.pp', line 11
plan cd4peadm::preflight::downgrade (Cd4peadm::Config $config = cd4peadm::config() ) {
$version_from_file_result = run_command("cat ${cd4peadm::version_file_path()}", $config['all_targets'],
{ '_run_as' => 'root', '_catch_errors' => true })
if(!$version_from_file_result.error_set.empty) {
$error = $version_from_file_result.error_set[0].value[stderr]
if($error =~ /.*No such file or directory.*/) {
$result = {
'failed' => [],
'passed' => ["Could not determine running version of CD4PE, using current module version ${cd4peadm::module_version()}"],
}
} else {
$result = {
'failed' => ["Could not determine running version of CD4PE: ${error}"],
'passed' => [],
}
}
} else {
$installed_version = chomp(regsubst($version_from_file_result[0].value[stdout],"\\\"",'', 'G'))
$new_version = cd4peadm::module_version()
if(versioncmp($installed_version, $new_version) == 1) {
$failed_message = @("FAILED")
Currently installed version is ${installed_version}, cannot install older version ${new_version}.
If you are trying to upgrade, make sure the version of puppetlabs-cd4peadm in your Puppetfile
is correct and try again.
| FAILED
$result = {
'failed' => [$failed_message],
'passed' => [],
}
} else {
$result = {
'failed' => [],
'passed' => ["Ok to install version ${new_version}"],
}
}
}
return $result
}
|