|
10 | 10 | example: |
11 | 11 | Concat_fragment <<| tag == 'unique_tag' |>> |
12 | 12 |
|
13 | | - concat_file { '/tmp/file: |
14 | | - tag => 'unique_tag', # Mandatory |
15 | | - path => '/tmp/file', # Optional. If given it overrides the resource name |
16 | | - owner => 'root', # Optional. Default to undef |
17 | | - group => 'root', # Optional. Default to undef |
18 | | - mode => '0644' # Optional. Default to undef |
19 | | - order => 'numeric' # Optional, Default to 'numeric' |
| 13 | + concat_file { '/tmp/file': |
| 14 | + tag => 'unique_tag', # Mandatory |
| 15 | + path => '/tmp/file', # Optional. If given it overrides the resource name |
| 16 | + owner => 'root', # Optional. Default to undef |
| 17 | + group => 'root', # Optional. Default to undef |
| 18 | + mode => '0644' # Optional. Default to undef |
| 19 | + order => 'numeric' # Optional, Default to 'numeric' |
| 20 | + ensure_newline => false # Optional, Defaults to false |
20 | 21 | } |
21 | 22 | " |
22 | 23 | ensurable do |
@@ -75,6 +76,11 @@ def exists? |
75 | 76 | desc "Validates file." |
76 | 77 | end |
77 | 78 |
|
| 79 | + newparam(:ensure_newline) do |
| 80 | + desc "Whether to ensure there is a newline after each fragment." |
| 81 | + defaultto false |
| 82 | + end |
| 83 | + |
78 | 84 | autorequire(:concat_fragment) do |
79 | 85 | catalog.resources.collect do |r| |
80 | 86 | if r.is_a?(Puppet::Type.type(:concat_fragment)) && r[:tag] == self[:tag] |
@@ -134,6 +140,11 @@ def fragment_content(r) |
134 | 140 | tmp = Puppet::FileServing::Content.indirection.find(@source, :environment => catalog.environment) |
135 | 141 | fragment_content = tmp.content unless tmp.nil? |
136 | 142 | end |
| 143 | + |
| 144 | + if self[:ensure_newline] |
| 145 | + fragment_content<<"\n" |
| 146 | + end |
| 147 | +
|
137 | 148 | fragment_content |
138 | 149 | end |
139 | 150 |
|
|
0 commit comments