|
5 | 5 | # resource. There are a number of possible patterns to
|
6 | 6 | # generate trivial resource definitions. This is an attempt
|
7 | 7 | # to create a single clear method for uncomplicated resources.
|
8 |
| -# There is limited support for `before`, `require`, `notify`, |
9 |
| -# and `subscribe`. However, the target resources must be defined |
10 |
| -# before this module is run. |
| 8 | +# There is __limited__ support for `before`, `require`, `notify`, |
| 9 | +# and `subscribe`. |
11 | 10 | #
|
12 | 11 | # @param create_resources
|
13 | 12 | # A hash of resources to create
|
14 |
| -# NOTE: functions, such as `template` or `epp` are not evaluated. |
| 13 | +# NOTE: functions, such as `template` or `epp`, are not evaluated. |
15 | 14 | #
|
16 | 15 | # @example
|
17 | 16 | # class { 'stdlib::manage':
|
|
25 | 24 | # 'package' => {
|
26 | 25 | # 'example' => {
|
27 | 26 | # 'ensure' => 'installed',
|
| 27 | +# 'subscribe' => ['Service[sshd]', 'Exec[something]'], |
28 | 28 | # }
|
29 | 29 | # }
|
30 | 30 | # }
|
|
38 | 38 | # package:
|
39 | 39 | # example:
|
40 | 40 | # ensure: installed
|
| 41 | +# subscribe: |
| 42 | +# - 'Service[sshd]' |
| 43 | +# - 'Exec[something]' |
41 | 44 | class stdlib::manage (
|
42 | 45 | Hash[String, Hash] $create_resources = {}
|
43 | 46 | ) {
|
44 | 47 | $create_resources.each |$type, $resources| {
|
45 | 48 | $resources.each |$title, $attributes| {
|
46 |
| - $filtered_attributes = $attributes.filter |$key, $value| { |
47 |
| - $key !~ /(before|require|notify|subscribe)/ |
48 |
| - } |
49 |
| - |
50 |
| - if $attributes['before'] { |
51 |
| - $_before = stdlib::str2resource($attributes['before']) |
52 |
| - } else { |
53 |
| - $_before = undef |
54 |
| - } |
55 |
| - |
56 |
| - if $attributes['require'] { |
57 |
| - $_require = stdlib::str2resource($attributes['require']) |
58 |
| - } else { |
59 |
| - $_require = undef |
60 |
| - } |
61 |
| - |
62 |
| - if $attributes['notify'] { |
63 |
| - $_notify = stdlib::str2resource($attributes['notify']) |
64 |
| - } else { |
65 |
| - $_notify = undef |
66 |
| - } |
67 |
| - |
68 |
| - if $attributes['subscribe'] { |
69 |
| - $_subscribe = stdlib::str2resource($attributes['subscribe']) |
70 |
| - } else { |
71 |
| - $_subscribe = undef |
72 |
| - } |
73 |
| - |
74 |
| - create_resources($type, { $title => $filtered_attributes }, { 'before' => $_before, 'require' => $_require, 'notify' => $_notify, 'subscribe' => $_subscribe }) |
| 49 | + create_resources($type, { $title => $attributes }) |
75 | 50 | }
|
76 | 51 | }
|
77 | 52 | }
|
0 commit comments