blob: 7d73831b85a3c871604364cc899b2264d295b004 (
plain)
1
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
|
# Requires the specified classes
Puppet::Parser::Functions::newfunction(:require,
:doc =>"Evaluate one or more classes, adding the required class as a dependency.
The relationship metaparameters work well for specifying relationships
between individual resources, but they can be clumsy for specifying
relationships between classes. This function is a superset of the
'include' function, adding a class relationship so that the requiring
class depends on the required class.
.. Warning::
using require in place of include can lead to unwanted dependency cycles.
For instance the following manifest, with 'require' instead of 'include'
would produce a nasty dependence cycle, because notify imposes a before
between File[/foo] and Service[foo]::
class myservice {
service { foo: ensure => running }
}
class otherstuff {
include myservice
file { '/foo': notify => Service[foo] }
}
") do |vals|
send(:function_include, vals)
vals = [vals] unless vals.is_a?(Array)
# add a relation from ourselves to each required klass
vals.each do |klass|
compiler.catalog.add_edge(resource, findresource(:class, klass))
end
end
|