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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'manifests/config/project.pp', line 19
define rundeck::config::project (
Hash[String, String] $config = {
'project.description' => "${name} project",
'project.label' => $name,
'project.disable.executions' => 'false',
'project.disable.schedule' => 'false',
'project.execution.history.cleanup.batch' => '500',
'project.execution.history.cleanup.enabled' => 'true',
'project.execution.history.cleanup.retention.days' => '60',
'project.execution.history.cleanup.retention.minimum' => '50',
'project.execution.history.cleanup.schedule' => '0 0 0 1/1 * ? *',
'project.jobs.gui.groupExpandLevel' => '1',
},
Enum['set', 'update'] $update_method = 'update',
Hash[String, Rundeck::Job] $jobs = {},
) {
include rundeck::cli
$_default_cfg = {
'project.name' => $name,
}
$_final_cfg = $config + $_default_cfg
$_cmd_line_cfg = $_final_cfg.map |$_k, $_v| {
"--${_k}=${_v}"
}
$_project_diff = $update_method ? {
'set' => "rd_project_diff.sh '${name}' ${update_method} '${_final_cfg.to_json}'",
default => "rd_project_diff.sh '${name}' ${update_method} '${_final_cfg.to_json}' '${_final_cfg.keys}'",
}
exec {
default:
path => ['/bin', '/usr/bin', '/usr/local/bin'],
environment => $rundeck::cli::environment,
;
"Create rundeck project: ${name}":
command => "rd projects create -p ${name}",
unless => "rd projects info -p ${name}",
;
"Manage rundeck project: ${name}":
command => "rd projects configure ${update_method} -p ${name} -- ${_cmd_line_cfg.shellquote}",
unless => $_project_diff,
;
}
$jobs.each |$_name, $_attr| {
if $_attr['ensure'] == 'absent' {
exec { "Remove rundeck job: ${_name}":
command => "rd jobs purge -y -p '${name}' -J '${_name}'",
path => ['/bin', '/usr/bin', '/usr/local/bin'],
environment => $rundeck::cli::environment,
onlyif => "rd jobs list -p '${name}' -J '${_name}' | grep -q '${_name}'",
}
}
exec { "Create/update rundeck job: ${_name}":
command => "rd jobs load -r -d update -p '${name}' -f '${_attr['path']}' -F ${_attr['format']}",
path => ['/bin', '/usr/bin', '/usr/local/bin'],
environment => $rundeck::cli::environment,
unless => "rd_job_diff.sh '${name}' '${_name}' '${_attr['path']}' ${_attr['format']}",
}
}
}
|