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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
# File 'manifests/config/context/environment.pp', line 26
define tomcat::config::context::environment (
Enum['present','absent'] $ensure = 'present',
Stdlib::Absolutepath $catalina_base = $::tomcat::catalina_home,
String $environment_name = $name,
Optional[String] $type = undef,
Optional[String] $value = undef,
Optional[String] $description = undef,
Optional[Boolean] $override = undef,
Hash $additional_attributes = {},
Array $attributes_to_remove = [],
Boolean $show_diff = true,
) {
if versioncmp($::augeasversion, '1.0.0') < 0 {
fail('Server configurations require Augeas >= 1.0.0')
}
$base_path = "Context/Environment[#attribute/name='${environment_name}']"
if $ensure == 'absent' {
$changes = "rm ${base_path}"
} else {
if empty($type) {
fail('$type must be specified')
}
if empty($value) {
fail('$value must be specified')
}
$set_name = "set ${base_path}/#attribute/name '${environment_name}'"
$set_type = "set ${base_path}/#attribute/type '${type}'"
$set_value = "set ${base_path}/#attribute/value '${value}'"
if $override != undef {
$_override = bool2str($override)
$set_override = "set ${base_path}/#attribute/override ${_override}"
} else {
$set_override = "rm ${base_path}/#attribute/override"
}
if ! empty($description) {
$set_description = "set ${base_path}/#attribute/description \'${description}\'"
} else {
$set_description = "rm ${base_path}/#attribute/description"
}
if ! empty($additional_attributes) {
$set_additional_attributes = suffix(prefix(join_keys_to_values($additional_attributes, " '"), "set ${base_path}/#attribute/"), "'")
} else {
$set_additional_attributes = undef
}
if ! empty(any2array($attributes_to_remove)) {
$rm_attributes_to_remove = prefix(any2array($attributes_to_remove), "rm ${base_path}/#attribute/")
} else {
$rm_attributes_to_remove = undef
}
$changes = delete_undef_values(flatten([
$set_name,
$set_type,
$set_value,
$set_override,
$set_description,
$set_additional_attributes,
$rm_attributes_to_remove,
]))
}
augeas { "context-${catalina_base}-environment-${name}":
lens => 'Xml.lns',
incl => "${catalina_base}/conf/context.xml",
changes => $changes,
show_diff => $show_diff,
}
}
|