puppet 4.2.0-x64-mingw32 → 4.2.1-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/Gemfile +1 -1
- data/ext/project_data.yaml +1 -1
- data/ext/suse/client.init +23 -10
- data/lib/hiera/puppet_function.rb +5 -5
- data/lib/puppet/application/agent.rb +14 -4
- data/lib/puppet/application/apply.rb +13 -4
- data/lib/puppet/defaults.rb +1 -1
- data/lib/puppet/environments.rb +85 -5
- data/lib/puppet/functions/epp.rb +29 -37
- data/lib/puppet/functions/hiera_include.rb +2 -2
- data/lib/puppet/functions/inline_epp.rb +44 -71
- data/lib/puppet/module_tool/applications/unpacker.rb +1 -1
- data/lib/puppet/module_tool/skeleton/templates/generator/manifests/init.pp.erb +25 -18
- data/lib/puppet/node.rb +11 -5
- data/lib/puppet/parser/functions/epp.rb +29 -37
- data/lib/puppet/parser/functions/inline_epp.rb +35 -60
- data/lib/puppet/pops/issues.rb +6 -2
- data/lib/puppet/pops/patterns.rb +3 -0
- data/lib/puppet/pops/types/type_parser.rb +2 -2
- data/lib/puppet/pops/validation/checker4_0.rb +4 -0
- data/lib/puppet/provider/zone/solaris.rb +2 -2
- data/lib/puppet/type.rb +4 -4
- data/lib/puppet/util.rb +9 -1
- data/lib/puppet/util/command_line.rb +4 -0
- data/lib/puppet/version.rb +1 -1
- data/spec/integration/parser/compiler_spec.rb +7 -5
- data/spec/integration/provider/package_spec.rb +3 -1
- data/spec/integration/ssl/certificate_authority_spec.rb +0 -1
- data/spec/integration/ssl/certificate_request_spec.rb +0 -1
- data/spec/integration/ssl/certificate_revocation_list_spec.rb +0 -1
- data/spec/integration/ssl/host_spec.rb +0 -1
- data/spec/integration/util/rdoc/parser_spec.rb +1 -1
- data/spec/unit/application/apply_spec.rb +1 -1
- data/spec/unit/application/filebucket_spec.rb +1 -1
- data/spec/unit/application_spec.rb +3 -3
- data/spec/unit/environments_spec.rb +2 -0
- data/spec/unit/face/node_spec.rb +1 -1
- data/spec/unit/file_serving/configuration_spec.rb +1 -1
- data/spec/unit/functions/hiera_spec.rb +2 -2
- data/spec/unit/graph/sequential_prioritizer_spec.rb +1 -1
- data/spec/unit/indirector/indirection_spec.rb +2 -2
- data/spec/unit/indirector/ssl_file_spec.rb +1 -1
- data/spec/unit/indirector/yaml_spec.rb +1 -1
- data/spec/unit/module_tool/application_spec.rb +1 -1
- data/spec/unit/module_tool/applications/builder_spec.rb +1 -1
- data/spec/unit/network/authstore_spec.rb +1 -1
- data/spec/unit/network/http/compression_spec.rb +1 -1
- data/spec/unit/network/http/handler_spec.rb +0 -5
- data/spec/unit/network/rights_spec.rb +3 -3
- data/spec/unit/node_spec.rb +27 -0
- data/spec/unit/parser/ast/leaf_spec.rb +1 -1
- data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +1 -0
- data/spec/unit/pops/types/type_parser_spec.rb +8 -0
- data/spec/unit/pops/validator/validator_spec.rb +19 -0
- data/spec/unit/property_spec.rb +1 -1
- data/spec/unit/provider/service/debian_spec.rb +1 -0
- data/spec/unit/provider/service/gentoo_spec.rb +1 -0
- data/spec/unit/provider/service/init_spec.rb +6 -0
- data/spec/unit/provider/service/openrc_spec.rb +1 -0
- data/spec/unit/provider/service/src_spec.rb +1 -0
- data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +1 -1
- data/spec/unit/provider/zone/solaris_spec.rb +19 -0
- data/spec/unit/resource_spec.rb +2 -2
- data/spec/unit/settings_spec.rb +1 -1
- data/spec/unit/ssl/certificate_authority_spec.rb +5 -3
- data/spec/unit/ssl/host_spec.rb +2 -2
- data/spec/unit/type/host_spec.rb +4 -4
- data/spec/unit/type/tidy_spec.rb +4 -4
- data/spec/unit/type/vlan_spec.rb +1 -1
- data/spec/unit/util/ldap/generator_spec.rb +1 -1
- data/spec/unit/util/network_device/cisco/device_spec.rb +1 -1
- data/spec/unit/util/network_device/transport/ssh_spec.rb +1 -1
- data/spec/unit/util/network_device_spec.rb +1 -1
- data/spec/unit/util/storage_spec.rb +5 -1
- data/spec/unit/util_spec.rb +21 -2
- metadata +3195 -3217
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b526eddd6769f426e5a5dd4e011b1d1662c518c3
|
4
|
+
data.tar.gz: 89afbaacc596b37a19082ab093e4e37e97950e08
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 774c2b6dd28fafd16df76aadd42e87af8f7c9a3182dce8d493ae21574a2a22f76797c119e288537aa894c96da0796f9bb784bf66b4ee8890b8f6e2e80ef0eb8b
|
7
|
+
data.tar.gz: 945e3eb27f99ec7d916414a4d485910600d85c73f7b97102df10b0f96ac7aba5959a0961d6c81fcc8e44ef468f2b0206d67449cfa8aec7d1e2c62e5c635edcaa
|
data/Gemfile
CHANGED
@@ -25,7 +25,7 @@ end
|
|
25
25
|
|
26
26
|
gem "puppet", :path => File.dirname(__FILE__), :require => false
|
27
27
|
gem "facter", *location_for(ENV['FACTER_LOCATION'] || ['> 2.0', '< 4'])
|
28
|
-
gem "hiera", *location_for(ENV['HIERA_LOCATION'] || ['>= 2.0', '<
|
28
|
+
gem "hiera", *location_for(ENV['HIERA_LOCATION'] || ['>= 2.0', '< 4'])
|
29
29
|
gem "rake", "10.1.1", :require => false
|
30
30
|
|
31
31
|
group(:development, :test) do
|
data/ext/project_data.yaml
CHANGED
data/ext/suse/client.init
CHANGED
@@ -36,7 +36,6 @@
|
|
36
36
|
lockfile=/var/lock/subsys/puppet
|
37
37
|
pidfile=/var/run/puppetlabs/agent.pid
|
38
38
|
puppetd=/opt/puppetlabs/puppet/bin/puppet
|
39
|
-
RETVAL=0
|
40
39
|
|
41
40
|
PUPPET_OPTS="agent"
|
42
41
|
|
@@ -63,9 +62,18 @@ case "$1" in
|
|
63
62
|
## Start daemon with startproc(8). If this fails
|
64
63
|
## the echo return value is set appropriate.
|
65
64
|
|
66
|
-
|
67
|
-
|
68
|
-
|
65
|
+
## This accounts for the behavior of startproc on sles 10.
|
66
|
+
## Check to see if a running process matches the contents
|
67
|
+
## of the pidfile, and do nothing if true. Otherwise
|
68
|
+
## force a process start
|
69
|
+
if [ -f "${pidfile}" ]; then
|
70
|
+
PID=$(cat "$pidfile")
|
71
|
+
if [ "$PID" -eq $(pgrep -f "$puppetd") ] ; then
|
72
|
+
rc_status -v
|
73
|
+
rc_exit
|
74
|
+
fi
|
75
|
+
fi
|
76
|
+
startproc -f -w -p "${pidfile}" "${puppetd}" "${PUPPET_OPTS}" "${PUPPET_EXTRA_OPTS}" && touch "${lockfile}"
|
69
77
|
# Remember status and be verbose
|
70
78
|
rc_status -v
|
71
79
|
;;
|
@@ -74,7 +82,7 @@ case "$1" in
|
|
74
82
|
## Stop daemon with killproc(8) and if this fails
|
75
83
|
## set echo the echo return value.
|
76
84
|
|
77
|
-
killproc -QUIT -p ${pidfile} $puppetd && rm -f ${lockfile} ${pidfile}
|
85
|
+
killproc -QUIT -p "${pidfile}" "${puppetd}" && rm -f "${lockfile}" "${pidfile}"
|
78
86
|
|
79
87
|
# Remember status and be verbose
|
80
88
|
rc_status -v
|
@@ -103,7 +111,7 @@ case "$1" in
|
|
103
111
|
|
104
112
|
echo -n "Reload service puppet"
|
105
113
|
## if it supports it:
|
106
|
-
killproc -HUP -p ${pidfile} $puppetd
|
114
|
+
killproc -HUP -p "${pidfile}" "${puppetd}"
|
107
115
|
rc_status -v
|
108
116
|
;;
|
109
117
|
reload)
|
@@ -112,7 +120,7 @@ case "$1" in
|
|
112
120
|
|
113
121
|
# If it supports signalling:
|
114
122
|
echo -n "Reload puppet services."
|
115
|
-
killproc -HUP -p ${pidfile} $puppetd
|
123
|
+
killproc -HUP -p "${pidfile}" "${puppetd}"
|
116
124
|
rc_status -v
|
117
125
|
;;
|
118
126
|
status)
|
@@ -127,12 +135,17 @@ case "$1" in
|
|
127
135
|
# 3 - service not running
|
128
136
|
|
129
137
|
# NOTE: checkproc returns LSB compliant status values.
|
130
|
-
|
131
|
-
|
138
|
+
if [ -f "${pidfile}" ]; then
|
139
|
+
checkproc -p "${pidfile}" "${puppetd}"
|
140
|
+
rc_status -v
|
141
|
+
else
|
142
|
+
rc_failed 3
|
143
|
+
rc_status -v
|
144
|
+
fi
|
132
145
|
;;
|
133
146
|
once)
|
134
147
|
shift
|
135
|
-
$puppetd ${PUPPET_OPTS} --onetime ${PUPPET_EXTRA_OPTS} $@
|
148
|
+
$puppetd "${PUPPET_OPTS}" --onetime "${PUPPET_EXTRA_OPTS}" $@
|
136
149
|
;;
|
137
150
|
*)
|
138
151
|
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|once}"
|
@@ -43,13 +43,13 @@ class Hiera::PuppetFunction < Puppet::Functions::InternalFunction
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def hiera_no_default(scope, key)
|
46
|
-
post_lookup(key, lookup(scope, key, nil, nil))
|
46
|
+
post_lookup(scope, key, lookup(scope, key, nil, nil))
|
47
47
|
end
|
48
48
|
|
49
49
|
def hiera_with_default(scope, key, default, override = nil)
|
50
50
|
undefined = (@@undefined_value ||= Object.new)
|
51
51
|
result = lookup(scope, key, undefined, override)
|
52
|
-
post_lookup(key, result.equal?(undefined) ? default : result)
|
52
|
+
post_lookup(scope, key, result.equal?(undefined) ? default : result)
|
53
53
|
end
|
54
54
|
|
55
55
|
def hiera_block1(scope, key, &default_block)
|
@@ -63,20 +63,20 @@ class Hiera::PuppetFunction < Puppet::Functions::InternalFunction
|
|
63
63
|
def common(scope, key, override, default_block)
|
64
64
|
undefined = (@@undefined_value ||= Object.new)
|
65
65
|
result = lookup(scope, key, undefined, override)
|
66
|
-
post_lookup(key, result.equal?(undefined) ? default_block.call(key) : result)
|
66
|
+
post_lookup(scope, key, result.equal?(undefined) ? default_block.call(key) : result)
|
67
67
|
end
|
68
68
|
|
69
69
|
private :common
|
70
70
|
|
71
71
|
def lookup(scope, key, default, override)
|
72
|
-
HieraPuppet.lookup(key, default,scope, override, merge_type)
|
72
|
+
HieraPuppet.lookup(key, default, scope, override, merge_type)
|
73
73
|
end
|
74
74
|
|
75
75
|
def merge_type
|
76
76
|
:priority
|
77
77
|
end
|
78
78
|
|
79
|
-
def post_lookup(key, result)
|
79
|
+
def post_lookup(scope, key, result)
|
80
80
|
result
|
81
81
|
end
|
82
82
|
end
|
@@ -181,10 +181,20 @@ generated by running puppet agent with '--genconfig'.
|
|
181
181
|
Enable full debugging.
|
182
182
|
|
183
183
|
* --detailed-exitcodes:
|
184
|
-
Provide
|
185
|
-
|
186
|
-
|
187
|
-
|
184
|
+
Provide extra information about the run via exit codes; only works if
|
185
|
+
'--onetime' is also specified. If enabled, 'puppet agent' will use the
|
186
|
+
following exit codes:
|
187
|
+
|
188
|
+
0: The run succeeded with no changes or failures; the system was already in
|
189
|
+
the desired state.
|
190
|
+
|
191
|
+
1: The run failed.
|
192
|
+
|
193
|
+
2: The run succeeded, and some resources were changed.
|
194
|
+
|
195
|
+
4: The run succeeded, and some resources failed.
|
196
|
+
|
197
|
+
6: The run succeeded, and included both changes and failures.
|
188
198
|
|
189
199
|
* --digest:
|
190
200
|
Change the certificate fingerprinting digest algorithm. The default is
|
@@ -83,10 +83,19 @@ configuration options can also be generated by running puppet with
|
|
83
83
|
Enable full debugging.
|
84
84
|
|
85
85
|
* --detailed-exitcodes:
|
86
|
-
Provide
|
87
|
-
|
88
|
-
|
89
|
-
changes
|
86
|
+
Provide extra information about the run via exit codes. If enabled, 'puppet
|
87
|
+
apply' will use the following exit codes:
|
88
|
+
|
89
|
+
0: The run succeeded with no changes or failures; the system was already in
|
90
|
+
the desired state.
|
91
|
+
|
92
|
+
1: The run failed.
|
93
|
+
|
94
|
+
2: The run succeeded, and some resources were changed.
|
95
|
+
|
96
|
+
4: The run succeeded, and some resources failed.
|
97
|
+
|
98
|
+
6: The run succeeded, and included both changes and failures.
|
90
99
|
|
91
100
|
* --help:
|
92
101
|
Print this help message
|
data/lib/puppet/defaults.rb
CHANGED
@@ -531,7 +531,7 @@ module Puppet
|
|
531
531
|
:desc => "The module repository",
|
532
532
|
},
|
533
533
|
:module_working_dir => {
|
534
|
-
:default => '$vardir/puppet-module',
|
534
|
+
:default => (Puppet.features.microsoft_windows? ? Dir.tmpdir() : '$vardir/puppet-module'),
|
535
535
|
:desc => "The directory into which module tool data is stored",
|
536
536
|
},
|
537
537
|
:module_skeleton_dir => {
|
data/lib/puppet/environments.rb
CHANGED
@@ -282,10 +282,29 @@ module Puppet::Environments
|
|
282
282
|
@cache_expiration_service || DefaultCacheExpirationService.new
|
283
283
|
end
|
284
284
|
|
285
|
+
# Returns the end of time (the next Mesoamerican Long Count cycle-end after 2012 (5125+2012) = 7137,
|
286
|
+
# of for a 32 bit machine using Ruby < 1.9.3, the year 2038.
|
287
|
+
def self.end_of_time
|
288
|
+
begin
|
289
|
+
Time.gm(7137)
|
290
|
+
rescue ArgumentError
|
291
|
+
Time.gm(2038)
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
END_OF_TIME = end_of_time
|
296
|
+
START_OF_TIME = Time.gm(1)
|
297
|
+
|
285
298
|
def initialize(loader)
|
286
299
|
@loader = loader
|
287
|
-
@cache = {}
|
288
300
|
@cache_expiration_service = Puppet::Environments::Cached.cache_expiration_service
|
301
|
+
@cache = {}
|
302
|
+
|
303
|
+
# Holds expiration times in sorted order - next to expire is first
|
304
|
+
@expirations = SortedSet.new
|
305
|
+
|
306
|
+
# Infinity since it there are no entries, this is a cache of the first to expire time
|
307
|
+
@next_expiration = END_OF_TIME
|
289
308
|
end
|
290
309
|
|
291
310
|
# @!macro loader_list
|
@@ -300,15 +319,34 @@ module Puppet::Environments
|
|
300
319
|
|
301
320
|
# @!macro loader_get
|
302
321
|
def get(name)
|
303
|
-
|
322
|
+
# Aggressively evict all that has expired
|
323
|
+
# This strategy favors smaller memory footprint over environment
|
324
|
+
# retrieval time.
|
325
|
+
clear_all_expired
|
304
326
|
if result = @cache[name]
|
327
|
+
# found in cache
|
305
328
|
return result.value
|
306
329
|
elsif (result = @loader.get(name))
|
307
|
-
|
330
|
+
# environment loaded, cache it
|
331
|
+
cache_entry = entry(result)
|
332
|
+
@cache_expiration_service.created(result)
|
333
|
+
add_entry(name, cache_entry)
|
308
334
|
result
|
309
335
|
end
|
310
336
|
end
|
311
337
|
|
338
|
+
# Adds a cache entry to the cache
|
339
|
+
def add_entry(name, cache_entry)
|
340
|
+
Puppet.debug {"Caching environment '#{name}' #{cache_entry.label}"}
|
341
|
+
@cache[name] = cache_entry
|
342
|
+
expires = cache_entry.expires
|
343
|
+
@expirations.add(expires)
|
344
|
+
if @next_expiration > expires
|
345
|
+
@next_expiration = expires
|
346
|
+
end
|
347
|
+
end
|
348
|
+
private :add_entry
|
349
|
+
|
312
350
|
# Clears the cache of the environment with the given name.
|
313
351
|
# (The intention is that this could be used from a MANUAL cache eviction command (TBD)
|
314
352
|
def clear(name)
|
@@ -319,6 +357,25 @@ module Puppet::Environments
|
|
319
357
|
# (The intention is that this could be used from a MANUAL cache eviction command (TBD)
|
320
358
|
def clear_all()
|
321
359
|
@cache = {}
|
360
|
+
@expirations.clear
|
361
|
+
@next_expiration = END_OF_TIME
|
362
|
+
end
|
363
|
+
|
364
|
+
# Clears all environments that have expired, either by exceeding their time to live, or
|
365
|
+
# through an explicit eviction determined by the cache expiration service.
|
366
|
+
#
|
367
|
+
def clear_all_expired()
|
368
|
+
t = Time.now
|
369
|
+
return if t < @next_expiration && ! @cache.any? {|name, _| @cache_expiration_service.expired?(name.to_sym) }
|
370
|
+
to_expire = @cache.select { |name, entry| entry.expires < t || @cache_expiration_service.expired?(name.to_sym) }
|
371
|
+
to_expire.each do |name, entry|
|
372
|
+
Puppet.debug {"Evicting cache entry for environment '#{name}'"}
|
373
|
+
@cache_expiration_service.evicted(name)
|
374
|
+
clear(name)
|
375
|
+
@expirations.delete(entry.expires)
|
376
|
+
Puppet.settings.clear_environment_settings(name)
|
377
|
+
end
|
378
|
+
@next_expiration = @expirations.first || END_OF_TIME
|
322
379
|
end
|
323
380
|
|
324
381
|
# This implementation evicts the cache, and always gets the current
|
@@ -337,9 +394,7 @@ module Puppet::Environments
|
|
337
394
|
# Creates a suitable cache entry given the time to live for one environment
|
338
395
|
#
|
339
396
|
def entry(env)
|
340
|
-
@cache_expiration_service.created(env)
|
341
397
|
ttl = (conf = get_conf(env.name)) ? conf.environment_timeout : Puppet.settings.value(:environment_timeout)
|
342
|
-
Puppet.debug {"Caching environment '#{env.name}' (cache ttl: #{ttl})"}
|
343
398
|
case ttl
|
344
399
|
when 0
|
345
400
|
NotCachedEntry.new(env) # Entry that is always expired (avoids syscall to get time)
|
@@ -373,6 +428,14 @@ module Puppet::Environments
|
|
373
428
|
def expired?
|
374
429
|
false
|
375
430
|
end
|
431
|
+
|
432
|
+
def label
|
433
|
+
""
|
434
|
+
end
|
435
|
+
|
436
|
+
def expires
|
437
|
+
END_OF_TIME
|
438
|
+
end
|
376
439
|
end
|
377
440
|
|
378
441
|
# Always evicting entry
|
@@ -380,6 +443,14 @@ module Puppet::Environments
|
|
380
443
|
def expired?
|
381
444
|
true
|
382
445
|
end
|
446
|
+
|
447
|
+
def label
|
448
|
+
"(ttl = 0 sec)"
|
449
|
+
end
|
450
|
+
|
451
|
+
def expires
|
452
|
+
START_OF_TIME
|
453
|
+
end
|
383
454
|
end
|
384
455
|
|
385
456
|
# Time to Live eviction policy entry
|
@@ -387,11 +458,20 @@ module Puppet::Environments
|
|
387
458
|
def initialize(value, ttl_seconds)
|
388
459
|
super value
|
389
460
|
@ttl = Time.now + ttl_seconds
|
461
|
+
@ttl_seconds = ttl_seconds
|
390
462
|
end
|
391
463
|
|
392
464
|
def expired?
|
393
465
|
Time.now > @ttl
|
394
466
|
end
|
467
|
+
|
468
|
+
def label
|
469
|
+
"(ttl = #{@ttl_seconds} sec)"
|
470
|
+
end
|
471
|
+
|
472
|
+
def expires
|
473
|
+
@ttl
|
474
|
+
end
|
395
475
|
end
|
396
476
|
end
|
397
477
|
end
|
data/lib/puppet/functions/epp.rb
CHANGED
@@ -1,42 +1,34 @@
|
|
1
|
-
# Evaluates an Embedded Puppet
|
1
|
+
# Evaluates an Embedded Puppet (EPP) template file and returns the rendered text
|
2
|
+
# result as a String.
|
3
|
+
#
|
4
|
+
# `epp('<MODULE NAME>/<TEMPLATE FILE>', <PARAMETER HASH>)`
|
2
5
|
#
|
3
6
|
# The first argument to this function should be a `<MODULE NAME>/<TEMPLATE FILE>`
|
4
|
-
# reference, which
|
5
|
-
# directory.
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
# given as template arguments when calling `inline_epp`, and that `z` if not given as a template argument
|
30
|
-
# defaults to `'unicorn'`. Template parameters are available as variables, e.g.arguments `$x`, `$y` and `$z` in the example.
|
31
|
-
# Note that `<%-` must be used or any leading whitespace will be interpreted as text
|
32
|
-
#
|
33
|
-
# Arguments are passed to the template by calling `epp` with a Hash as the last argument, where parameters
|
34
|
-
# are bound to values, e.g. `epp('...', {'x'=>10, 'y'=>20})`. Excess arguments may be given
|
35
|
-
# (i.e. undeclared parameters) only if the EPP templates does not declare any parameters at all.
|
36
|
-
# Template parameters shadow variables in outer scopes. File based epp does never have access to variables in the
|
37
|
-
# scope where the `epp` function is called from.
|
38
|
-
#
|
39
|
-
# @see function inline_epp for examples of EPP
|
7
|
+
# reference, which loads `<TEMPLATE FILE>` from `<MODULE NAME>`'s `templates`
|
8
|
+
# directory. In most cases, the last argument is optional; if used, it should be a
|
9
|
+
# [hash](/puppet/latest/reference/lang_data_hash.html) that contains parameters to
|
10
|
+
# pass to the template.
|
11
|
+
#
|
12
|
+
# - See the [template](/puppet/latest/reference/lang_template.html) documentation
|
13
|
+
# for general template usage information.
|
14
|
+
# - See the [EPP syntax](/puppet/latest/reference/lang_template_epp.html)
|
15
|
+
# documentation for examples of EPP.
|
16
|
+
#
|
17
|
+
# For example, to call the apache module's `templates/vhost/_docroot.epp`
|
18
|
+
# template and pass the `docroot` and `virtual_docroot` parameters, call the `epp`
|
19
|
+
# function like this:
|
20
|
+
#
|
21
|
+
# `epp('apache/templates/vhost/_docroot.epp', { 'docroot' => '/var/www/html',
|
22
|
+
# 'virtual_docroot' => '/var/www/example' })`
|
23
|
+
#
|
24
|
+
# Puppet produces a syntax error if you pass more parameters than are declared in
|
25
|
+
# the template's parameter tag. When passing parameters to a template that
|
26
|
+
# contains a parameter tag, use the same names as the tag's declared parameters.
|
27
|
+
#
|
28
|
+
# Parameters are required only if they are declared in the called template's
|
29
|
+
# parameter tag without default values. Puppet produces an error if the `epp`
|
30
|
+
# function fails to pass any required parameter.
|
31
|
+
#
|
40
32
|
# @since 4.0.0
|
41
33
|
#
|
42
34
|
Puppet::Functions.create_function(:epp, Puppet::Functions::InternalFunction) do
|
@@ -10,8 +10,8 @@ Puppet::Functions.create_function(:hiera_include, Hiera::PuppetFunction) do
|
|
10
10
|
:array
|
11
11
|
end
|
12
12
|
|
13
|
-
def post_lookup(key, value)
|
13
|
+
def post_lookup(scope, key, value)
|
14
14
|
raise Puppet::ParseError, "Could not find data item #{key}" if value.nil?
|
15
|
-
|
15
|
+
call_function_with_scope(scope, 'include', value) unless value.empty?
|
16
16
|
end
|
17
17
|
end
|
@@ -1,74 +1,47 @@
|
|
1
|
-
# Evaluates an Embedded Puppet
|
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
|
-
# is
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
#
|
38
|
-
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
#
|
42
|
-
#
|
43
|
-
#
|
44
|
-
#
|
45
|
-
# # produces 'Hello given argument world!'
|
46
|
-
# $x ='local variable world'
|
47
|
-
# inline_epptemplate(@(END:epp), { x =>'given argument'})
|
48
|
-
# <%- |$x| -%>
|
49
|
-
# Hello <%= $x %> world!
|
50
|
-
# END
|
51
|
-
#
|
52
|
-
# # produces 'Hello given argument world!'
|
53
|
-
# $x ='local variable world'
|
54
|
-
# inline_epptemplate(@(END:epp), { x =>'given argument'})
|
55
|
-
# <%- |$x| -%>
|
56
|
-
# Hello <%= $x %>!
|
57
|
-
# END
|
58
|
-
#
|
59
|
-
# # results in error, missing value for y
|
60
|
-
# $x ='local variable world'
|
61
|
-
# inline_epptemplate(@(END:epp), { x =>'given argument'})
|
62
|
-
# <%- |$x, $y| -%>
|
63
|
-
# Hello <%= $x %>!
|
64
|
-
# END
|
65
|
-
#
|
66
|
-
# # Produces 'Hello given argument planet'
|
67
|
-
# $x ='local variable world'
|
68
|
-
# inline_epptemplate(@(END:epp), { x =>'given argument'})
|
69
|
-
# <%- |$x, $y=planet| -%>
|
70
|
-
# Hello <%= $x %> <%= $y %>!
|
71
|
-
# END
|
1
|
+
# Evaluates an Embedded Puppet (EPP) template string and returns the rendered
|
2
|
+
# text result as a String.
|
3
|
+
#
|
4
|
+
# `inline_epp('<EPP TEMPLATE STRING>', <PARAMETER HASH>)`
|
5
|
+
#
|
6
|
+
# The first argument to this function should be a string containing an EPP
|
7
|
+
# template. In most cases, the last argument is optional; if used, it should be a
|
8
|
+
# [hash](/puppet/latest/reference/lang_data_hash.html) that contains parameters to
|
9
|
+
# pass to the template.
|
10
|
+
#
|
11
|
+
# - See the [template](/puppet/latest/reference/lang_template.html) documentation
|
12
|
+
# for general template usage information.
|
13
|
+
# - See the [EPP syntax](/puppet/latest/reference/lang_template_epp.html)
|
14
|
+
# documentation for examples of EPP.
|
15
|
+
#
|
16
|
+
# For example, to evaluate an inline EPP template and pass it the `docroot` and
|
17
|
+
# `virtual_docroot` parameters, call the `inline_epp` function like this:
|
18
|
+
#
|
19
|
+
# `inline_epp('docroot: <%= $docroot %> Virtual docroot: <%= $virtual_docroot %>',
|
20
|
+
# { 'docroot' => '/var/www/html', 'virtual_docroot' => '/var/www/example' })`
|
21
|
+
#
|
22
|
+
# Puppet produces a syntax error if you pass more parameters than are declared in
|
23
|
+
# the template's parameter tag. When passing parameters to a template that
|
24
|
+
# contains a parameter tag, use the same names as the tag's declared parameters.
|
25
|
+
#
|
26
|
+
# Parameters are required only if they are declared in the called template's
|
27
|
+
# parameter tag without default values. Puppet produces an error if the
|
28
|
+
# `inline_epp` function fails to pass any required parameter.
|
29
|
+
#
|
30
|
+
# An inline EPP template should be written as a single-quoted string or
|
31
|
+
# [heredoc](puppet/latest/reference/lang_data_string.html#heredocs).
|
32
|
+
# A double-quoted string is subject to expression interpolation before the string
|
33
|
+
# is parsed as an EPP template.
|
34
|
+
#
|
35
|
+
# For example, to evaluate an inline EPP template using a heredoc, call the
|
36
|
+
# `inline_epp` function like this:
|
37
|
+
#
|
38
|
+
# ~~~ puppet
|
39
|
+
# # Outputs 'Hello given argument planet!'
|
40
|
+
# inline_epp(@(END), { x => 'given argument' })
|
41
|
+
# <%- | $x, $y = planet | -%>
|
42
|
+
# Hello <%= $x %> <%= $y %>!
|
43
|
+
# END
|
44
|
+
# ~~~
|
72
45
|
#
|
73
46
|
# @since 4.0.0
|
74
47
|
#
|