|
13 | 13 | file_concat { '/tmp/file: |
14 | 14 | tag => 'unique_tag', # Mandatory |
15 | 15 | path => '/tmp/file', # Optional. If given it overrides the resource name |
16 | | - owner => 'root', # Optional. Default to root |
17 | | - group => 'root', # Optional. Default to root |
18 | | - mode => '0644' # Optional. Default to 0644 |
| 16 | + owner => 'root', # Optional. Default to undef |
| 17 | + group => 'root', # Optional. Default to undef |
| 18 | + mode => '0644' # Optional. Default to undef |
19 | 19 | order => 'numeric' # Optional, Default to 'numeric' |
20 | 20 | } |
21 | 21 | " |
@@ -46,17 +46,14 @@ def exists? |
46 | 46 |
|
47 | 47 | newparam(:owner, :parent => Puppet::Type::File::Owner) do |
48 | 48 | desc "Desired file owner." |
49 | | - defaultto 'root' |
50 | 49 | end |
51 | 50 |
|
52 | 51 | newparam(:group, :parent => Puppet::Type::File::Group) do |
53 | 52 | desc "Desired file group." |
54 | | - defaultto 'root' |
55 | 53 | end |
56 | 54 |
|
57 | 55 | newparam(:mode, :parent => Puppet::Type::File::Mode) do |
58 | 56 | desc "Desired file mode." |
59 | | - defaultto '0644' |
60 | 57 | end |
61 | 58 |
|
62 | 59 | newparam(:order) do |
@@ -141,15 +138,17 @@ def fragment_content(r) |
141 | 138 | end |
142 | 139 |
|
143 | 140 | def eval_generate |
144 | | - [Puppet::Type.type(:file).new({ |
145 | | - :ensure => self[:ensure] == :absent ? :absent : :file, |
146 | | - :path => self[:path], |
147 | | - :owner => self[:owner], |
148 | | - :group => self[:group], |
149 | | - :mode => self[:mode], |
150 | | - :replace => self[:replace], |
151 | | - :backup => self[:backup], |
| 141 | + file_opts = { |
| 142 | + :ensure => self[:ensure] == :absent ? :absent : :file, |
152 | 143 | :content => self.should_content, |
153 | | - })] |
| 144 | + } |
| 145 | + |
| 146 | + [:path, :owner, :group, :mode, :replace, :backup].each do |param| |
| 147 | + unless self[param].nil? |
| 148 | + file_opts[param] = self[param] |
| 149 | + end |
| 150 | + end |
| 151 | + |
| 152 | + [Puppet::Type.type(:file).new(file_opts)] |
154 | 153 | end |
155 | 154 | end |
0 commit comments