Puppet Plan: cd4peadm::delete_license
- Defined in:
-
plans/delete_license.pp
Summary
Delete the installed license
Overview
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
|
# File 'plans/delete_license.pp', line 2
plan cd4peadm::delete_license() {
run_plan('cd4peadm::check_bolt_version')
$config = cd4peadm::config()
$backend_hosts = $config['roles']['backend']['targets']
$runtime = $config['runtime']
$opts = { '_catch_errors' => true, '_run_as' => 'root' }
$service_status_result = run_command("systemctl is-active ${runtime}-pipelinesinfra", $backend_hosts, $opts)
# If the service is running anywhere, fail with a message that it needs to be stopped
if(!$service_status_result.ok_set.empty) {
$error = @("ERROR")
Detected that CD4PE is currently running.
Please stop CD4PE before deleting your license.
To do so, run:
bolt plan run cd4peadm::ctl action=stop
Then re-run this plan to delete the license. Once the license
is deleted, the server can be started again with:
bolt plan run cd4peadm::ctl action=start
| ERROR
fail_plan($error)
}
$backend_host = $config['roles']['backend']['targets'][0]
without_default_logging() || {
$installed_license_path = file::join(cd4peadm::license_install_dir(), 'license.lic')
$delete_license = run_command(
"rm ${installed_license_path}",
$backend_host,
{ '_run_as' => 'root', '_catch_errors' => true }
)
if($delete_license.error_set.empty) {
out::message("Successfully deleted license from ${backend_host}.")
} else {
$error = $delete_license.error_set[0].value[stderr]
if($error =~ /.*No such file or directory.*/) {
fail_plan("No installed license found on ${backend_host}, unable to delete.")
} else {
fail_plan("Error deleting license from ${backend_host}: ${error}")
}
}
}
}
|