|
14 | 14 | # |
15 | 15 | # @example |
16 | 16 | # class { 'stdlib::manage': |
17 | | -# 'create_resources' => { |
18 | | -# 'file' => { |
| 17 | +# 'create_resources' => { |
| 18 | +# 'file' => { |
19 | 19 | # '/etc/motd.d/hello' => { |
20 | | -# 'content' => 'I say Hi', |
21 | | -# 'notify' => 'Service[sshd]', |
| 20 | +# 'content' => 'I say Hi', |
| 21 | +# 'notify' => 'Service[sshd]', |
| 22 | +# }, |
| 23 | +# '/etc/motd' => { |
| 24 | +# 'ensure' => 'file', |
| 25 | +# 'template' => 'profile/motd.epp', |
22 | 26 | # } |
23 | 27 | # }, |
24 | | -# 'package' => { |
25 | | -# 'example' => { |
26 | | -# 'ensure' => 'installed', |
27 | | -# 'subscribe' => ['Service[sshd]', 'Exec[something]'], |
| 28 | +# 'package' => { |
| 29 | +# 'example' => { |
| 30 | +# 'ensure' => 'installed', |
| 31 | +# 'subscribe' => ['Service[sshd]', 'Exec[something]'], |
28 | 32 | # } |
29 | 33 | # } |
30 | 34 | # } |
|
35 | 39 | # '/etc/motd.d/hello': |
36 | 40 | # content: I say Hi |
37 | 41 | # notify: 'Service[sshd]' |
| 42 | +# '/etc/motd': |
| 43 | +# ensure: 'file' |
| 44 | +# template: 'profile/motd.epp' |
38 | 45 | # package: |
39 | 46 | # example: |
40 | 47 | # ensure: installed |
|
46 | 53 | ) { |
47 | 54 | $create_resources.each |$type, $resources| { |
48 | 55 | $resources.each |$title, $attributes| { |
49 | | - create_resources($type, { $title => $attributes }) |
| 56 | + case $type { |
| 57 | + 'file': { |
| 58 | + if 'template' in $attributes and 'content' in $attributes { |
| 59 | + fail("You can not set content and template fir file ${title}") |
| 60 | + } |
| 61 | + if 'template' in $attributes { |
| 62 | + $content = epp($attributes['template']) |
| 63 | + } elsif 'content' in $attributes { |
| 64 | + $content = $attributes['content'] |
| 65 | + } else { |
| 66 | + $content = undef |
| 67 | + } |
| 68 | + file { $title: |
| 69 | + * => $attributes - 'template' - 'content', |
| 70 | + content => $content, |
| 71 | + } |
| 72 | + } |
| 73 | + default: { |
| 74 | + create_resources($type, { $title => $attributes }) |
| 75 | + } |
| 76 | + } |
50 | 77 | } |
51 | 78 | } |
52 | 79 | } |
0 commit comments