2
3
4
5
6
7
8
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'plans/upgrade.pp', line 2
plan cd4peadm::upgrade() {
run_plan('cd4peadm::check_bolt_version')
# Get the version of CD4PE on the target so we can
# determine if we need to run individual upgrade plans
$hiera_config = loadyaml('data/common.yaml')
$target = $hiera_config['cd4peadm::config']['targets']['backend'][0]
$version_from_file_result = run_command("cat ${cd4peadm::version_file_path()}", $target,
{ '_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.*/) {
out::message('Could not determine installed version, assuming < 5.2.0.')
$installed_version = '5.1.2'
} else {
fail_plan("Could not determine version of CD4PE on the target ${target}: ${error}")
}
} else {
$installed_version = chomp($version_from_file_result[0].value[stdout])
}
if (versioncmp($installed_version, '5.2.0') < 0) {
out::message("Making changes to support upgrading ${installed_version} to 5.2.0 and newer")
run_plan('cd4peadm::upgrade::ensure_certs_in_hiera')
run_plan('cd4peadm::upgrade::set_default_config_values')
}
$config = cd4peadm::config()
run_plan('cd4peadm::preflight',
config => $config,
)
run_plan('cd4peadm::install::runtime',
config => $config,
)
run_plan('cd4peadm::install::upload_images',
config => $config,
)
run_plan('cd4peadm::install::roles',
config => $config,
)
run_plan('cd4peadm::install::wait_for_services',
config => $config,
)
run_plan('cd4peadm::upgrade::cleanup',
config => $config,
)
write_file(cd4peadm::module_version(), cd4peadm::version_file_path(), $config['all_targets'], { '_run_as' => 'root' })
}
|