|
41 | 41 | # notify: 'Service[sshd]' |
42 | 42 | # '/etc/motd': |
43 | 43 | # ensure: 'file' |
44 | | -# template: 'profile/motd.epp' |
| 44 | +# epp: |
| 45 | +# template: 'profile/motd.epp' |
| 46 | +# context: {} |
| 47 | +# '/etc/information': |
| 48 | +# ensure: 'file' |
| 49 | +# erb: |
| 50 | +# template: 'profile/information.erb' |
45 | 51 | # package: |
46 | 52 | # example: |
47 | 53 | # ensure: installed |
|
55 | 61 | $resources.each |$title, $attributes| { |
56 | 62 | case $type { |
57 | 63 | 'file': { |
58 | | - if 'template' in $attributes and 'content' in $attributes { |
59 | | - fail("You can not set 'content' and 'template' for file ${title}") |
| 64 | + # sanity checks |
| 65 | + # epp, erb and content are exclusive |
| 66 | + if 'epp' in $attributes and 'content' in $attributes { |
| 67 | + fail("You can not set 'epp' and 'content' for file ${title}") |
| 68 | + } |
| 69 | + if 'erb' in $attributes and 'content' in $attributes { |
| 70 | + fail("You can not set 'erb' and 'content' for file ${title}") |
| 71 | + } |
| 72 | + if 'erb' in $attributes and 'epp' in $attributes { |
| 73 | + fail("You can not set 'erb' and 'epp' for file ${title}") |
60 | 74 | } |
61 | | - if 'template' in $attributes { |
62 | | - $content = epp($attributes['template']) |
| 75 | + |
| 76 | + if 'epp' in $attributes { |
| 77 | + if 'template' in $attributes['epp'] { |
| 78 | + if 'context' in $attributes['epp'] { |
| 79 | + $content = epp($attributes['epp']['template'], $attributes['epp']['context']) |
| 80 | + } else { |
| 81 | + $content = epp($attributes['epp']['template']) |
| 82 | + } |
| 83 | + } else { |
| 84 | + fail("No template configured for epp for file ${title}") |
| 85 | + } |
| 86 | + } elsif 'erb' in $attributes { |
| 87 | + if 'template' in $attributes['erb'] { |
| 88 | + $content = template($attributes['erb']['template']) |
| 89 | + } else { |
| 90 | + fail("No template configured for erb for file ${title}") |
| 91 | + } |
63 | 92 | } elsif 'content' in $attributes { |
64 | 93 | $content = $attributes['content'] |
65 | 94 | } else { |
66 | 95 | $content = undef |
67 | 96 | } |
68 | 97 | file { $title: |
69 | | - * => $attributes - 'template' - 'content', |
| 98 | + * => $attributes - 'erb' - 'epp' - 'content', |
70 | 99 | content => $content, |
71 | 100 | } |
72 | 101 | } |
|
0 commit comments